Code Monkey home page Code Monkey logo

ks-orderapi-python's Introduction

ks_api_client

No description provided

  • API version: 1.0.1
  • Package version: 1.0.15

Requirements.

Python 2.7 and 3.4+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/osparamatrix/ks-orderapi-python.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/osparamatrix/ks-orderapi-python.git)

Then import the package:

import ks_api_client

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import ks_api_client

Getting Started

Please follow the installation procedure and then run the following:

from ks_api_client import ks_api
# Defining the host is optional and defaults to https://tradeapi.kotaksecurities.com/apim
# See configuration.py for a list of all supported configuration parameters.
client = ks_api.KSTradeApi(access_token = "", userid = "", \
                consumer_key = "", ip = "127.0.0.1", app_id = "")

#For using sandbox environment use host as https://sbx.kotaksecurities.com/apim
client = ks_api.KSTradeApi(access_token = "", userid = "", \
                consumer_key = "", ip = "127.0.0.1", app_id = "", host = "https://sbx.kotaksecurities.com/apim")
		
# Get session for user
client.login(password = "")

#Generated session token
client.session_2fa(access_code = "")

# Place an order
client.place_order(order_type = "N", instrument_token = 727, transaction_type = "BUY",\
                       quantity = 1, price = 0, disclosed_quantity = 0, trigger_price = 0,\
                            validity = "GFD", variety = "REGULAR", tag = "string")
# Place an MIS order
client.place_order(order_type = "MIS", instrument_token = 727, transaction_type = "BUY",\
                       quantity = 1, price = 0, disclosed_quantity = 0, trigger_price = 0,\
                            validity = "GFD", variety = "REGULAR", tag = "string")			    
						
# Modify an order
client.modify_order(order_id = "", quantity = 1, price = 0, disclosed_quantity = 0, trigger_price = 0, validity = "GFD")

# Cancel an order
client.cancel_order(order_id = "")

# Get Report Orders
client.order_report()

# Get Report Orders for order id
client.order_report(order_id = "")

# Get Margin required
order_info = [
    {"instrument_token": 727, "quantity": 1, "price": 1300, "amount": 0, "trigger_price": 1190},
    {"instrument_token": 1374, "quantity": 1, "price": 1200, "amount": 0, "trigger_price": 1150}
]
client.margin_required(transaction_type = "BUY",order_info = order_info)

# Get Positions
client.positions(position_type = "TODAYS")

# Get Quote details
client.quote(instrument_token = 110)

# Get Historical data
client.history("historicalprices",{"exchange":"bse","cocode":"476","fromdate":"01-jan-2014","todate":"08-oct-2015"})
client.history("historicalprices-unadjusted",{"exchange":"bse","co_code":"476","date":"16-Jun-2016"})
client.history("NSEFNO_HistoricalContinuousChart",{"symbol":"HDFC","expiry type": "near"})
client.history("LiveorEODHistorical",{"exchange":"BSE","co_code":"5400","period":"Y","cnt":"3"})

#Terminate user's Session
client.logout()

Documentation for API Endpoints

All URIs are relative to https://tradeapi.kotaksecurities.com/apim

Class Method Description
SessionApi ks_api.KSTradeApi Initialise Session
SessionApi login Login using Userid
SessionApi session_2fa Generate final Session Token
OrderApi place_order Place a New order
OrderApi modify_order Modify an existing order
OrderApi cancel_order Cancel an order
ReportsApi order_report Get order report
ReportsApi trade_report Get trade report
MarginApi margin_required Get Margin Required for an order by amount or quantity.
PositionsApi positions Get's Open position.
QuoteApi quote Get Quote details
HistoricalApi history Get historical data.
SessionApi logout Invalidate Session Token

ks-orderapi-python's People

Contributors

thebhushanp avatar harshad5498 avatar shubhamzemse94 avatar osparamatrix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.