├── python ├── test │ ├── __init__.py │ ├── test_order_api.py │ ├── test_token_api.py │ ├── test_normal_order_api.py │ ├── test_smart_order_routing_api.py │ ├── test_super_multiple_order_api.py │ ├── test_gtcplace.py │ ├── test_codplace.py │ ├── test_ctdplace.py │ ├── test_codmodify.py │ ├── test_gtcmodify.py │ ├── test_ctdmodify.py │ ├── test_quote_api.py │ ├── test_fault.py │ ├── test_positions_api.py │ ├── test_tsloplace.py │ ├── test_margin_trading_api.py │ ├── test_user_details.py │ ├── test_tslomodify.py │ ├── test_user_credentials.py │ ├── test_margin_det.py │ ├── test_order_info.py │ ├── test_bracketplace.py │ ├── test_bracketmodify.py │ ├── test_session_api.py │ ├── test_existing_sor_order.py │ ├── test_existing_sm_order.py │ ├── test_new_sm_order.py │ ├── test_new_mtf_order.py │ ├── test_new_sor_order.py │ ├── test_existing_mtf_order.py │ ├── test_new_normal_order.py │ ├── test_existing_normal_order.py │ ├── test_margin_api.py │ ├── test_orders.py │ └── test_reports_api.py ├── test-requirements.txt ├── requirements.txt ├── ks_api_client │ ├── settings.py │ ├── api │ │ ├── __init__.py │ │ └── historical_api.py │ ├── models │ │ ├── __init__.py │ │ ├── codmodify.py │ │ ├── inline_object.py │ │ ├── gtcmodify.py │ │ ├── gtcplace.py │ │ ├── ctdplace.py │ │ ├── ctdmodify.py │ │ ├── codplace.py │ │ ├── user_credentials.py │ │ ├── tsloplace.py │ │ ├── user_details.py │ │ ├── req_margin.py │ │ ├── fault.py │ │ ├── tslomodify.py │ │ ├── margin_det.py │ │ ├── bracketplace.py │ │ ├── bracketmodify.py │ │ └── order_info.py │ ├── __init__.py │ └── exceptions.py ├── docs │ ├── Gtcmodify.md │ ├── Ctdplace.md │ ├── Codmodify.md │ ├── Ctdmodify.md │ ├── UserCredentials.md │ ├── Gtcplace.md │ ├── ReqMargin.md │ ├── UserDetails.md │ ├── Fault.md │ ├── Tsloplace.md │ ├── Codplace.md │ ├── Tslomodify.md │ ├── Bracketplace.md │ ├── Bracketmodify.md │ ├── ExistingMTFOrder.md │ ├── ExistingSMOrder.md │ ├── ExistingSOROrder.md │ ├── ExistingNormalOrder.md │ ├── OrderInfo.md │ ├── NewSOROrder.md │ ├── NewSMOrder.md │ ├── NewMTFOrder.md │ ├── NewNormalOrder.md │ ├── ExistingOrder.md │ ├── NewOrder.md │ ├── HistoricalApi.md │ ├── QuoteApi.md │ ├── StreamingApi.md │ ├── TokenApi.md │ ├── README.md │ └── ReportsApi.md ├── .travis.yml ├── .gitlab-ci.yml ├── setup.py ├── .gitignore ├── .openapi-generator-ignore └── README.md ├── README.md └── .gitignore /python/test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ksapi 2 | The libraries to integrate Kotak Securities Trading APIs. 3 | -------------------------------------------------------------------------------- /python/test-requirements.txt: -------------------------------------------------------------------------------- 1 | pytest~=4.6.7 # needed for python 2.7+3.4 2 | pytest-cov>=2.8.1 3 | pytest-randomly==1.2.3 # needed for python 2.7+3.4 4 | -------------------------------------------------------------------------------- /python/requirements.txt: -------------------------------------------------------------------------------- 1 | certifi >= 14.05.14 2 | future; python_version<="2.7" 3 | six >= 1.10 4 | python_dateutil >= 2.5.3 5 | setuptools >= 21.0.0 6 | urllib3 >= 1.15.1 7 | python-socketio[client]==5.3.0 8 | requests==2.26.0 9 | python-dotenv==0.19.2 -------------------------------------------------------------------------------- /python/ks_api_client/settings.py: -------------------------------------------------------------------------------- 1 | access_token = "" 2 | userid = "" 3 | consumer_key = "" 4 | consumer_secret = "" 5 | broadcast_host = "https://wstreamer.kotaksecurities.com/feed" 6 | ip = "127.0.0.1" 7 | app_id = "" 8 | proxy_url = "" 9 | proxy_user = "" 10 | proxy_pass = "" 11 | cacert_file = "" 12 | cacert_dir = "" -------------------------------------------------------------------------------- /python/docs/Gtcmodify.md: -------------------------------------------------------------------------------- 1 | # Gtcmodify 2 | 3 | Order parmaeter for Product GTC 4 | ## Properties 5 | Name | Type | Description | Notes 6 | ------------ | ------------- | ------------- | ------------- 7 | **gtcOrderNo** | **str** | Order Number to modify | [optional] 8 | 9 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /python/docs/Ctdplace.md: -------------------------------------------------------------------------------- 1 | # Ctdplace 2 | 3 | Order parmaeter for Product CTD 4 | ## Properties 5 | Name | Type | Description | Notes 6 | ------------ | ------------- | ------------- | ------------- 7 | **ConvertQuantity** | **int** | Quantity to convert to delivery | [optional] 8 | 9 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /python/docs/Codmodify.md: -------------------------------------------------------------------------------- 1 | # Codmodify 2 | 3 | Call of the day Order parmaeter for Product COD 4 | ## Properties 5 | Name | Type | Description | Notes 6 | ------------ | ------------- | ------------- | ------------- 7 | **orderNo** | **str** | Order Number to modify | [optional] 8 | 9 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /python/docs/Ctdmodify.md: -------------------------------------------------------------------------------- 1 | # Ctdmodify 2 | 3 | Order parmaeter for Product CTD 4 | ## Properties 5 | Name | Type | Description | Notes 6 | ------------ | ------------- | ------------- | ------------- 7 | **ConvertQuantity** | **int** | Quantity to convert to delivery | [optional] 8 | 9 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /python/docs/UserCredentials.md: -------------------------------------------------------------------------------- 1 | # UserCredentials 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **userid** | **str** | Your KSEC userID | [optional] 7 | **password** | **str** | Your KSEC password | [optional] 8 | 9 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /python/.travis.yml: -------------------------------------------------------------------------------- 1 | # ref: https://docs.travis-ci.com/user/languages/python 2 | language: python 3 | python: 4 | - "2.7" 5 | - "3.2" 6 | - "3.3" 7 | - "3.4" 8 | - "3.5" 9 | - "3.6" 10 | - "3.7" 11 | - "3.8" 12 | # command to install dependencies 13 | install: 14 | - "pip install -r requirements.txt" 15 | - "pip install -r test-requirements.txt" 16 | # command to run tests 17 | script: pytest --cov=ks_api_client 18 | -------------------------------------------------------------------------------- /python/docs/Gtcplace.md: -------------------------------------------------------------------------------- 1 | # Gtcplace 2 | 3 | Order parmaeter for Product GTC 4 | ## Properties 5 | Name | Type | Description | Notes 6 | ------------ | ------------- | ------------- | ------------- 7 | **closeDate** | **str** | Close date for GTC order till which order to be placed in exchange by system. | [optional] 8 | 9 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /python/docs/ReqMargin.md: -------------------------------------------------------------------------------- 1 | # ReqMargin 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **transactionType** | **str** | Transaction Type - BUY or SELL | [optional] 7 | **orderInfo** | [**list[OrderInfo]**](OrderInfo.md) | | [optional] 8 | 9 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /python/docs/UserDetails.md: -------------------------------------------------------------------------------- 1 | # UserDetails 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **userid** | **str** | Userid for which access code validation | [optional] 7 | **accessCode** | **str** | Login access code received on email and mobile no | [optional] 8 | 9 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /python/docs/Fault.md: -------------------------------------------------------------------------------- 1 | # Fault 2 | 3 | Fault Details 4 | ## Properties 5 | Name | Type | Description | Notes 6 | ------------ | ------------- | ------------- | ------------- 7 | **code** | **int** | error code | [optional] 8 | **message** | **str** | error message | [optional] 9 | **description** | **str** | error description | [optional] 10 | 11 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | 14 | -------------------------------------------------------------------------------- /python/docs/Tsloplace.md: -------------------------------------------------------------------------------- 1 | # Tsloplace 2 | 3 | TSLO Order parmaeter for Product TSLO 4 | ## Properties 5 | Name | Type | Description | Notes 6 | ------------ | ------------- | ------------- | ------------- 7 | **spread** | **float** | Spread of the order | [optional] 8 | **trailingPrice** | **float** | Triling price of TSLO Order. | [optional] 9 | 10 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /python/docs/Codplace.md: -------------------------------------------------------------------------------- 1 | # Codplace 2 | 3 | Call of the day Order parmaeter for Product COD 4 | ## Properties 5 | Name | Type | Description | Notes 6 | ------------ | ------------- | ------------- | ------------- 7 | **squareOffFlag** | **int** | Square off flag for COD order, 1 to auto square off order. 0 - for no auto Square off by system. | [optional] 8 | 9 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /python/docs/Tslomodify.md: -------------------------------------------------------------------------------- 1 | # Tslomodify 2 | 3 | TSLO Order parmaeter for Product TSLO 4 | ## Properties 5 | Name | Type | Description | Notes 6 | ------------ | ------------- | ------------- | ------------- 7 | **orderIndicator** | **int** | Order Indicator to modify Order | [optional] 8 | **spread** | **float** | Spread of the order | [optional] 9 | **trailingPrice** | **float** | Triling price of TSLO Order. | [optional] 10 | 11 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | 14 | -------------------------------------------------------------------------------- /python/docs/Bracketplace.md: -------------------------------------------------------------------------------- 1 | # Bracketplace 2 | 3 | Bracket Order parmaeter for Product Bracket 4 | ## Properties 5 | Name | Type | Description | Notes 6 | ------------ | ------------- | ------------- | ------------- 7 | **Spread** | **float** | Spread of the order | [optional] 8 | **trailingPrice** | **float** | Triling price of TSLO Order. | [optional] 9 | **bookProfit** | **float** | Book Profit Price of the order | [optional] 10 | **bookDisclosedQty** | **int** | Quantity to be disclosed in bracket order | [optional] 11 | 12 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /python/docs/Bracketmodify.md: -------------------------------------------------------------------------------- 1 | # Bracketmodify 2 | 3 | Bracket Order parmaeter for Product Bracket 4 | ## Properties 5 | Name | Type | Description | Notes 6 | ------------ | ------------- | ------------- | ------------- 7 | **orderIndicator** | **int** | Order Indicator to modify Order | [optional] 8 | **Spread** | **float** | Spread of the order | [optional] 9 | **trailingPrice** | **float** | Triling price of TSLO Order. | [optional] 10 | **bookProfit** | **float** | Book Profit Price of the order | [optional] 11 | **bookDisclosedQty** | **int** | Quantity to be disclosed in bracket order | [optional] 12 | 13 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 14 | 15 | 16 | -------------------------------------------------------------------------------- /python/docs/ExistingMTFOrder.md: -------------------------------------------------------------------------------- 1 | # ExistingMTFOrder 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **orderId** | **str** | Order ID of the order to be modified | 7 | **quantity** | **int** | Order quantity - specified in same unit as quoted in market depth | [optional] 8 | **price** | **float** | Order Price, non zero positive for limit order and zero for market order | [optional] 9 | **disclosedQuantity** | **int** | Quantity to be disclosed in order | [optional] 10 | **triggerPrice** | **float** | Trigger price, required for stoploss or supermultiple order | [optional] 11 | 12 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /python/docs/ExistingSMOrder.md: -------------------------------------------------------------------------------- 1 | # ExistingSMOrder 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **orderId** | **str** | Order ID of the order to be modified | 7 | **quantity** | **int** | Order quantity - specified in same unit as quoted in market depth | [optional] 8 | **price** | **float** | Order Price, non zero positive for limit order and zero for market order | [optional] 9 | **disclosedQuantity** | **int** | Quantity to be disclosed in order | [optional] 10 | **triggerPrice** | **float** | Trigger price, required for stoploss or supermultiple order | [optional] 11 | 12 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /python/docs/ExistingSOROrder.md: -------------------------------------------------------------------------------- 1 | # ExistingSOROrder 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **orderId** | **str** | Order ID of the order to be modified | 7 | **quantity** | **int** | Order quantity - specified in same unit as quoted in market depth | [optional] 8 | **price** | **float** | Order Price, non zero positive for limit order and zero for market order | [optional] 9 | **disclosedQuantity** | **int** | Quantity to be disclosed in order | [optional] 10 | **triggerPrice** | **float** | Trigger price, required for stoploss or supermultiple order | [optional] 11 | 12 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /python/docs/ExistingNormalOrder.md: -------------------------------------------------------------------------------- 1 | # ExistingNormalOrder 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **orderId** | **str** | Order ID of the order to be modified | 7 | **quantity** | **int** | Order quantity - specified in same unit as quoted in market depth | [optional] 8 | **price** | **float** | Order Price, non zero positive for limit order and zero for market order | [optional] 9 | **disclosedQuantity** | **int** | Quantity to be disclosed in order | [optional] 10 | **triggerPrice** | **float** | Trigger price, required for stoploss or supermultiple order | [optional] 11 | 12 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /python/docs/OrderInfo.md: -------------------------------------------------------------------------------- 1 | # OrderInfo 2 | 3 | Order info for Margin Details 4 | ## Properties 5 | Name | Type | Description | Notes 6 | ------------ | ------------- | ------------- | ------------- 7 | **instrumentToken** | **int** | Instrument token of the scrip to be traded | [optional] 8 | **quantity** | **int** | Order quantity - specified in same unit as quoted in market depth | [optional] 9 | **price** | **float** | Order Price, non zero positive for limit order and zero for market order | [optional] 10 | **amount** | **int** | Order Amount | [optional] 11 | **triggerPrice** | **float** | Trigger price, required for stoploss or supermultiple order | [optional] 12 | 13 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 14 | 15 | 16 | -------------------------------------------------------------------------------- /python/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # ref: https://docs.gitlab.com/ee/ci/README.html 2 | 3 | stages: 4 | - test 5 | 6 | .nosetest: 7 | stage: test 8 | script: 9 | - pip install -r requirements.txt 10 | - pip install -r test-requirements.txt 11 | - pytest --cov=ks_api_client 12 | 13 | nosetest-2.7: 14 | extends: .nosetest 15 | image: python:2.7-alpine 16 | nosetest-3.3: 17 | extends: .nosetest 18 | image: python:3.3-alpine 19 | nosetest-3.4: 20 | extends: .nosetest 21 | image: python:3.4-alpine 22 | nosetest-3.5: 23 | extends: .nosetest 24 | image: python:3.5-alpine 25 | nosetest-3.6: 26 | extends: .nosetest 27 | image: python:3.6-alpine 28 | nosetest-3.7: 29 | extends: .nosetest 30 | image: python:3.7-alpine 31 | nosetest-3.8: 32 | extends: .nosetest 33 | image: python:3.8-alpine 34 | -------------------------------------------------------------------------------- /python/setup.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | from setuptools import setup, find_packages # noqa: H301 4 | 5 | NAME = "ks-api-client" 6 | VERSION = "1.1.0" 7 | # To install the library, run the following 8 | # 9 | # python setup.py install 10 | # 11 | # prerequisite: setuptools http://pypi.python.org/pypi/setuptools 12 | 13 | REQUIRES = ["certifi>=14.05.14", "six >= 1.10", "python_dateutil >= 2.5.3", "urllib3 > 1.15", "python-socketio[client]==5.3.0","requests==2.26.0", "python-dotenv==0.19.2"] 14 | 15 | setup( 16 | name=NAME, 17 | version=VERSION, 18 | description="KS Trade API's", 19 | author="KS-Trade API", 20 | author_email="team@xyz.org", 21 | url="", 22 | keywords=["KS-Trade API", "KS Trade API's"], 23 | install_requires=REQUIRES, 24 | packages=find_packages(exclude=["test", "tests"]), 25 | include_package_data=True, 26 | long_description="""\ 27 | """ 28 | ) 29 | -------------------------------------------------------------------------------- /python/ks_api_client/api/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | # flake8: noqa 4 | 5 | # import apis into api package 6 | from ks_api_client.api.historical_api import HistoricalApi 7 | from ks_api_client.api.mis_order_api import MISOrderApi 8 | from ks_api_client.api.margin_api import MarginApi 9 | from ks_api_client.api.margin_trading_api import MarginTradingApi 10 | from ks_api_client.api.normal_order_api import NormalOrderApi 11 | from ks_api_client.api.order_api import OrderApi 12 | from ks_api_client.api.positions_api import PositionsApi 13 | from ks_api_client.api.quote_api import QuoteApi 14 | from ks_api_client.api.reports_api import ReportsApi 15 | from ks_api_client.api.session_api import SessionApi 16 | from ks_api_client.api.smart_order_routing_api import SmartOrderRoutingApi 17 | from ks_api_client.api.super_multiple_order_api import SuperMultipleOrderApi 18 | from ks_api_client.api.token_api import TokenApi 19 | -------------------------------------------------------------------------------- /python/test/test_order_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | 10 | import ks_api_client 11 | from ks_api_client.api.order_api import OrderApi # noqa: E501 12 | from ks_api_client.rest import ApiException 13 | 14 | class TestOrderApi(unittest.TestCase): 15 | """OrderApi unit test stubs""" 16 | 17 | def setUp(self): 18 | self.api = ks_api_client.api.order_api.OrderApi() # noqa: E501 19 | 20 | def tearDown(self): 21 | pass 22 | 23 | def test_modify_order(self): 24 | """Test case for modify_order 25 | 26 | Modify an existing order # noqa: E501 27 | """ 28 | pass 29 | 30 | def test_place_new_order(self): 31 | """Test case for place_new_order 32 | 33 | Place a New order # noqa: E501 34 | """ 35 | pass 36 | 37 | if __name__ == '__main__': 38 | unittest.main() 39 | -------------------------------------------------------------------------------- /python/docs/NewSOROrder.md: -------------------------------------------------------------------------------- 1 | # NewSOROrder 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **instrumentToken** | **int** | Instrument token of the scrip to be traded | [optional] 7 | **transactionType** | **str** | Transaction Type - BUY or SELL | [optional] 8 | **quantity** | **int** | Order quantity - specified in same unit as quoted in market depth | [optional] 9 | **price** | **float** | Order Price for SOR order is always zero i.e. Market Order | [optional] 10 | **validity** | **str** | Validity of the order - GFD for SOR by default | [optional] 11 | **variety** | **str** | Variety of the SOR order - REGULAR by Default. | [optional] 12 | **disclosedQuantity** | **int** | Quantity to be disclosed in order | [optional] 13 | **triggerPrice** | **float** | Trigger price, required for stoploss or supermultiple order | [optional] 14 | **tag** | **str** | Tag for this order | [optional] 15 | 16 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 17 | 18 | 19 | -------------------------------------------------------------------------------- /python/test/test_token_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Token-API 5 | 6 | No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 7 | 8 | OpenAPI spec version: 1.0 9 | Generated by: https://openapi-generator.tech 10 | """ 11 | 12 | 13 | from __future__ import absolute_import 14 | 15 | import unittest 16 | 17 | import ks_api_client 18 | from ks_api_client.api.token_api import TokenApi # noqa: E501 19 | from ks_api_client.rest import ApiException 20 | 21 | 22 | class TestTokenApi(unittest.TestCase): 23 | """DefaultApi unit test stubs""" 24 | 25 | def setUp(self): 26 | self.api = ks_api_client.api.token_api.TokenApi() # noqa: E501 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def test_revoke_post(self): 32 | """Test case for revoke_post 33 | 34 | """ 35 | pass 36 | 37 | def test_token_post(self): 38 | """Test case for token_post 39 | 40 | """ 41 | pass 42 | 43 | 44 | if __name__ == '__main__': 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /python/docs/NewSMOrder.md: -------------------------------------------------------------------------------- 1 | # NewSMOrder 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **instrumentToken** | **int** | Instrument token of the scrip to be traded | [optional] 7 | **transactionType** | **str** | Transaction Type - BUY or SELL | [optional] 8 | **quantity** | **int** | Order quantity - specified in same unit as quoted in market depth | [optional] 9 | **price** | **float** | Order Price, non zero positive for limit order and zero for market order | [optional] 10 | **validity** | **str** | Validity of the order - GFD, IOC etc | [optional] 11 | **variety** | **str** | Variety of the order - REGULAR, AMO, SQUAREOFF - for Super Multiple Orders etc | [optional] 12 | **disclosedQuantity** | **int** | Quantity to be disclosed in order | [optional] 13 | **triggerPrice** | **float** | Trigger price, required for stoploss or supermultiple order | [optional] 14 | **tag** | **str** | Tag for this order | [optional] 15 | 16 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 17 | 18 | 19 | -------------------------------------------------------------------------------- /python/docs/NewMTFOrder.md: -------------------------------------------------------------------------------- 1 | # NewMTFOrder 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **instrumentToken** | **int** | Instrument token of the scrip to be traded | [optional] 7 | **transactionType** | **str** | Transaction Type - BUY or SELL | [optional] 8 | **quantity** | **int** | Order quantity - specified in same unit as quoted in market depth | [optional] 9 | **price** | **float** | Order Price, non zero positive for limit order and zero for market order | [optional] 10 | **validity** | **str** | Validity of the order - GFD, IOC etc | [optional] 11 | **variety** | **str** | Variety of the order - REGULAR, AMO, SQUAREOFF - for Super Multiple Orders etc | [optional] 12 | **disclosedQuantity** | **int** | Quantity to be disclosed in order | [optional] 13 | **triggerPrice** | **float** | Trigger price, required for stoploss or supermultiple order | [optional] 14 | **tag** | **str** | Tag for this order | [optional] 15 | 16 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 17 | 18 | 19 | -------------------------------------------------------------------------------- /python/docs/NewNormalOrder.md: -------------------------------------------------------------------------------- 1 | # NewNormalOrder 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **instrumentToken** | **int** | Instrument token of the scrip to be traded | [optional] 7 | **transactionType** | **str** | Transaction Type - BUY or SELL | [optional] 8 | **quantity** | **int** | Order quantity - specified in same unit as quoted in market depth | [optional] 9 | **price** | **float** | Order Price, non zero positive for limit order and zero for market order | [optional] 10 | **validity** | **str** | Validity of the order - GFD, IOC etc | [optional] 11 | **variety** | **str** | Variety of the order - REGULAR, AMO, SQUAREOFF - for Super Multiple Orders etc | [optional] 12 | **disclosedQuantity** | **int** | Quantity to be disclosed in order | [optional] 13 | **triggerPrice** | **float** | Trigger price, required for stoploss or supermultiple order | [optional] 14 | **tag** | **str** | Tag for this order | [optional] 15 | 16 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 17 | 18 | 19 | -------------------------------------------------------------------------------- /python/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | venv/ 48 | .venv/ 49 | .python-version 50 | .pytest_cache 51 | 52 | # Translations 53 | *.mo 54 | *.pot 55 | 56 | # Django stuff: 57 | *.log 58 | 59 | # Sphinx documentation 60 | docs/_build/ 61 | 62 | # PyBuilder 63 | target/ 64 | 65 | #Ipython Notebook 66 | .ipynb_checkpoints 67 | 68 | .openapi-generator/ -------------------------------------------------------------------------------- /python/test/test_normal_order_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | 10 | import ks_api_client 11 | from ks_api_client.api.normal_order_api import NormalOrderApi # noqa: E501 12 | from ks_api_client.rest import ApiException 13 | 14 | class TestNormalOrderApi(unittest.TestCase): 15 | """NormalOrderApi unit test stubs""" 16 | 17 | def setUp(self): 18 | self.api = ks_api_client.api.normal_order_api.NormalOrderApi() # noqa: E501 19 | 20 | def tearDown(self): 21 | pass 22 | 23 | def test_cancel_normal_order(self): 24 | """Test case for cancel_normal_order 25 | 26 | Cancel a Normal order # noqa: E501 27 | """ 28 | pass 29 | 30 | def test_modify_normal_order(self): 31 | """Test case for modify_normal_order 32 | 33 | Modify an existing normal order # noqa: E501 34 | """ 35 | pass 36 | 37 | def test_place_new_normal_order(self): 38 | """Test case for place_new_normal_order 39 | 40 | Place a New normal order # noqa: E501 41 | """ 42 | pass 43 | 44 | 45 | if __name__ == '__main__': 46 | unittest.main() 47 | -------------------------------------------------------------------------------- /python/test/test_smart_order_routing_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | 10 | import ks_api_client 11 | from ks_api_client.api.smart_order_routing_api import SmartOrderRoutingApi # noqa: E501 12 | from ks_api_client.rest import ApiException 13 | 14 | 15 | class TestSmartOrderRoutingApi(unittest.TestCase): 16 | """SmartOrderRoutingApi unit test stubs""" 17 | 18 | def setUp(self): 19 | self.api = ks_api_client.api.smart_order_routing_api.SmartOrderRoutingApi() # noqa: E501 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def test_cancel_sor_order(self): 25 | """Test case for cancel_sor_order 26 | 27 | Cancel an SORorder # noqa: E501 28 | """ 29 | pass 30 | 31 | def test_modify_sor_order(self): 32 | """Test case for modify_sor_order 33 | 34 | Modify an existing SOR order # noqa: E501 35 | """ 36 | pass 37 | 38 | def test_place_new_sor_order(self): 39 | """Test case for place_new_sor_order 40 | 41 | Place a New SOR order # noqa: E501 42 | """ 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | -------------------------------------------------------------------------------- /python/test/test_super_multiple_order_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | 10 | import ks_api_client 11 | from ks_api_client.api.super_multiple_order_api import SuperMultipleOrderApi # noqa: E501 12 | from ks_api_client.rest import ApiException 13 | 14 | 15 | class TestSuperMultipleOrderApi(unittest.TestCase): 16 | """SuperMultipleOrderApi unit test stubs""" 17 | 18 | def setUp(self): 19 | self.api = ks_api_client.api.super_multiple_order_api.SuperMultipleOrderApi() # noqa: E501 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def test_cancel_sm_order(self): 25 | """Test case for cancel_sm_order 26 | 27 | Cancel an Super Multiple order # noqa: E501 28 | """ 29 | pass 30 | 31 | def test_modify_sm_order(self): 32 | """Test case for modify_sm_order 33 | 34 | Modify an existing super multiple order # noqa: E501 35 | """ 36 | pass 37 | 38 | def test_place_new_sm_order(self): 39 | """Test case for place_new_sm_order 40 | 41 | Place a New Super Multiple order # noqa: E501 42 | """ 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | -------------------------------------------------------------------------------- /python/docs/ExistingOrder.md: -------------------------------------------------------------------------------- 1 | # ExistingOrder 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **orderId** | **str** | Order ID of the order to be modified | 7 | **quantity** | **int** | Order quantity - specified in same unit as quoted in market depth | [optional] 8 | **price** | **float** | Order Price, non zero positive for limit order and zero for market order | [optional] 9 | **disclosedQuantity** | **int** | Quantity to be disclosed in order | [optional] 10 | **triggerPrice** | **float** | Trigger price, required for stoploss or supermultiple order | [optional] 11 | **validity** | **str** | Validity of the order - GFD, IOC etc | [optional] 12 | **tslo** | [**Tslomodify**](Tslomodify.md) | | [optional] 13 | **bracket** | [**Bracketmodify**](Bracketmodify.md) | | [optional] 14 | **tslonew** | [**Tslomodify**](Tslomodify.md) | | [optional] 15 | **bracketnew** | [**Bracketmodify**](Bracketmodify.md) | | [optional] 16 | **gtc** | [**Gtcmodify**](Gtcmodify.md) | | [optional] 17 | **ctd** | [**Ctdmodify**](Ctdmodify.md) | | [optional] 18 | **cod** | [**Codmodify**](Codmodify.md) | | [optional] 19 | 20 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 21 | 22 | 23 | -------------------------------------------------------------------------------- /python/test/test_gtcplace.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.gtcplace import Gtcplace # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestGtcplace(unittest.TestCase): 16 | """Gtcplace unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test Gtcplace 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.gtcplace.Gtcplace() # noqa: E501 30 | if include_optional : 31 | return Gtcplace( 32 | closeDate = '0' 33 | ) 34 | else : 35 | return Gtcplace( 36 | ) 37 | 38 | def testGtcplace(self): 39 | """Test Gtcplace""" 40 | inst_req_only = self.make_instance(include_optional=False) 41 | inst_req_and_optional = self.make_instance(include_optional=True) 42 | 43 | 44 | if __name__ == '__main__': 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /python/test/test_codplace.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.codplace import Codplace # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestCodplace(unittest.TestCase): 16 | """Codplace unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test Codplace 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.codplace.Codplace() # noqa: E501 30 | if include_optional : 31 | return Codplace( 32 | squareOffFlag = 56 33 | ) 34 | else : 35 | return Codplace( 36 | ) 37 | 38 | def testCodplace(self): 39 | """Test Codplace""" 40 | inst_req_only = self.make_instance(include_optional=False) 41 | inst_req_and_optional = self.make_instance(include_optional=True) 42 | 43 | 44 | if __name__ == '__main__': 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /python/test/test_ctdplace.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.ctdplace import Ctdplace # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestCtdplace(unittest.TestCase): 16 | """Ctdplace unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test Ctdplace 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.ctdplace.Ctdplace() # noqa: E501 30 | if include_optional : 31 | return Ctdplace( 32 | ConvertQuantity = 56 33 | ) 34 | else : 35 | return Ctdplace( 36 | ) 37 | 38 | def testCtdplace(self): 39 | """Test Ctdplace""" 40 | inst_req_only = self.make_instance(include_optional=False) 41 | inst_req_and_optional = self.make_instance(include_optional=True) 42 | 43 | 44 | if __name__ == '__main__': 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /python/test/test_codmodify.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.codmodify import Codmodify # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestCodmodify(unittest.TestCase): 16 | """Codmodify unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test Codmodify 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.codmodify.Codmodify() # noqa: E501 30 | if include_optional : 31 | return Codmodify( 32 | orderNo = '0' 33 | ) 34 | else : 35 | return Codmodify( 36 | ) 37 | 38 | def testCodmodify(self): 39 | """Test Codmodify""" 40 | inst_req_only = self.make_instance(include_optional=False) 41 | inst_req_and_optional = self.make_instance(include_optional=True) 42 | 43 | 44 | if __name__ == '__main__': 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /python/test/test_gtcmodify.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.gtcmodify import Gtcmodify # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestGtcmodify(unittest.TestCase): 16 | """Gtcmodify unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test Gtcmodify 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.gtcmodify.Gtcmodify() # noqa: E501 30 | if include_optional : 31 | return Gtcmodify( 32 | gtcOrderNo = '0' 33 | ) 34 | else : 35 | return Gtcmodify( 36 | ) 37 | 38 | def testGtcmodify(self): 39 | """Test Gtcmodify""" 40 | inst_req_only = self.make_instance(include_optional=False) 41 | inst_req_and_optional = self.make_instance(include_optional=True) 42 | 43 | 44 | if __name__ == '__main__': 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /python/test/test_ctdmodify.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.ctdmodify import Ctdmodify # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestCtdmodify(unittest.TestCase): 16 | """Ctdmodify unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test Ctdmodify 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.ctdmodify.Ctdmodify() # noqa: E501 30 | if include_optional : 31 | return Ctdmodify( 32 | ConvertQuantity = 56 33 | ) 34 | else : 35 | return Ctdmodify( 36 | ) 37 | 38 | def testCtdmodify(self): 39 | """Test Ctdmodify""" 40 | inst_req_only = self.make_instance(include_optional=False) 41 | inst_req_and_optional = self.make_instance(include_optional=True) 42 | 43 | 44 | if __name__ == '__main__': 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /python/test/test_quote_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | 10 | import ks_api_client 11 | from ks_api_client.api.quote_api import QuoteApi # noqa: E501 12 | from ks_api_client.rest import ApiException 13 | 14 | 15 | class TestQuoteApi(unittest.TestCase): 16 | """QuoteApi unit test stubs""" 17 | 18 | def setUp(self): 19 | self.api = ks_api_client.api.quote_api.QuoteApi() # noqa: E501 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def test_get_instruments_details(self): 25 | """Test case for get_instruments_details 26 | 27 | Get full details # noqa: E501 28 | """ 29 | pass 30 | 31 | def test_get_ltp_quote(self): 32 | """Test case for get_ltp_quote 33 | 34 | Get LTP quote # noqa: E501 35 | """ 36 | pass 37 | 38 | def test_get_market_details_quote(self): 39 | """Test case for get_market_details_quote 40 | 41 | Get market details quote # noqa: E501 42 | """ 43 | pass 44 | 45 | def test_get_ohlc_quote(self): 46 | """Test case for get_ohlc_quote 47 | 48 | Get OHLC quote # noqa: E501 49 | """ 50 | pass 51 | 52 | 53 | if __name__ == '__main__': 54 | unittest.main() 55 | -------------------------------------------------------------------------------- /python/test/test_fault.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.fault import Fault # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestFault(unittest.TestCase): 16 | """Fault unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test Fault 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.fault.Fault() # noqa: E501 30 | if include_optional : 31 | return Fault( 32 | code = 56, 33 | message = '0', 34 | description = '0' 35 | ) 36 | else : 37 | return Fault( 38 | ) 39 | 40 | def testFault(self): 41 | """Test Fault""" 42 | inst_req_only = self.make_instance(include_optional=False) 43 | inst_req_and_optional = self.make_instance(include_optional=True) 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | -------------------------------------------------------------------------------- /python/test/test_positions_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import ks_api_client 10 | from ks_api_client.api.positions_api import PositionsApi # noqa: E501 11 | from ks_api_client.rest import ApiException 12 | 13 | class TestPositionsApi(unittest.TestCase): 14 | """PositionsApi unit test stubs""" 15 | 16 | def setUp(self): 17 | self.api = ks_api_client.api.positions_api.PositionsApi() # noqa: E501 18 | 19 | def tearDown(self): 20 | pass 21 | 22 | def test_positions(self): 23 | """Test case for positions 24 | 25 | Get's raw position from Trading Engine. # noqa: E501 26 | """ 27 | pass 28 | 29 | def test_positions_open(self): 30 | """Test case for positions_open 31 | 32 | Get's Open position. # noqa: E501 33 | """ 34 | pass 35 | 36 | def test_positions_stocks(self): 37 | """Test case for positions_stocks 38 | 39 | Get's Sell from Existing stocks. # noqa: E501 40 | """ 41 | pass 42 | 43 | def test_positions_today(self): 44 | """Test case for positions_today 45 | 46 | Get's Todays position. # noqa: E501 47 | """ 48 | pass 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /python/test/test_tsloplace.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.tsloplace import Tsloplace # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestTsloplace(unittest.TestCase): 16 | """Tsloplace unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test Tsloplace 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.tsloplace.Tsloplace() # noqa: E501 30 | if include_optional : 31 | return Tsloplace( 32 | spread = 1.337, 33 | trailingPrice = 1.337 34 | ) 35 | else : 36 | return Tsloplace( 37 | ) 38 | 39 | def testTsloplace(self): 40 | """Test Tsloplace""" 41 | inst_req_only = self.make_instance(include_optional=False) 42 | inst_req_and_optional = self.make_instance(include_optional=True) 43 | 44 | 45 | if __name__ == '__main__': 46 | unittest.main() 47 | -------------------------------------------------------------------------------- /python/test/test_margin_trading_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | 10 | import ks_api_client 11 | from ks_api_client.ks_api import KSTradeApi as TradingApi 12 | from ks_api_client.api.margin_trading_api import MarginTradingApi # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | from ks_api_client.settings import host, access_token, userid, \ 15 | consumer_key, app_id, password, access_code, ip 16 | 17 | class TestMarginTradingApi(unittest.TestCase): 18 | """MarginTradingApi unit test stubs""" 19 | 20 | def setUp(self): 21 | self.api = ks_api_client.api.margin_trading_api.MarginTradingApi() # noqa: E501 22 | 23 | def tearDown(self): 24 | pass 25 | 26 | def test_cancel_mtf_order(self): 27 | """Test case for cancel_mtf_order 28 | 29 | Cancel an order # noqa: E501 30 | """ 31 | pass 32 | 33 | def test_modify_mtf_order(self): 34 | """Test case for modify_mtf_order 35 | 36 | Modify an existing MTF order # noqa: E501 37 | """ 38 | pass 39 | 40 | def test_place_new_mtf_order(self): 41 | """Test case for place_new_mtf_order 42 | 43 | Place a New MTF order # noqa: E501 44 | """ 45 | pass 46 | 47 | 48 | if __name__ == '__main__': 49 | unittest.main() 50 | -------------------------------------------------------------------------------- /python/test/test_user_details.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.user_details import UserDetails # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestUserDetails(unittest.TestCase): 16 | """UserDetails unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test UserDetails 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.user_details.UserDetails() # noqa: E501 30 | if include_optional : 31 | return UserDetails( 32 | userid = '1y409', 33 | accessCode = '1111' 34 | ) 35 | else : 36 | return UserDetails( 37 | ) 38 | 39 | def testUserDetails(self): 40 | """Test UserDetails""" 41 | inst_req_only = self.make_instance(include_optional=False) 42 | inst_req_and_optional = self.make_instance(include_optional=True) 43 | 44 | 45 | if __name__ == '__main__': 46 | unittest.main() 47 | -------------------------------------------------------------------------------- /python/test/test_tslomodify.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.tslomodify import Tslomodify # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestTslomodify(unittest.TestCase): 16 | """Tslomodify unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test Tslomodify 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.tslomodify.Tslomodify() # noqa: E501 30 | if include_optional : 31 | return Tslomodify( 32 | orderIndicator = 56, 33 | spread = 1.337, 34 | trailingPrice = 1.337 35 | ) 36 | else : 37 | return Tslomodify( 38 | ) 39 | 40 | def testTslomodify(self): 41 | """Test Tslomodify""" 42 | inst_req_only = self.make_instance(include_optional=False) 43 | inst_req_and_optional = self.make_instance(include_optional=True) 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | -------------------------------------------------------------------------------- /python/.openapi-generator-ignore: -------------------------------------------------------------------------------- 1 | # OpenAPI Generator Ignore 2 | # Generated by openapi-generator https://github.com/openapitools/openapi-generator 3 | 4 | # Use this file to prevent files from being overwritten by the generator. 5 | # The patterns follow closely to .gitignore or .dockerignore. 6 | 7 | # As an example, the C# client generator defines ApiClient.cs. 8 | # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: 9 | #ApiClient.cs 10 | 11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 12 | #foo/*/qux 13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 14 | 15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 16 | #foo/**/qux 17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 18 | 19 | # You can also negate patterns with an exclamation (!). 20 | # For example, you can ignore all files in a docs folder with the file extension .md: 21 | #docs/*.md 22 | # Then explicitly reverse the ignore rule for a single file: 23 | #!docs/README.md 24 | 25 | README.md 26 | docs/MarginApi.md 27 | docs/MarginTradingApi.md 28 | docs/NormalOrderApi.md 29 | docs/OrderApi.md 30 | docs/PositionsApi.md 31 | docs/ReportsApi.md 32 | docs/SessionApi.md 33 | docs/SmartOrderRoutingApi.md 34 | docs/SuperMultipleOrderApi.md 35 | docs/QuoteApi.md -------------------------------------------------------------------------------- /python/test/test_user_credentials.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.user_credentials import UserCredentials # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestUserCredentials(unittest.TestCase): 16 | """UserCredentials unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test UserCredentials 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.user_credentials.UserCredentials() # noqa: E501 30 | if include_optional : 31 | return UserCredentials( 32 | userid = '1Y409', 33 | password = 'login@1' 34 | ) 35 | else : 36 | return UserCredentials( 37 | ) 38 | 39 | def testUserCredentials(self): 40 | """Test UserCredentials""" 41 | inst_req_only = self.make_instance(include_optional=False) 42 | inst_req_and_optional = self.make_instance(include_optional=True) 43 | 44 | 45 | if __name__ == '__main__': 46 | unittest.main() 47 | -------------------------------------------------------------------------------- /python/test/test_margin_det.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.margin_det import MarginDet # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestMarginDet(unittest.TestCase): 16 | """MarginDet unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test MarginDet 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.margin_det.MarginDet() # noqa: E501 30 | if include_optional : 31 | return MarginDet( 32 | instrumentToken = 56, 33 | normal = 1.337, 34 | supermultiple = 1.337, 35 | mtf = 1.337 36 | ) 37 | else : 38 | return MarginDet( 39 | ) 40 | 41 | def testMarginDet(self): 42 | """Test MarginDet""" 43 | inst_req_only = self.make_instance(include_optional=False) 44 | inst_req_and_optional = self.make_instance(include_optional=True) 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | -------------------------------------------------------------------------------- /python/test/test_order_info.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.order_info import OrderInfo # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestOrderInfo(unittest.TestCase): 16 | """OrderInfo unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test OrderInfo 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.order_info.OrderInfo() # noqa: E501 30 | if include_optional : 31 | return OrderInfo( 32 | instrumentToken = 56, 33 | quantity = 56, 34 | price = 1.337, 35 | amount = 56, 36 | triggerPrice = 1.337 37 | ) 38 | else : 39 | return OrderInfo( 40 | ) 41 | 42 | def testOrderInfo(self): 43 | """Test OrderInfo""" 44 | inst_req_only = self.make_instance(include_optional=False) 45 | inst_req_and_optional = self.make_instance(include_optional=True) 46 | 47 | 48 | if __name__ == '__main__': 49 | unittest.main() 50 | -------------------------------------------------------------------------------- /python/test/test_bracketplace.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.bracketplace import Bracketplace # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestBracketplace(unittest.TestCase): 16 | """Bracketplace unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test Bracketplace 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.bracketplace.Bracketplace() # noqa: E501 30 | if include_optional : 31 | return Bracketplace( 32 | Spread = 1.337, 33 | trailingPrice = 1.337, 34 | bookProfit = 1.337, 35 | bookDisclosedQty = 56 36 | ) 37 | else : 38 | return Bracketplace( 39 | ) 40 | 41 | def testBracketplace(self): 42 | """Test Bracketplace""" 43 | inst_req_only = self.make_instance(include_optional=False) 44 | inst_req_and_optional = self.make_instance(include_optional=True) 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | -------------------------------------------------------------------------------- /python/test/test_bracketmodify.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.bracketmodify import Bracketmodify # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestBracketmodify(unittest.TestCase): 16 | """Bracketmodify unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test Bracketmodify 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.bracketmodify.Bracketmodify() # noqa: E501 30 | if include_optional : 31 | return Bracketmodify( 32 | orderIndicator = 56, 33 | Spread = 1.337, 34 | trailingPrice = 1.337, 35 | bookProfit = 1.337, 36 | bookDisclosedQty = 56 37 | ) 38 | else : 39 | return Bracketmodify( 40 | ) 41 | 42 | def testBracketmodify(self): 43 | """Test Bracketmodify""" 44 | inst_req_only = self.make_instance(include_optional=False) 45 | inst_req_and_optional = self.make_instance(include_optional=True) 46 | 47 | 48 | if __name__ == '__main__': 49 | unittest.main() 50 | -------------------------------------------------------------------------------- /python/test/test_session_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | 10 | import ks_api_client 11 | from ks_api_client.api.session_api import SessionApi # noqa: E501 12 | from ks_api_client.rest import ApiException 13 | 14 | 15 | class TestSessionApi(unittest.TestCase): 16 | """SessionApi unit test stubs""" 17 | 18 | def setUp(self): 19 | self.api = ks_api_client.api.session_api.SessionApi() # noqa: E501 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def test_generate_session2_fa(self): 25 | """Test case for generate_session2_fa 26 | 27 | Generate final Session Token # noqa: E501 28 | """ 29 | pass 30 | 31 | def test_generate_session2_fa_ott(self): 32 | """Test case for generate_session2_fa_ott 33 | 34 | Generate Final Session Token using One Time Token for Trade API subcribed clients # noqa: E501 35 | """ 36 | pass 37 | 38 | def test_login_with_user_id(self): 39 | """Test case for login_with_user_id 40 | 41 | Login using Userid # noqa: E501 42 | """ 43 | pass 44 | 45 | def test_session_init(self): 46 | """Test case for session_init 47 | 48 | Initialise Session # noqa: E501 49 | """ 50 | pass 51 | 52 | def test_session_logout(self): 53 | """Test case for session_logout 54 | 55 | Invalidate Session Token # noqa: E501 56 | """ 57 | pass 58 | 59 | 60 | if __name__ == '__main__': 61 | unittest.main() 62 | -------------------------------------------------------------------------------- /python/test/test_existing_sor_order.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.existing_sor_order import ExistingSOROrder # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestExistingSOROrder(unittest.TestCase): 16 | """ExistingSOROrder unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test ExistingSOROrder 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | # model = ks_api_client.models.existing_sor_order.ExistingSOROrder() # noqa: E501 30 | if include_optional : 31 | return ExistingSOROrder( 32 | orderId = '0', 33 | quantity = 56, 34 | price = 1.337, 35 | disclosedQuantity = 56, 36 | triggerPrice = 1.337, 37 | validity = 'GFD' 38 | ) 39 | else : 40 | return ExistingSOROrder( 41 | orderId = '0', 42 | ) 43 | 44 | def testExistingSOROrder(self): 45 | """Test ExistingSOROrder""" 46 | inst_req_only = self.make_instance(include_optional=False) 47 | inst_req_and_optional = self.make_instance(include_optional=True) 48 | 49 | 50 | if __name__ == '__main__': 51 | unittest.main() 52 | -------------------------------------------------------------------------------- /python/test/test_existing_sm_order.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.existing_sm_order import ExistingSMOrder # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestExistingSMOrder(unittest.TestCase): 16 | """ExistingSMOrder unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test ExistingSMOrder 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | # model = ks_api_client.models.existing_sm_order.ExistingSMOrder() # noqa: E501 30 | if include_optional : 31 | return ExistingSMOrder( 32 | orderId = '0', 33 | quantity = 56, 34 | price = 1.337, 35 | disclosedQuantity = 56, 36 | triggerPrice = 1.337, 37 | validity = 'GFD' 38 | ) 39 | else : 40 | return ExistingSMOrder( 41 | orderId = '0', 42 | validity = 'GFD', 43 | ) 44 | 45 | def testExistingSMOrder(self): 46 | """Test ExistingSMOrder""" 47 | inst_req_only = self.make_instance(include_optional=False) 48 | inst_req_and_optional = self.make_instance(include_optional=True) 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /python/test/test_new_sm_order.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.new_sm_order import NewSMOrder # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestNewSMOrder(unittest.TestCase): 16 | """NewSMOrder unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test NewSMOrder 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.new_sm_order.NewSMOrder() # noqa: E501 30 | if include_optional : 31 | return NewSMOrder( 32 | instrumentToken = 56, 33 | transactionType = 'BUY', 34 | quantity = 56, 35 | price = 1.337, 36 | validity = 'GFD', 37 | variety = 'REGULAR', 38 | disclosedQuantity = 56, 39 | triggerPrice = 1.337, 40 | tag = '0' 41 | ) 42 | else : 43 | return NewSMOrder( 44 | ) 45 | 46 | def testNewSMOrder(self): 47 | """Test NewSMOrder""" 48 | inst_req_only = self.make_instance(include_optional=False) 49 | inst_req_and_optional = self.make_instance(include_optional=True) 50 | 51 | 52 | if __name__ == '__main__': 53 | unittest.main() 54 | -------------------------------------------------------------------------------- /python/test/test_new_mtf_order.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.new_mtf_order import NewMTFOrder # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestNewMTFOrder(unittest.TestCase): 16 | """NewMTFOrder unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test NewMTFOrder 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.new_mtf_order.NewMTFOrder() # noqa: E501 30 | if include_optional : 31 | return NewMTFOrder( 32 | instrumentToken = 56, 33 | transactionType = 'BUY', 34 | quantity = 56, 35 | price = 1.337, 36 | validity = 'GFD', 37 | variety = 'REGULAR', 38 | disclosedQuantity = 56, 39 | triggerPrice = 1.337, 40 | tag = '0' 41 | ) 42 | else : 43 | return NewMTFOrder( 44 | ) 45 | 46 | def testNewMTFOrder(self): 47 | """Test NewMTFOrder""" 48 | inst_req_only = self.make_instance(include_optional=False) 49 | inst_req_and_optional = self.make_instance(include_optional=True) 50 | 51 | 52 | if __name__ == '__main__': 53 | unittest.main() 54 | -------------------------------------------------------------------------------- /python/test/test_new_sor_order.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.new_sor_order import NewSOROrder # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestNewSOROrder(unittest.TestCase): 16 | """NewSOROrder unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test NewSOROrder 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.new_sor_order.NewSOROrder() # noqa: E501 30 | if include_optional : 31 | return NewSOROrder( 32 | instrumentToken = 56, 33 | transactionType = 'BUY', 34 | quantity = 56, 35 | price = 1.337, 36 | validity = 'GFD', 37 | variety = 'REGULAR', 38 | disclosedQuantity = 56, 39 | triggerPrice = 1.337, 40 | tag = '0' 41 | ) 42 | else : 43 | return NewSOROrder( 44 | ) 45 | 46 | def testNewSOROrder(self): 47 | """Test NewSOROrder""" 48 | inst_req_only = self.make_instance(include_optional=False) 49 | inst_req_and_optional = self.make_instance(include_optional=True) 50 | 51 | 52 | if __name__ == '__main__': 53 | unittest.main() 54 | -------------------------------------------------------------------------------- /python/test/test_existing_mtf_order.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.existing_mtf_order import ExistingMTFOrder # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestExistingMTFOrder(unittest.TestCase): 16 | """ExistingMTFOrder unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test ExistingMTFOrder 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | # model = ks_api_client.models.existing_mtf_order.ExistingMTFOrder() # noqa: E501 30 | if include_optional : 31 | return ExistingMTFOrder( 32 | orderId = '0', 33 | quantity = 56, 34 | price = 1.337, 35 | disclosedQuantity = 56, 36 | triggerPrice = 1.337, 37 | validity = 'GFD' 38 | ) 39 | else : 40 | return ExistingMTFOrder( 41 | orderId = '0', 42 | validity = 'GFD', 43 | ) 44 | 45 | def testExistingMTFOrder(self): 46 | """Test ExistingMTFOrder""" 47 | inst_req_only = self.make_instance(include_optional=False) 48 | inst_req_and_optional = self.make_instance(include_optional=True) 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /python/test/test_new_normal_order.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.new_normal_order import NewNormalOrder # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestNewNormalOrder(unittest.TestCase): 16 | """NewNormalOrder unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test NewNormalOrder 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.new_normal_order.NewNormalOrder() # noqa: E501 30 | if include_optional : 31 | return NewNormalOrder( 32 | instrumentToken = 56, 33 | transactionType = 'BUY', 34 | quantity = 56, 35 | price = 1.337, 36 | validity = 'GFD', 37 | variety = 'REGULAR', 38 | disclosedQuantity = 56, 39 | triggerPrice = 1.337, 40 | tag = '0' 41 | ) 42 | else : 43 | return NewNormalOrder( 44 | ) 45 | 46 | def testNewNormalOrder(self): 47 | """Test NewNormalOrder""" 48 | inst_req_only = self.make_instance(include_optional=False) 49 | inst_req_and_optional = self.make_instance(include_optional=True) 50 | 51 | 52 | if __name__ == '__main__': 53 | unittest.main() 54 | -------------------------------------------------------------------------------- /python/test/test_existing_normal_order.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.existing_normal_order import ExistingNormalOrder # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestExistingNormalOrder(unittest.TestCase): 16 | """ExistingNormalOrder unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test ExistingNormalOrder 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | # model = ks_api_client.models.existing_normal_order.ExistingNormalOrder() # noqa: E501 30 | if include_optional : 31 | return ExistingNormalOrder( 32 | orderId = '0', 33 | quantity = 56, 34 | price = 1.337, 35 | disclosedQuantity = 56, 36 | triggerPrice = 1.337, 37 | validity = 'GFD' 38 | ) 39 | else : 40 | return ExistingNormalOrder( 41 | orderId = '0', 42 | validity = 'GFD', 43 | ) 44 | 45 | def testExistingNormalOrder(self): 46 | """Test ExistingNormalOrder""" 47 | inst_req_only = self.make_instance(include_optional=False) 48 | inst_req_and_optional = self.make_instance(include_optional=True) 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /python/docs/NewOrder.md: -------------------------------------------------------------------------------- 1 | # NewOrder 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **instrumentToken** | **int** | Instrument token of the scrip to be traded | [optional] 7 | **transactionType** | **str** | Transaction Type - BUY or SELL | [optional] 8 | **quantity** | **int** | Order quantity - specified in same unit as quoted in market depth | [optional] 9 | **price** | **float** | Order Price, non zero positive for limit order and zero for market order | [optional] 10 | **product** | **str** | Product type for this order - NORMAL, SUPERMULTIPLE, SUPERMULTIPLEOPTION, MTF | [optional] 11 | **validity** | **str** | Validity of the order - GFD, IOC etc | [optional] 12 | **variety** | **str** | Variety of the order - REGULAR, AMO, SQUAREOFF - for Super Multiple Orders etc | [optional] 13 | **disclosedQuantity** | **int** | Quantity to be disclosed in order | [optional] 14 | **triggerPrice** | **float** | Trigger price, required for stoploss or supermultiple order | [optional] 15 | **tslo** | [**Tsloplace**](Tsloplace.md) | | [optional] 16 | **bracket** | [**Bracketplace**](Bracketplace.md) | | [optional] 17 | **tslonew** | [**Tsloplace**](Tsloplace.md) | | [optional] 18 | **bracketnew** | [**Bracketplace**](Bracketplace.md) | | [optional] 19 | **gtc** | [**Gtcplace**](Gtcplace.md) | | [optional] 20 | **ctd** | [**Ctdplace**](Ctdplace.md) | | [optional] 21 | **cod** | [**Codplace**](Codplace.md) | | [optional] 22 | **tag** | **str** | Tag for this order | [optional] 23 | **smartOrderRouting** | **str** | smart Order Routing for this order | [optional] 24 | 25 | [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 26 | 27 | 28 | -------------------------------------------------------------------------------- /python/docs/HistoricalApi.md: -------------------------------------------------------------------------------- 1 | # ks_api_client.HistoricalApi 2 | 3 | All URIs are relative to "host" parameter 4 | 5 | Method | Description 6 | ------------- | ------------- 7 | [**history**](HistoricalApi.md#history) | Get historical data 8 | 9 | 10 | # **get_resource** 11 | > object history(resource, input) 12 | 13 | Get historical data based on given resource 14 | 15 | Get Historical data 16 | 17 | ### Example 18 | 19 | ```python 20 | from ks_api_client import ks_api 21 | 22 | client = ks_api.KSTradeApi(access_token = "", userid = "", consumer_key = "",ip = "127.0.0.1", app_id = "", \ 23 | host = "https://tradeapi.kotaksecurities.com/apim", consumer_secret = "") 24 | 25 | #First initialize session and generate session token 26 | 27 | try: 28 | # Get historical prices 29 | client.history("historicalprices",{"exchange":"bse","cocode":"476","fromdate":"01-jan-2014","todate":"08-oct-2015"}) 30 | except Exception as e: 31 | print("Exception when calling Historical API->details: %s\n" % e) 32 | ``` 33 | 34 | ### Parameters 35 | 36 | Name | Type | Description | Notes 37 | ------------- | ------------- | ------------- | ------------- 38 | **resource** | **str**| | Type of resource historicalprices,historicalprices-unadjusted,NSEFNO_HistoricalContinuousChart,LiveorEODHistorical 39 | **input** | **str**| | Json as per resource selected 40 | 41 | ### Return type 42 | 43 | **object** 44 | 45 | 46 | ### HTTP request headers 47 | 48 | - **Accept**: application/json 49 | 50 | ### HTTP response details 51 | | Status code | Description | Response headers | 52 | |-------------|-------------|------------------| 53 | **200** | Historical Details | - | 54 | 55 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 56 | 57 | -------------------------------------------------------------------------------- /python/test/test_margin_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | 10 | import ks_api_client 11 | from ks_api_client.api.margin_api import MarginApi # noqa: E501 12 | from ks_api_client.ks_api import KSTradeApi as TradingApi 13 | from ks_api_client.rest import ApiException 14 | from ks_api_client.settings import host, access_token, userid, \ 15 | consumer_key, app_id, password, access_code, ip 16 | 17 | class TestMarginApi(unittest.TestCase): 18 | """MarginApi unit test stubs""" 19 | ks_trade_api = TradingApi(access_token, userid, consumer_key, ip, app_id, host) 20 | ks_trade_api.login(password = password) 21 | ks_trade_api.session_2fa(access_code = access_code) 22 | 23 | def setUp(self): 24 | self.api = ks_api_client.api.margin_api.MarginApi() # noqa: E501 25 | self.ks_trade_api.login(password) 26 | self.ks_trade_api.session_2fa(access_code) 27 | 28 | def tearDown(self): 29 | pass 30 | 31 | def test_get_margins(self): 32 | """Test case for get_margins 33 | 34 | Complete Margin # noqa: E501 35 | """ 36 | margin = self.ks_trade_api.margin() 37 | print("Margin : ",margin) 38 | 39 | def test_margin_required(self): 40 | """Test case for margin_required 41 | 42 | Get Margin Required for an order by amount or quantity. # noqa: E501 43 | """ 44 | order_info = [ 45 | {"instrument_token": 727, "quantity": 1, "price": 1300, "amount": 0, "trigger_price": 1190}, 46 | {"instrument_token": 1374, "quantity": 1, "price": 1200, "amount": 0, "trigger_price": 1150} 47 | ] 48 | margin_required = self.ks_trade_api.margin_required(transaction_type = "BUY",order_info = order_info) 49 | print("Margin required: ",margin_required) 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /python/ks_api_client/models/__init__.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # flake8: noqa 4 | 5 | from __future__ import absolute_import 6 | 7 | # import models into model package 8 | from ks_api_client.models.bracketmodify import Bracketmodify 9 | from ks_api_client.models.bracketplace import Bracketplace 10 | from ks_api_client.models.codmodify import Codmodify 11 | from ks_api_client.models.codplace import Codplace 12 | from ks_api_client.models.ctdmodify import Ctdmodify 13 | from ks_api_client.models.ctdplace import Ctdplace 14 | from ks_api_client.models.existing_mis_order import ExistingMISOrder 15 | from ks_api_client.models.existing_mtf_order import ExistingMTFOrder 16 | from ks_api_client.models.existing_normal_order import ExistingNormalOrder 17 | from ks_api_client.models.existing_order import ExistingOrder 18 | from ks_api_client.models.existing_sm_order import ExistingSMOrder 19 | from ks_api_client.models.existing_sor_order import ExistingSOROrder 20 | from ks_api_client.models.fault import Fault 21 | from ks_api_client.models.gtcmodify import Gtcmodify 22 | from ks_api_client.models.gtcplace import Gtcplace 23 | from ks_api_client.models.inline_object import InlineObject 24 | from ks_api_client.models.margin_det import MarginDet 25 | from ks_api_client.models.new_mis_order import NewMISOrder 26 | from ks_api_client.models.new_mtf_order import NewMTFOrder 27 | from ks_api_client.models.new_normal_order import NewNormalOrder 28 | from ks_api_client.models.new_order import NewOrder 29 | from ks_api_client.models.new_sm_order import NewSMOrder 30 | from ks_api_client.models.new_sor_order import NewSOROrder 31 | from ks_api_client.models.order_info import OrderInfo 32 | from ks_api_client.models.orders import Orders 33 | from ks_api_client.models.req_margin import ReqMargin 34 | from ks_api_client.models.tslomodify import Tslomodify 35 | from ks_api_client.models.tsloplace import Tsloplace 36 | from ks_api_client.models.user_credentials import UserCredentials 37 | from ks_api_client.models.user_details import UserDetails 38 | -------------------------------------------------------------------------------- /python/test/test_orders.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import datetime 10 | 11 | import ks_api_client 12 | from ks_api_client.models.orders import Orders # noqa: E501 13 | from ks_api_client.rest import ApiException 14 | 15 | class TestOrders(unittest.TestCase): 16 | """Orders unit test stubs""" 17 | 18 | def setUp(self): 19 | pass 20 | 21 | def tearDown(self): 22 | pass 23 | 24 | def make_instance(self, include_optional): 25 | """Test Orders 26 | include_option is a boolean, when False only required 27 | params are included, when True both required and 28 | optional params are included """ 29 | model = ks_api_client.models.orders.Orders() # noqa: E501 30 | if include_optional : 31 | return Orders( 32 | orderId = 1.337, 33 | variety = 'REGULAR', 34 | instrumentName = '0', 35 | instrumentToken = '0', 36 | exchange = 'NSE', 37 | orderQuantity = 56, 38 | pendingQuantity = 56, 39 | cancelledQuantity = 56, 40 | filledQuantity = 56, 41 | disclosedQuantity = 56, 42 | triggerPrice = 56, 43 | price = 1.337, 44 | product = 'NORMAL', 45 | transactionType = 'BUY', 46 | orderTimestamp = '0', 47 | validity = 'GFD', 48 | statusMessage = '0', 49 | tag = '0', 50 | status = 'placed', 51 | statusInfo = '0', 52 | isFNO = '0' 53 | ) 54 | else : 55 | return Orders( 56 | ) 57 | 58 | def testOrders(self): 59 | """Test Orders""" 60 | inst_req_only = self.make_instance(include_optional=False) 61 | inst_req_and_optional = self.make_instance(include_optional=True) 62 | 63 | 64 | if __name__ == '__main__': 65 | unittest.main() 66 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /python/docs/QuoteApi.md: -------------------------------------------------------------------------------- 1 | # ks_api_client.QuoteApi 2 | 3 | All URIs are relative to "host" parameter* 4 | 5 | Method | Description 6 | ------------- | ------------- 7 | [**quote**](QuoteApi.md#quote_details) | Get's Quotes. 8 | 9 | 10 | # **quote_details** 11 | > object quote(instrument_token, quote_type) 12 | 13 | Get Quote Details 14 | 15 | Returns full quote details in case quote_type is not provided 16 | else returns quote details of provided quote_type. 17 | 18 | ### Example 19 | 20 | 21 | ```python 22 | from ks_api_client import ks_api 23 | 24 | client = ks_api.KSTradeApi(access_token = "", userid = "", consumer_key = "",ip = "127.0.0.1", app_id = "", \ 25 | host = "https://tradeapi.kotaksecurities.com/apim", consumer_secret = "") 26 | 27 | #First initialize session and generate session token 28 | 29 | try: 30 | # Get full quote details 31 | client.quote(instrument_token = 110) 32 | 33 | # Get quote details by quote_type 34 | client.quote(instrument_token = 110, quote_type = "LTP") 35 | except Exception as e: 36 | print("Exception when calling QuoteApi->quote_details: %s\n" % e) 37 | ``` 38 | 39 | ### Parameters 40 | 41 | Name | Type | Description | Notes 42 | ------------- | ------------- | ------------- | ------------- 43 | **instrument_token** | **str**| | 44 | **quote_type** | **str** | Type of Quote details - LTP, DEPTH, OHLC | [optional] 45 | 46 | ### Return type 47 | 48 | object 49 | 50 | ### Sample response 51 | 52 | ```python 53 | { 54 | "success": [ 55 | { 56 | "wtoken": "110", 57 | "ltp": "40.4500", 58 | "lv_net_chg": "0.011000000000000001", 59 | "lv_net_chg_perc": "0.027954", 60 | "open_price": "40.0000", 61 | "closing_price": "39.3500", 62 | "high_price": "40.4500", 63 | "low_price": "39.8000", 64 | "average_trade_price": "40.3900", 65 | "last_trade_qty": "1472", 66 | "BD_last_traded_time": "25/08/2021 11:41:20", 67 | "OI": "0", 68 | "BD_TTQ": "1658", 69 | "market_exchange": "BSE", 70 | "stk_name": "CORALFINAC", 71 | "display_segment": "EQ", 72 | "display_fno_eq": "" 73 | } 74 | ] 75 | } 76 | ``` 77 | 78 | ### HTTP request headers 79 | 80 | - **Accept**: application/json 81 | 82 | ### HTTP response details 83 | | Status code | Description | Response headers | 84 | |-------------|-------------|------------------| 85 | **200** | Quote fetched successfully | - | 86 | **400** | Invalid or missing input parameters | - | 87 | **403** | Invalid session, please re-login to continue | - | 88 | **429** | Too many requests to the API | - | 89 | **500** | Unexpected error | - | 90 | **502** | Not able to communicate with OMS | - | 91 | **503** | Trade API service is unavailable | - | 92 | **504** | Gateway timeout, trade API is unreachable | - | 93 | 94 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 95 | 96 | -------------------------------------------------------------------------------- /python/ks_api_client/__init__.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # flake8: noqa 4 | 5 | from __future__ import absolute_import 6 | 7 | __version__ = "1.0.0" 8 | 9 | # import apis into sdk package 10 | from ks_api_client.api.historical_api import HistoricalApi 11 | from ks_api_client.api.mis_order_api import MISOrderApi 12 | from ks_api_client.api.margin_api import MarginApi 13 | from ks_api_client.api.margin_trading_api import MarginTradingApi 14 | from ks_api_client.api.normal_order_api import NormalOrderApi 15 | from ks_api_client.api.order_api import OrderApi 16 | from ks_api_client.api.positions_api import PositionsApi 17 | from ks_api_client.api.quote_api import QuoteApi 18 | from ks_api_client.api.reports_api import ReportsApi 19 | from ks_api_client.api.session_api import SessionApi 20 | from ks_api_client.api.smart_order_routing_api import SmartOrderRoutingApi 21 | from ks_api_client.api.super_multiple_order_api import SuperMultipleOrderApi 22 | from ks_api_client.api.token_api import TokenApi 23 | 24 | # import ApiClient 25 | from ks_api_client.api_client import ApiClient 26 | from ks_api_client.configuration import Configuration 27 | from ks_api_client.exceptions import OpenApiException 28 | from ks_api_client.exceptions import ApiTypeError 29 | from ks_api_client.exceptions import ApiValueError 30 | from ks_api_client.exceptions import ApiKeyError 31 | from ks_api_client.exceptions import ApiAttributeError 32 | from ks_api_client.exceptions import ApiException 33 | # import models into sdk package 34 | from ks_api_client.models.bracketmodify import Bracketmodify 35 | from ks_api_client.models.bracketplace import Bracketplace 36 | from ks_api_client.models.codmodify import Codmodify 37 | from ks_api_client.models.codplace import Codplace 38 | from ks_api_client.models.ctdmodify import Ctdmodify 39 | from ks_api_client.models.ctdplace import Ctdplace 40 | from ks_api_client.models.existing_mis_order import ExistingMISOrder 41 | from ks_api_client.models.existing_mtf_order import ExistingMTFOrder 42 | from ks_api_client.models.existing_normal_order import ExistingNormalOrder 43 | from ks_api_client.models.existing_order import ExistingOrder 44 | from ks_api_client.models.existing_sm_order import ExistingSMOrder 45 | from ks_api_client.models.existing_sor_order import ExistingSOROrder 46 | from ks_api_client.models.fault import Fault 47 | from ks_api_client.models.gtcmodify import Gtcmodify 48 | from ks_api_client.models.gtcplace import Gtcplace 49 | from ks_api_client.models.new_mis_order import NewMISOrder 50 | from ks_api_client.models.new_mtf_order import NewMTFOrder 51 | from ks_api_client.models.new_normal_order import NewNormalOrder 52 | from ks_api_client.models.new_order import NewOrder 53 | from ks_api_client.models.new_sm_order import NewSMOrder 54 | from ks_api_client.models.new_sor_order import NewSOROrder 55 | from ks_api_client.models.order_info import OrderInfo 56 | from ks_api_client.models.req_margin import ReqMargin 57 | from ks_api_client.models.tslomodify import Tslomodify 58 | from ks_api_client.models.tsloplace import Tsloplace 59 | from ks_api_client.models.user_credentials import UserCredentials 60 | from ks_api_client.models.user_details import UserDetails 61 | 62 | -------------------------------------------------------------------------------- /python/docs/StreamingApi.md: -------------------------------------------------------------------------------- 1 | # ks_api_client.StreamingApi 2 | 3 | All URIs are relative to "host" parameter 4 | 5 | Method | Description 6 | ------------- | ------------- 7 | [**subscribe**](StreamingApi.md#subscribe) | Get streaming service subscription for specified instruments inputs 8 | [**unsubscribe**](StreamingApi.md#unsubscribe) | Request to unsubscribe from streaming service 9 | 10 | # **subscribe** 11 | > object subscribe(input_tokens, callback, broadcast_host): 12 | 13 | Get streaming service subscription for specified instruments inputs. 14 | 15 | ### Example 16 | 17 | 18 | ```python 19 | from ks_api_client import ks_api 20 | 21 | client = ks_api.KSTradeApi(access_token = "", userid = "", consumer_key = "",ip = "127.0.0.1", app_id = "", \ 22 | host = "https://tradeapi.kotaksecurities.com/apim", consumer_secret = "") 23 | 24 | try: 25 | def callback_method(message): 26 | print(message) 27 | print("Your logic/computation will come here.") 28 | # subscribe to the streamingAPI 29 | client.subscribe(input_tokens="745,754", callback=callback_method, broadcast_host="https://wstreamer.kotaksecurities.com/feed") 30 | except Exception as e: 31 | print("Exception when calling StreamingApi->subscribe: %s\n" % e) 32 | ``` 33 | 34 | ### Parameters 35 | 36 | Name | Type | Description | Notes 37 | ------------- | ------------- | ------------- | ------------- 38 | **input_tokens** | **str** | Instrument tokens (comma seperated with no spaces). | Example: "475,745" 39 | **callback** | **obj** | Method object | method of function should have one mandatory parameter to accept message. 40 | **broadcast_host** | **str** | String broadcast host URL | URL for price feed: "https://wstreamer.kotaksecurities.com/feed" (default), and for order status updates: "https://wstreamer.kotaksecurities.com/feed/orders" 41 | 42 | ### Return type 43 | 44 | **object** 45 | 46 | ### Response Structure 47 | 48 | Index | Description 49 | ------------- | ------------- 50 | 0| - 51 | 1| - 52 | 2| Best buy price 53 | 3| Best buy quantity 54 | 4| Best sell price 55 | 5| Best sell quantity 56 | 6| Last trade price 57 | 7| High price 58 | 8| Low price 59 | 9| Average trade price 60 | 10| Closing price 61 | 11| Open price 62 | 12| Net change percentage 63 | 13| Total sell quantity 64 | 14| Total buy quantity 65 | 15| Total trade quantity 66 | 16| Open Interest 67 | 17| Total trade value 68 | 18| Last trade quantity 69 | 19| Last trade time 70 | 20| Net change 71 | 21| Upper circuit limit 72 | 22| Lower circuit limit 73 | 74 | 75 | # **unsubscribe** 76 | > object unsubscribe() 77 | 78 | Request to unsubscribe from streaming service. 79 | 80 | ### Example 81 | 82 | 83 | ```python 84 | from ks_api_client import ks_api 85 | 86 | client = ks_api.KSTradeApi(access_token = "", userid = "", consumer_key = "",ip = "127.0.0.1", app_id = "", \ 87 | host = "https://tradeapi.kotaksecurities.com/apim", consumer_secret = "") 88 | 89 | try: 90 | # unsubscribe to the streamingAPI 91 | client.unsubscribe() 92 | except Exception as e: 93 | print("Exception when calling StreamingApi->unsubscribe: %s\n" % e) 94 | ``` 95 | 96 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 97 | -------------------------------------------------------------------------------- /python/ks_api_client/models/codmodify.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class Codmodify(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'orderNo': 'str' 24 | } 25 | 26 | attribute_map = { 27 | 'orderNo': 'orderNo' 28 | } 29 | 30 | def __init__(self, orderNo=None, local_vars_configuration=None): # noqa: E501 31 | """Codmodify - a model defined in OpenAPI""" # noqa: E501 32 | if local_vars_configuration is None: 33 | local_vars_configuration = Configuration() 34 | self.local_vars_configuration = local_vars_configuration 35 | 36 | self._orderNo = None 37 | self.discriminator = None 38 | 39 | if orderNo is not None: 40 | self.orderNo = orderNo 41 | 42 | @property 43 | def orderNo(self): 44 | """Gets the orderNo of this Codmodify. # noqa: E501 45 | 46 | Order Number to modify # noqa: E501 47 | 48 | :return: The orderNo of this Codmodify. # noqa: E501 49 | :rtype: str 50 | """ 51 | return self._orderNo 52 | 53 | @orderNo.setter 54 | def orderNo(self, orderNo): 55 | """Sets the orderNo of this Codmodify. 56 | 57 | Order Number to modify # noqa: E501 58 | 59 | :param orderNo: The orderNo of this Codmodify. # noqa: E501 60 | :type orderNo: str 61 | """ 62 | 63 | self._orderNo = orderNo 64 | 65 | def to_dict(self): 66 | """Returns the model properties as a dict""" 67 | result = {} 68 | 69 | for attr, _ in six.iteritems(self.openapi_types): 70 | value = getattr(self, attr) 71 | if isinstance(value, list): 72 | result[attr] = list(map( 73 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 74 | value 75 | )) 76 | elif hasattr(value, "to_dict"): 77 | result[attr] = value.to_dict() 78 | elif isinstance(value, dict): 79 | result[attr] = dict(map( 80 | lambda item: (item[0], item[1].to_dict()) 81 | if hasattr(item[1], "to_dict") else item, 82 | value.items() 83 | )) 84 | else: 85 | result[attr] = value 86 | 87 | return result 88 | 89 | def to_str(self): 90 | """Returns the string representation of the model""" 91 | return pprint.pformat(self.to_dict()) 92 | 93 | def __repr__(self): 94 | """For `print` and `pprint`""" 95 | return self.to_str() 96 | 97 | def __eq__(self, other): 98 | """Returns true if both objects are equal""" 99 | if not isinstance(other, Codmodify): 100 | return False 101 | 102 | return self.to_dict() == other.to_dict() 103 | 104 | def __ne__(self, other): 105 | """Returns true if both objects are not equal""" 106 | if not isinstance(other, Codmodify): 107 | return True 108 | 109 | return self.to_dict() != other.to_dict() 110 | -------------------------------------------------------------------------------- /python/ks_api_client/models/inline_object.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class InlineObject(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'userid': 'str' 24 | } 25 | 26 | attribute_map = { 27 | 'userid': 'userid' 28 | } 29 | 30 | def __init__(self, userid=None, local_vars_configuration=None): # noqa: E501 31 | """InlineObject - a model defined in OpenAPI""" # noqa: E501 32 | if local_vars_configuration is None: 33 | local_vars_configuration = Configuration() 34 | self.local_vars_configuration = local_vars_configuration 35 | 36 | self._userid = None 37 | self.discriminator = None 38 | 39 | if userid is not None: 40 | self.userid = userid 41 | 42 | @property 43 | def userid(self): 44 | """Gets the userid of this InlineObject. # noqa: E501 45 | 46 | Userid for which access code validation # noqa: E501 47 | 48 | :return: The userid of this InlineObject. # noqa: E501 49 | :rtype: str 50 | """ 51 | return self._userid 52 | 53 | @userid.setter 54 | def userid(self, userid): 55 | """Sets the userid of this InlineObject. 56 | 57 | Userid for which access code validation # noqa: E501 58 | 59 | :param userid: The userid of this InlineObject. # noqa: E501 60 | :type userid: str 61 | """ 62 | 63 | self._userid = userid 64 | 65 | def to_dict(self): 66 | """Returns the model properties as a dict""" 67 | result = {} 68 | 69 | for attr, _ in six.iteritems(self.openapi_types): 70 | value = getattr(self, attr) 71 | if isinstance(value, list): 72 | result[attr] = list(map( 73 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 74 | value 75 | )) 76 | elif hasattr(value, "to_dict"): 77 | result[attr] = value.to_dict() 78 | elif isinstance(value, dict): 79 | result[attr] = dict(map( 80 | lambda item: (item[0], item[1].to_dict()) 81 | if hasattr(item[1], "to_dict") else item, 82 | value.items() 83 | )) 84 | else: 85 | result[attr] = value 86 | 87 | return result 88 | 89 | def to_str(self): 90 | """Returns the string representation of the model""" 91 | return pprint.pformat(self.to_dict()) 92 | 93 | def __repr__(self): 94 | """For `print` and `pprint`""" 95 | return self.to_str() 96 | 97 | def __eq__(self, other): 98 | """Returns true if both objects are equal""" 99 | if not isinstance(other, InlineObject): 100 | return False 101 | 102 | return self.to_dict() == other.to_dict() 103 | 104 | def __ne__(self, other): 105 | """Returns true if both objects are not equal""" 106 | if not isinstance(other, InlineObject): 107 | return True 108 | 109 | return self.to_dict() != other.to_dict() 110 | -------------------------------------------------------------------------------- /python/ks_api_client/models/gtcmodify.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class Gtcmodify(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'gtcOrderNo': 'str' 24 | } 25 | 26 | attribute_map = { 27 | 'gtcOrderNo': 'gtcOrderNo' 28 | } 29 | 30 | def __init__(self, gtcOrderNo=None, local_vars_configuration=None): # noqa: E501 31 | """Gtcmodify - a model defined in OpenAPI""" # noqa: E501 32 | if local_vars_configuration is None: 33 | local_vars_configuration = Configuration() 34 | self.local_vars_configuration = local_vars_configuration 35 | 36 | self._gtcOrderNo = None 37 | self.discriminator = None 38 | 39 | if gtcOrderNo is not None: 40 | self.gtcOrderNo = gtcOrderNo 41 | 42 | @property 43 | def gtcOrderNo(self): 44 | """Gets the gtcOrderNo of this Gtcmodify. # noqa: E501 45 | 46 | Order Number to modify # noqa: E501 47 | 48 | :return: The gtcOrderNo of this Gtcmodify. # noqa: E501 49 | :rtype: str 50 | """ 51 | return self._gtcOrderNo 52 | 53 | @gtcOrderNo.setter 54 | def gtcOrderNo(self, gtcOrderNo): 55 | """Sets the gtcOrderNo of this Gtcmodify. 56 | 57 | Order Number to modify # noqa: E501 58 | 59 | :param gtcOrderNo: The gtcOrderNo of this Gtcmodify. # noqa: E501 60 | :type gtcOrderNo: str 61 | """ 62 | 63 | self._gtcOrderNo = gtcOrderNo 64 | 65 | def to_dict(self): 66 | """Returns the model properties as a dict""" 67 | result = {} 68 | 69 | for attr, _ in six.iteritems(self.openapi_types): 70 | value = getattr(self, attr) 71 | if isinstance(value, list): 72 | result[attr] = list(map( 73 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 74 | value 75 | )) 76 | elif hasattr(value, "to_dict"): 77 | result[attr] = value.to_dict() 78 | elif isinstance(value, dict): 79 | result[attr] = dict(map( 80 | lambda item: (item[0], item[1].to_dict()) 81 | if hasattr(item[1], "to_dict") else item, 82 | value.items() 83 | )) 84 | else: 85 | result[attr] = value 86 | 87 | return result 88 | 89 | def to_str(self): 90 | """Returns the string representation of the model""" 91 | return pprint.pformat(self.to_dict()) 92 | 93 | def __repr__(self): 94 | """For `print` and `pprint`""" 95 | return self.to_str() 96 | 97 | def __eq__(self, other): 98 | """Returns true if both objects are equal""" 99 | if not isinstance(other, Gtcmodify): 100 | return False 101 | 102 | return self.to_dict() == other.to_dict() 103 | 104 | def __ne__(self, other): 105 | """Returns true if both objects are not equal""" 106 | if not isinstance(other, Gtcmodify): 107 | return True 108 | 109 | return self.to_dict() != other.to_dict() 110 | -------------------------------------------------------------------------------- /python/docs/TokenApi.md: -------------------------------------------------------------------------------- 1 | # ks_api_client.TokenApi 2 | 3 | All URIs are relative to "host" parameter 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**revoke_post**](DefaultApi.md#revoke_post) | **POST** /revoke | 8 | [**token_post**](DefaultApi.md#token_post) | **POST** /token | 9 | 10 | 11 | # **revoke** 12 | > revoke(token=token, token_type_hint=token_type_hint) 13 | 14 | 15 | 16 | ### Example 17 | ```python 18 | from ks_api_client import ks_api 19 | 20 | # Configure OAuth2 access token for authorization: default 21 | client = ks_api.KSTradeApi(access_token = "", userid = "", consumer_key = "",ip = "127.0.0.1", app_id = "", \ 22 | host = "https://tradeapi.kotaksecurities.com/apim", consumer_secret = "") 23 | 24 | #First initialize session and generate session token 25 | 26 | try: 27 | client.revoke(token="token", token_type_hint="token_type_hint") 28 | except ApiException as e: 29 | print("Exception when calling TokenApi->revoke: %s\n" % e) 30 | ``` 31 | 32 | ### Parameters 33 | 34 | Name | Type | Description | Notes 35 | ------------- | ------------- | ------------- | ------------- 36 | **authorization** | **str**| Basic Base64(consumer-key:consumer-secret) | 37 | **token** | **str**| access token you want to revoke | [optional] 38 | **token_type_hint** | **str**| (optional) | [optional] 39 | 40 | ### Return type 41 | 42 | void (empty response body) 43 | 44 | ### Authorization 45 | 46 | [default](../README.md#default) 47 | 48 | ### HTTP request headers 49 | 50 | - **Content-Type**: application/x-www-form-urlencoded 51 | - **Accept**: Not defined 52 | 53 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 54 | 55 | # **token** 56 | > token(grant_type=grant_type, username=username, password=password, refresh_token=refresh_token) 57 | 58 | 59 | 60 | ### Example 61 | ```python 62 | from ks_api_client import ks_api 63 | 64 | # Configure OAuth2 access token for authorization: default 65 | client = ks_api.KSTradeApi(access_token = "", userid = "", consumer_key = "",ip = "127.0.0.1", app_id = "", \ 66 | host = "https://tradeapi.kotaksecurities.com/apim", consumer_secret = "") 67 | 68 | #First initialize session and generate session token 69 | 70 | try: 71 | client.token(grant_type="grant_type", username="username", password="password", refresh_token="refresh_token") 72 | except ApiException as e: 73 | print("Exception when calling TokenApi->token: %s\n" % e) 74 | ``` 75 | 76 | ### Parameters 77 | 78 | Name | Type | Description | Notes 79 | ------------- | ------------- | ------------- | ------------- 80 | **authorization** | **str**| Basic Base64(consumer-key:consumer-secret) | 81 | **grant_type** | **str**| | [optional] 82 | **username** | **str**| only if grant_type=password | [optional] 83 | **password** | **str**| only if grant_type=password | [optional] 84 | **refresh_token** | **str**| only if grant_type=refresh_token | [optional] 85 | 86 | ### Return type 87 | 88 | void (empty response body) 89 | 90 | ### Authorization 91 | 92 | [default](../README.md#default) 93 | 94 | ### HTTP request headers 95 | 96 | - **Content-Type**: application/x-www-form-urlencoded 97 | - **Accept**: Not defined 98 | 99 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 100 | 101 | -------------------------------------------------------------------------------- /python/ks_api_client/models/gtcplace.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class Gtcplace(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'closeDate': 'str' 24 | } 25 | 26 | attribute_map = { 27 | 'closeDate': 'closeDate' 28 | } 29 | 30 | def __init__(self, closeDate=None, local_vars_configuration=None): # noqa: E501 31 | """Gtcplace - a model defined in OpenAPI""" # noqa: E501 32 | if local_vars_configuration is None: 33 | local_vars_configuration = Configuration() 34 | self.local_vars_configuration = local_vars_configuration 35 | 36 | self._closeDate = None 37 | self.discriminator = None 38 | 39 | if closeDate is not None: 40 | self.closeDate = closeDate 41 | 42 | @property 43 | def closeDate(self): 44 | """Gets the closeDate of this Gtcplace. # noqa: E501 45 | 46 | Close date for GTC order till which order to be placed in exchange by system. # noqa: E501 47 | 48 | :return: The closeDate of this Gtcplace. # noqa: E501 49 | :rtype: str 50 | """ 51 | return self._closeDate 52 | 53 | @closeDate.setter 54 | def closeDate(self, closeDate): 55 | """Sets the closeDate of this Gtcplace. 56 | 57 | Close date for GTC order till which order to be placed in exchange by system. # noqa: E501 58 | 59 | :param closeDate: The closeDate of this Gtcplace. # noqa: E501 60 | :type closeDate: str 61 | """ 62 | 63 | self._closeDate = closeDate 64 | 65 | def to_dict(self): 66 | """Returns the model properties as a dict""" 67 | result = {} 68 | 69 | for attr, _ in six.iteritems(self.openapi_types): 70 | value = getattr(self, attr) 71 | if isinstance(value, list): 72 | result[attr] = list(map( 73 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 74 | value 75 | )) 76 | elif hasattr(value, "to_dict"): 77 | result[attr] = value.to_dict() 78 | elif isinstance(value, dict): 79 | result[attr] = dict(map( 80 | lambda item: (item[0], item[1].to_dict()) 81 | if hasattr(item[1], "to_dict") else item, 82 | value.items() 83 | )) 84 | else: 85 | result[attr] = value 86 | 87 | return result 88 | 89 | def to_str(self): 90 | """Returns the string representation of the model""" 91 | return pprint.pformat(self.to_dict()) 92 | 93 | def __repr__(self): 94 | """For `print` and `pprint`""" 95 | return self.to_str() 96 | 97 | def __eq__(self, other): 98 | """Returns true if both objects are equal""" 99 | if not isinstance(other, Gtcplace): 100 | return False 101 | 102 | return self.to_dict() == other.to_dict() 103 | 104 | def __ne__(self, other): 105 | """Returns true if both objects are not equal""" 106 | if not isinstance(other, Gtcplace): 107 | return True 108 | 109 | return self.to_dict() != other.to_dict() 110 | -------------------------------------------------------------------------------- /python/ks_api_client/models/ctdplace.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class Ctdplace(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'ConvertQuantity': 'int' 24 | } 25 | 26 | attribute_map = { 27 | 'ConvertQuantity': 'ConvertQuantity' 28 | } 29 | 30 | def __init__(self, ConvertQuantity=None, local_vars_configuration=None): # noqa: E501 31 | """Ctdplace - a model defined in OpenAPI""" # noqa: E501 32 | if local_vars_configuration is None: 33 | local_vars_configuration = Configuration() 34 | self.local_vars_configuration = local_vars_configuration 35 | 36 | self._ConvertQuantity = None 37 | self.discriminator = None 38 | 39 | if ConvertQuantity is not None: 40 | self.ConvertQuantity = ConvertQuantity 41 | 42 | @property 43 | def ConvertQuantity(self): 44 | """Gets the ConvertQuantity of this Ctdplace. # noqa: E501 45 | 46 | Quantity to convert to delivery # noqa: E501 47 | 48 | :return: The ConvertQuantity of this Ctdplace. # noqa: E501 49 | :rtype: int 50 | """ 51 | return self._ConvertQuantity 52 | 53 | @ConvertQuantity.setter 54 | def ConvertQuantity(self, ConvertQuantity): 55 | """Sets the ConvertQuantity of this Ctdplace. 56 | 57 | Quantity to convert to delivery # noqa: E501 58 | 59 | :param ConvertQuantity: The ConvertQuantity of this Ctdplace. # noqa: E501 60 | :type ConvertQuantity: int 61 | """ 62 | 63 | self._ConvertQuantity = ConvertQuantity 64 | 65 | def to_dict(self): 66 | """Returns the model properties as a dict""" 67 | result = {} 68 | 69 | for attr, _ in six.iteritems(self.openapi_types): 70 | value = getattr(self, attr) 71 | if isinstance(value, list): 72 | result[attr] = list(map( 73 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 74 | value 75 | )) 76 | elif hasattr(value, "to_dict"): 77 | result[attr] = value.to_dict() 78 | elif isinstance(value, dict): 79 | result[attr] = dict(map( 80 | lambda item: (item[0], item[1].to_dict()) 81 | if hasattr(item[1], "to_dict") else item, 82 | value.items() 83 | )) 84 | else: 85 | result[attr] = value 86 | 87 | return result 88 | 89 | def to_str(self): 90 | """Returns the string representation of the model""" 91 | return pprint.pformat(self.to_dict()) 92 | 93 | def __repr__(self): 94 | """For `print` and `pprint`""" 95 | return self.to_str() 96 | 97 | def __eq__(self, other): 98 | """Returns true if both objects are equal""" 99 | if not isinstance(other, Ctdplace): 100 | return False 101 | 102 | return self.to_dict() == other.to_dict() 103 | 104 | def __ne__(self, other): 105 | """Returns true if both objects are not equal""" 106 | if not isinstance(other, Ctdplace): 107 | return True 108 | 109 | return self.to_dict() != other.to_dict() 110 | -------------------------------------------------------------------------------- /python/ks_api_client/models/ctdmodify.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class Ctdmodify(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'ConvertQuantity': 'int' 24 | } 25 | 26 | attribute_map = { 27 | 'ConvertQuantity': 'ConvertQuantity' 28 | } 29 | 30 | def __init__(self, ConvertQuantity=None, local_vars_configuration=None): # noqa: E501 31 | """Ctdmodify - a model defined in OpenAPI""" # noqa: E501 32 | if local_vars_configuration is None: 33 | local_vars_configuration = Configuration() 34 | self.local_vars_configuration = local_vars_configuration 35 | 36 | self._ConvertQuantity = None 37 | self.discriminator = None 38 | 39 | if ConvertQuantity is not None: 40 | self.ConvertQuantity = ConvertQuantity 41 | 42 | @property 43 | def ConvertQuantity(self): 44 | """Gets the ConvertQuantity of this Ctdmodify. # noqa: E501 45 | 46 | Quantity to convert to delivery # noqa: E501 47 | 48 | :return: The ConvertQuantity of this Ctdmodify. # noqa: E501 49 | :rtype: int 50 | """ 51 | return self._ConvertQuantity 52 | 53 | @ConvertQuantity.setter 54 | def ConvertQuantity(self, ConvertQuantity): 55 | """Sets the ConvertQuantity of this Ctdmodify. 56 | 57 | Quantity to convert to delivery # noqa: E501 58 | 59 | :param ConvertQuantity: The ConvertQuantity of this Ctdmodify. # noqa: E501 60 | :type ConvertQuantity: int 61 | """ 62 | 63 | self._ConvertQuantity = ConvertQuantity 64 | 65 | def to_dict(self): 66 | """Returns the model properties as a dict""" 67 | result = {} 68 | 69 | for attr, _ in six.iteritems(self.openapi_types): 70 | value = getattr(self, attr) 71 | if isinstance(value, list): 72 | result[attr] = list(map( 73 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 74 | value 75 | )) 76 | elif hasattr(value, "to_dict"): 77 | result[attr] = value.to_dict() 78 | elif isinstance(value, dict): 79 | result[attr] = dict(map( 80 | lambda item: (item[0], item[1].to_dict()) 81 | if hasattr(item[1], "to_dict") else item, 82 | value.items() 83 | )) 84 | else: 85 | result[attr] = value 86 | 87 | return result 88 | 89 | def to_str(self): 90 | """Returns the string representation of the model""" 91 | return pprint.pformat(self.to_dict()) 92 | 93 | def __repr__(self): 94 | """For `print` and `pprint`""" 95 | return self.to_str() 96 | 97 | def __eq__(self, other): 98 | """Returns true if both objects are equal""" 99 | if not isinstance(other, Ctdmodify): 100 | return False 101 | 102 | return self.to_dict() == other.to_dict() 103 | 104 | def __ne__(self, other): 105 | """Returns true if both objects are not equal""" 106 | if not isinstance(other, Ctdmodify): 107 | return True 108 | 109 | return self.to_dict() != other.to_dict() 110 | -------------------------------------------------------------------------------- /python/ks_api_client/models/codplace.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class Codplace(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'squareOffFlag': 'int' 24 | } 25 | 26 | attribute_map = { 27 | 'squareOffFlag': 'squareOffFlag' 28 | } 29 | 30 | def __init__(self, squareOffFlag=None, local_vars_configuration=None): # noqa: E501 31 | """Codplace - a model defined in OpenAPI""" # noqa: E501 32 | if local_vars_configuration is None: 33 | local_vars_configuration = Configuration() 34 | self.local_vars_configuration = local_vars_configuration 35 | 36 | self._squareOffFlag = None 37 | self.discriminator = None 38 | 39 | if squareOffFlag is not None: 40 | self.squareOffFlag = squareOffFlag 41 | 42 | @property 43 | def squareOffFlag(self): 44 | """Gets the squareOffFlag of this Codplace. # noqa: E501 45 | 46 | Square off flag for COD order, 1 to auto square off order. 0 - for no auto Square off by system. # noqa: E501 47 | 48 | :return: The squareOffFlag of this Codplace. # noqa: E501 49 | :rtype: int 50 | """ 51 | return self._squareOffFlag 52 | 53 | @squareOffFlag.setter 54 | def squareOffFlag(self, squareOffFlag): 55 | """Sets the squareOffFlag of this Codplace. 56 | 57 | Square off flag for COD order, 1 to auto square off order. 0 - for no auto Square off by system. # noqa: E501 58 | 59 | :param squareOffFlag: The squareOffFlag of this Codplace. # noqa: E501 60 | :type squareOffFlag: int 61 | """ 62 | 63 | self._squareOffFlag = squareOffFlag 64 | 65 | def to_dict(self): 66 | """Returns the model properties as a dict""" 67 | result = {} 68 | 69 | for attr, _ in six.iteritems(self.openapi_types): 70 | value = getattr(self, attr) 71 | if isinstance(value, list): 72 | result[attr] = list(map( 73 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 74 | value 75 | )) 76 | elif hasattr(value, "to_dict"): 77 | result[attr] = value.to_dict() 78 | elif isinstance(value, dict): 79 | result[attr] = dict(map( 80 | lambda item: (item[0], item[1].to_dict()) 81 | if hasattr(item[1], "to_dict") else item, 82 | value.items() 83 | )) 84 | else: 85 | result[attr] = value 86 | 87 | return result 88 | 89 | def to_str(self): 90 | """Returns the string representation of the model""" 91 | return pprint.pformat(self.to_dict()) 92 | 93 | def __repr__(self): 94 | """For `print` and `pprint`""" 95 | return self.to_str() 96 | 97 | def __eq__(self, other): 98 | """Returns true if both objects are equal""" 99 | if not isinstance(other, Codplace): 100 | return False 101 | 102 | return self.to_dict() == other.to_dict() 103 | 104 | def __ne__(self, other): 105 | """Returns true if both objects are not equal""" 106 | if not isinstance(other, Codplace): 107 | return True 108 | 109 | return self.to_dict() != other.to_dict() 110 | -------------------------------------------------------------------------------- /python/test/test_reports_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | 5 | 6 | from __future__ import absolute_import 7 | 8 | import unittest 9 | import time 10 | import ks_api_client 11 | from ks_api_client.ks_api import KSTradeApi as TradingApi 12 | from ks_api_client.rest import ApiException 13 | from ks_api_client.settings import host, access_token, userid, \ 14 | consumer_key, app_id, password, access_code, ip 15 | 16 | class TestReportsApi(unittest.TestCase): 17 | """ReportsApi unit test stubs""" 18 | ks_trade_api = TradingApi(access_token, userid, consumer_key, ip, app_id, host) 19 | 20 | def setUp(self): 21 | self.ks_trade_api.login(password = password) 22 | self.ks_trade_api.session_2fa(access_code = access_code) 23 | 24 | def tearDown(self): 25 | pass 26 | 27 | def test_get_fno_order_detail_by_order_id(self): 28 | """Test case for get_fno_order_detail_by_order_id 29 | 30 | Get order report by orderId # noqa: E501 31 | """ 32 | place_new_order = self.ks_trade_api.place_order(order_type = "N", tag = "string", transaction_type = "BUY", \ 33 | instrument_token = 727, variety = "REGULAR", quantity = 1, price = 0, \ 34 | disclosed_quantity = 0, validity = "GFD", trigger_price = 0) 35 | order_id = place_new_order['Success']['NSE']['orderId'] 36 | if order_id: 37 | fno_order_details = self.ks_trade_api.order_report(order_id = order_id,is_fno = "Y") 38 | print("FNO Order Details: ",fno_order_details) 39 | 40 | def test_get_order_report_by_order_id(self): 41 | """Test case for get_order_report_by_order_id 42 | 43 | Get order report by orderId # noqa: E501 44 | """ 45 | place_new_order = self.ks_trade_api.place_order(order_type = "N", tag = "string", transaction_type = "BUY", \ 46 | instrument_token = 727, variety = "REGULAR", quantity = 1, price = 0, \ 47 | disclosed_quantity = 0, validity = "GFD", trigger_price = 0) 48 | order_id = place_new_order['Success']['NSE']['orderId'] 49 | if order_id: 50 | order_report = self.ks_trade_api.order_report(order_id = order_id) 51 | print("Order Report: ",order_report) 52 | 53 | def test_get_order_reports(self): 54 | """Test case for get_order_reports 55 | 56 | Get order report # noqa: E501 57 | """ 58 | order_reports = self.ks_trade_api.order_report() 59 | print("Order Reports: ",order_reports) 60 | 61 | def test_get_trade_report(self): 62 | """Test case for get_trade_report 63 | 64 | Get trade report # noqa: E501 65 | """ 66 | trade_reports = self.ks_trade_api.trade_report() 67 | print("Trade Reports: ",trade_reports) 68 | 69 | def test_get_trade_report_by_order_id(self): 70 | """Test case for get_trade_report_by_order_id 71 | 72 | Get trade report by orderId # noqa: E501 73 | """ 74 | place_new_order = self.ks_trade_api.place_order(order_type = "N", tag = "string", transaction_type = "BUY", \ 75 | instrument_token = 727, variety = "REGULAR", quantity = 1, price = 0, \ 76 | disclosed_quantity = 0, validity = "GFD", trigger_price = 0) 77 | order_id = place_new_order['Success']['NSE']['orderId'] 78 | if order_id: 79 | trade_report = self.ks_trade_api.trade_report(order_id=order_id) 80 | print("Trade Report",trade_report) 81 | 82 | def test_get_fno_trade_detail_by_order_id(self): 83 | """Test case for get_fno_order_detail_by_order_id 84 | 85 | Get order report by orderId # noqa: E501 86 | """ 87 | place_new_order = self.ks_trade_api.place_order(order_type = "N", tag = "string", transaction_type = "BUY", \ 88 | instrument_token = 727, variety = "REGULAR", quantity = 1, price = 0, \ 89 | disclosed_quantity = 0, validity = "GFD", trigger_price = 0) 90 | order_id = place_new_order['Success']['NSE']['orderId'] 91 | if order_id: 92 | fno_trade_report = self.ks_trade_api.order_report(order_id = order_id,is_fno = "Y") 93 | print("fno_trade_details: ",fno_trade_report) 94 | 95 | 96 | if __name__ == '__main__': 97 | unittest.main() 98 | -------------------------------------------------------------------------------- /python/ks_api_client/models/user_credentials.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class UserCredentials(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'userid': 'str', 24 | 'password': 'str' 25 | } 26 | 27 | attribute_map = { 28 | 'userid': 'userid', 29 | 'password': 'password' 30 | } 31 | 32 | def __init__(self, userid=None, password=None, local_vars_configuration=None): # noqa: E501 33 | """UserCredentials - a model defined in OpenAPI""" # noqa: E501 34 | if local_vars_configuration is None: 35 | local_vars_configuration = Configuration() 36 | self.local_vars_configuration = local_vars_configuration 37 | 38 | self._userid = None 39 | self._password = None 40 | self.discriminator = None 41 | 42 | if userid is not None: 43 | self.userid = userid 44 | if password is not None: 45 | self.password = password 46 | 47 | @property 48 | def userid(self): 49 | """Gets the userid of this UserCredentials. # noqa: E501 50 | 51 | Your KSEC userID # noqa: E501 52 | 53 | :return: The userid of this UserCredentials. # noqa: E501 54 | :rtype: str 55 | """ 56 | return self._userid 57 | 58 | @userid.setter 59 | def userid(self, userid): 60 | """Sets the userid of this UserCredentials. 61 | 62 | Your KSEC userID # noqa: E501 63 | 64 | :param userid: The userid of this UserCredentials. # noqa: E501 65 | :type userid: str 66 | """ 67 | 68 | self._userid = userid 69 | 70 | @property 71 | def password(self): 72 | """Gets the password of this UserCredentials. # noqa: E501 73 | 74 | Your KSEC password # noqa: E501 75 | 76 | :return: The password of this UserCredentials. # noqa: E501 77 | :rtype: str 78 | """ 79 | return self._password 80 | 81 | @password.setter 82 | def password(self, password): 83 | """Sets the password of this UserCredentials. 84 | 85 | Your KSEC password # noqa: E501 86 | 87 | :param password: The password of this UserCredentials. # noqa: E501 88 | :type password: str 89 | """ 90 | 91 | self._password = password 92 | 93 | def to_dict(self): 94 | """Returns the model properties as a dict""" 95 | result = {} 96 | 97 | for attr, _ in six.iteritems(self.openapi_types): 98 | value = getattr(self, attr) 99 | if isinstance(value, list): 100 | result[attr] = list(map( 101 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 102 | value 103 | )) 104 | elif hasattr(value, "to_dict"): 105 | result[attr] = value.to_dict() 106 | elif isinstance(value, dict): 107 | result[attr] = dict(map( 108 | lambda item: (item[0], item[1].to_dict()) 109 | if hasattr(item[1], "to_dict") else item, 110 | value.items() 111 | )) 112 | else: 113 | result[attr] = value 114 | 115 | return result 116 | 117 | def to_str(self): 118 | """Returns the string representation of the model""" 119 | return pprint.pformat(self.to_dict()) 120 | 121 | def __repr__(self): 122 | """For `print` and `pprint`""" 123 | return self.to_str() 124 | 125 | def __eq__(self, other): 126 | """Returns true if both objects are equal""" 127 | if not isinstance(other, UserCredentials): 128 | return False 129 | 130 | return self.to_dict() == other.to_dict() 131 | 132 | def __ne__(self, other): 133 | """Returns true if both objects are not equal""" 134 | if not isinstance(other, UserCredentials): 135 | return True 136 | 137 | return self.to_dict() != other.to_dict() 138 | -------------------------------------------------------------------------------- /python/ks_api_client/models/tsloplace.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class Tsloplace(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'spread': 'float', 24 | 'trailingPrice': 'float' 25 | } 26 | 27 | attribute_map = { 28 | 'spread': 'spread', 29 | 'trailingPrice': 'trailingPrice' 30 | } 31 | 32 | def __init__(self, spread=None, trailingPrice=None, local_vars_configuration=None): # noqa: E501 33 | """Tsloplace - a model defined in OpenAPI""" # noqa: E501 34 | if local_vars_configuration is None: 35 | local_vars_configuration = Configuration() 36 | self.local_vars_configuration = local_vars_configuration 37 | 38 | self._spread = None 39 | self._trailingPrice = None 40 | self.discriminator = None 41 | 42 | if spread is not None: 43 | self.spread = spread 44 | if trailingPrice is not None: 45 | self.trailingPrice = trailingPrice 46 | 47 | @property 48 | def spread(self): 49 | """Gets the spread of this Tsloplace. # noqa: E501 50 | 51 | Spread of the order # noqa: E501 52 | 53 | :return: The spread of this Tsloplace. # noqa: E501 54 | :rtype: float 55 | """ 56 | return self._spread 57 | 58 | @spread.setter 59 | def spread(self, spread): 60 | """Sets the spread of this Tsloplace. 61 | 62 | Spread of the order # noqa: E501 63 | 64 | :param spread: The spread of this Tsloplace. # noqa: E501 65 | :type spread: float 66 | """ 67 | 68 | self._spread = spread 69 | 70 | @property 71 | def trailingPrice(self): 72 | """Gets the trailingPrice of this Tsloplace. # noqa: E501 73 | 74 | Triling price of TSLO Order. # noqa: E501 75 | 76 | :return: The trailingPrice of this Tsloplace. # noqa: E501 77 | :rtype: float 78 | """ 79 | return self._trailingPrice 80 | 81 | @trailingPrice.setter 82 | def trailingPrice(self, trailingPrice): 83 | """Sets the trailingPrice of this Tsloplace. 84 | 85 | Triling price of TSLO Order. # noqa: E501 86 | 87 | :param trailingPrice: The trailingPrice of this Tsloplace. # noqa: E501 88 | :type trailingPrice: float 89 | """ 90 | 91 | self._trailingPrice = trailingPrice 92 | 93 | def to_dict(self): 94 | """Returns the model properties as a dict""" 95 | result = {} 96 | 97 | for attr, _ in six.iteritems(self.openapi_types): 98 | value = getattr(self, attr) 99 | if isinstance(value, list): 100 | result[attr] = list(map( 101 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 102 | value 103 | )) 104 | elif hasattr(value, "to_dict"): 105 | result[attr] = value.to_dict() 106 | elif isinstance(value, dict): 107 | result[attr] = dict(map( 108 | lambda item: (item[0], item[1].to_dict()) 109 | if hasattr(item[1], "to_dict") else item, 110 | value.items() 111 | )) 112 | else: 113 | result[attr] = value 114 | 115 | return result 116 | 117 | def to_str(self): 118 | """Returns the string representation of the model""" 119 | return pprint.pformat(self.to_dict()) 120 | 121 | def __repr__(self): 122 | """For `print` and `pprint`""" 123 | return self.to_str() 124 | 125 | def __eq__(self, other): 126 | """Returns true if both objects are equal""" 127 | if not isinstance(other, Tsloplace): 128 | return False 129 | 130 | return self.to_dict() == other.to_dict() 131 | 132 | def __ne__(self, other): 133 | """Returns true if both objects are not equal""" 134 | if not isinstance(other, Tsloplace): 135 | return True 136 | 137 | return self.to_dict() != other.to_dict() 138 | -------------------------------------------------------------------------------- /python/ks_api_client/models/user_details.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class UserDetails(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'userid': 'str', 24 | 'accessCode': 'str' 25 | } 26 | 27 | attribute_map = { 28 | 'userid': 'userid', 29 | 'accessCode': 'accessCode' 30 | } 31 | 32 | def __init__(self, userid=None, accessCode=None, local_vars_configuration=None): # noqa: E501 33 | """UserDetails - a model defined in OpenAPI""" # noqa: E501 34 | if local_vars_configuration is None: 35 | local_vars_configuration = Configuration() 36 | self.local_vars_configuration = local_vars_configuration 37 | 38 | self._userid = None 39 | self._accessCode = None 40 | self.discriminator = None 41 | 42 | if userid is not None: 43 | self.userid = userid 44 | if accessCode is not None: 45 | self.accessCode = accessCode 46 | 47 | @property 48 | def userid(self): 49 | """Gets the userid of this UserDetails. # noqa: E501 50 | 51 | Userid for which access code validation # noqa: E501 52 | 53 | :return: The userid of this UserDetails. # noqa: E501 54 | :rtype: str 55 | """ 56 | return self._userid 57 | 58 | @userid.setter 59 | def userid(self, userid): 60 | """Sets the userid of this UserDetails. 61 | 62 | Userid for which access code validation # noqa: E501 63 | 64 | :param userid: The userid of this UserDetails. # noqa: E501 65 | :type userid: str 66 | """ 67 | 68 | self._userid = userid 69 | 70 | @property 71 | def accessCode(self): 72 | """Gets the accessCode of this UserDetails. # noqa: E501 73 | 74 | Login access code received on email and mobile no # noqa: E501 75 | 76 | :return: The accessCode of this UserDetails. # noqa: E501 77 | :rtype: str 78 | """ 79 | return self._accessCode 80 | 81 | @accessCode.setter 82 | def accessCode(self, accessCode): 83 | """Sets the accessCode of this UserDetails. 84 | 85 | Login access code received on email and mobile no # noqa: E501 86 | 87 | :param accessCode: The accessCode of this UserDetails. # noqa: E501 88 | :type accessCode: str 89 | """ 90 | 91 | self._accessCode = accessCode 92 | 93 | def to_dict(self): 94 | """Returns the model properties as a dict""" 95 | result = {} 96 | 97 | for attr, _ in six.iteritems(self.openapi_types): 98 | value = getattr(self, attr) 99 | if isinstance(value, list): 100 | result[attr] = list(map( 101 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 102 | value 103 | )) 104 | elif hasattr(value, "to_dict"): 105 | result[attr] = value.to_dict() 106 | elif isinstance(value, dict): 107 | result[attr] = dict(map( 108 | lambda item: (item[0], item[1].to_dict()) 109 | if hasattr(item[1], "to_dict") else item, 110 | value.items() 111 | )) 112 | else: 113 | result[attr] = value 114 | 115 | return result 116 | 117 | def to_str(self): 118 | """Returns the string representation of the model""" 119 | return pprint.pformat(self.to_dict()) 120 | 121 | def __repr__(self): 122 | """For `print` and `pprint`""" 123 | return self.to_str() 124 | 125 | def __eq__(self, other): 126 | """Returns true if both objects are equal""" 127 | if not isinstance(other, UserDetails): 128 | return False 129 | 130 | return self.to_dict() == other.to_dict() 131 | 132 | def __ne__(self, other): 133 | """Returns true if both objects are not equal""" 134 | if not isinstance(other, UserDetails): 135 | return True 136 | 137 | return self.to_dict() != other.to_dict() 138 | -------------------------------------------------------------------------------- /python/ks_api_client/exceptions.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | import six 4 | 5 | 6 | class OpenApiException(Exception): 7 | """The base exception class for all OpenAPIExceptions""" 8 | 9 | 10 | class ApiTypeError(OpenApiException, TypeError): 11 | def __init__(self, msg, path_to_item=None, valid_classes=None, 12 | key_type=None): 13 | """ Raises an exception for TypeErrors 14 | 15 | Args: 16 | msg (str): the exception message 17 | 18 | Keyword Args: 19 | path_to_item (list): a list of keys an indices to get to the 20 | current_item 21 | None if unset 22 | valid_classes (tuple): the primitive classes that current item 23 | should be an instance of 24 | None if unset 25 | key_type (bool): False if our value is a value in a dict 26 | True if it is a key in a dict 27 | False if our item is an item in a list 28 | None if unset 29 | """ 30 | self.path_to_item = path_to_item 31 | self.valid_classes = valid_classes 32 | self.key_type = key_type 33 | full_msg = msg 34 | if path_to_item: 35 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 36 | super(ApiTypeError, self).__init__(full_msg) 37 | 38 | 39 | class ApiValueError(OpenApiException, ValueError): 40 | def __init__(self, msg, path_to_item=None): 41 | """ 42 | Args: 43 | msg (str): the exception message 44 | 45 | Keyword Args: 46 | path_to_item (list) the path to the exception in the 47 | received_data dict. None if unset 48 | """ 49 | 50 | self.path_to_item = path_to_item 51 | full_msg = msg 52 | if path_to_item: 53 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 54 | super(ApiValueError, self).__init__(full_msg) 55 | 56 | 57 | class ApiAttributeError(OpenApiException, AttributeError): 58 | def __init__(self, msg, path_to_item=None): 59 | """ 60 | Raised when an attribute reference or assignment fails. 61 | 62 | Args: 63 | msg (str): the exception message 64 | 65 | Keyword Args: 66 | path_to_item (None/list) the path to the exception in the 67 | received_data dict 68 | """ 69 | self.path_to_item = path_to_item 70 | full_msg = msg 71 | if path_to_item: 72 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 73 | super(ApiAttributeError, self).__init__(full_msg) 74 | 75 | 76 | class ApiKeyError(OpenApiException, KeyError): 77 | def __init__(self, msg, path_to_item=None): 78 | """ 79 | Args: 80 | msg (str): the exception message 81 | 82 | Keyword Args: 83 | path_to_item (None/list) the path to the exception in the 84 | received_data dict 85 | """ 86 | self.path_to_item = path_to_item 87 | full_msg = msg 88 | if path_to_item: 89 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 90 | super(ApiKeyError, self).__init__(full_msg) 91 | 92 | 93 | class ApiException(OpenApiException): 94 | 95 | def __init__(self, status=None, reason=None, http_resp=None, body =None): 96 | if http_resp: 97 | self.status = http_resp.status 98 | self.reason = http_resp.reason 99 | self.body = http_resp.data 100 | self.headers = http_resp.getheaders() 101 | else: 102 | self.status = status 103 | self.reason = reason 104 | self.body = None 105 | self.headers = None 106 | if body: 107 | self.body = body 108 | if status: 109 | self.status = status 110 | if reason: 111 | self.reason = reason 112 | 113 | def __str__(self): 114 | """Custom error messages for exception""" 115 | error_message = "({0})\n"\ 116 | "Reason: {1}\n".format(self.status, self.reason) 117 | if self.headers: 118 | error_message += "HTTP response headers: {0}\n".format( 119 | self.headers) 120 | 121 | if self.body: 122 | error_message += "HTTP response body: {0}\n".format(self.body) 123 | 124 | return error_message 125 | 126 | 127 | def render_path(path_to_item): 128 | """Returns a string representation of a path""" 129 | result = "" 130 | for pth in path_to_item: 131 | if isinstance(pth, six.integer_types): 132 | result += "[{0}]".format(pth) 133 | else: 134 | result += "['{0}']".format(pth) 135 | return result 136 | -------------------------------------------------------------------------------- /python/ks_api_client/models/req_margin.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class ReqMargin(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'transactionType': 'str', 24 | 'orderInfo': 'list[OrderInfo]' 25 | } 26 | 27 | attribute_map = { 28 | 'transactionType': 'transactionType', 29 | 'orderInfo': 'orderInfo' 30 | } 31 | 32 | def __init__(self, transactionType=None, orderInfo=None, local_vars_configuration=None): # noqa: E501 33 | """ReqMargin - a model defined in OpenAPI""" # noqa: E501 34 | if local_vars_configuration is None: 35 | local_vars_configuration = Configuration() 36 | self.local_vars_configuration = local_vars_configuration 37 | 38 | self._transactionType = None 39 | self._orderInfo = None 40 | self.discriminator = None 41 | 42 | if transactionType is not None: 43 | self.transactionType = transactionType 44 | if orderInfo is not None: 45 | self.orderInfo = orderInfo 46 | 47 | @property 48 | def transactionType(self): 49 | """Gets the transactionType of this ReqMargin. # noqa: E501 50 | 51 | Transaction Type - BUY or SELL # noqa: E501 52 | 53 | :return: The transactionType of this ReqMargin. # noqa: E501 54 | :rtype: str 55 | """ 56 | return self._transactionType 57 | 58 | @transactionType.setter 59 | def transactionType(self, transactionType): 60 | """Sets the transactionType of this ReqMargin. 61 | 62 | Transaction Type - BUY or SELL # noqa: E501 63 | 64 | :param transactionType: The transactionType of this ReqMargin. # noqa: E501 65 | :type transactionType: str 66 | """ 67 | allowed_values = ["BUY", "SELL"] # noqa: E501 68 | if self.local_vars_configuration.client_side_validation and transactionType not in allowed_values: # noqa: E501 69 | raise ValueError( 70 | "Invalid value for `transactionType` ({0}), must be one of {1}" # noqa: E501 71 | .format(transactionType, allowed_values) 72 | ) 73 | 74 | self._transactionType = transactionType 75 | 76 | @property 77 | def orderInfo(self): 78 | """Gets the orderInfo of this ReqMargin. # noqa: E501 79 | 80 | 81 | :return: The orderInfo of this ReqMargin. # noqa: E501 82 | :rtype: list[OrderInfo] 83 | """ 84 | return self._orderInfo 85 | 86 | @orderInfo.setter 87 | def orderInfo(self, orderInfo): 88 | """Sets the orderInfo of this ReqMargin. 89 | 90 | 91 | :param orderInfo: The orderInfo of this ReqMargin. # noqa: E501 92 | :type orderInfo: list[OrderInfo] 93 | """ 94 | 95 | self._orderInfo = orderInfo 96 | 97 | def to_dict(self): 98 | """Returns the model properties as a dict""" 99 | result = {} 100 | 101 | for attr, _ in six.iteritems(self.openapi_types): 102 | value = getattr(self, attr) 103 | if isinstance(value, list): 104 | result[attr] = list(map( 105 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 106 | value 107 | )) 108 | elif hasattr(value, "to_dict"): 109 | result[attr] = value.to_dict() 110 | elif isinstance(value, dict): 111 | result[attr] = dict(map( 112 | lambda item: (item[0], item[1].to_dict()) 113 | if hasattr(item[1], "to_dict") else item, 114 | value.items() 115 | )) 116 | else: 117 | result[attr] = value 118 | 119 | return result 120 | 121 | def to_str(self): 122 | """Returns the string representation of the model""" 123 | return pprint.pformat(self.to_dict()) 124 | 125 | def __repr__(self): 126 | """For `print` and `pprint`""" 127 | return self.to_str() 128 | 129 | def __eq__(self, other): 130 | """Returns true if both objects are equal""" 131 | if not isinstance(other, ReqMargin): 132 | return False 133 | 134 | return self.to_dict() == other.to_dict() 135 | 136 | def __ne__(self, other): 137 | """Returns true if both objects are not equal""" 138 | if not isinstance(other, ReqMargin): 139 | return True 140 | 141 | return self.to_dict() != other.to_dict() 142 | -------------------------------------------------------------------------------- /python/ks_api_client/models/fault.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class Fault(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'code': 'int', 24 | 'message': 'str', 25 | 'description': 'str' 26 | } 27 | 28 | attribute_map = { 29 | 'code': 'code', 30 | 'message': 'message', 31 | 'description': 'description' 32 | } 33 | 34 | def __init__(self, code=None, message=None, description=None, local_vars_configuration=None): # noqa: E501 35 | """Fault - a model defined in OpenAPI""" # noqa: E501 36 | if local_vars_configuration is None: 37 | local_vars_configuration = Configuration() 38 | self.local_vars_configuration = local_vars_configuration 39 | 40 | self._code = None 41 | self._message = None 42 | self._description = None 43 | self.discriminator = None 44 | 45 | if code is not None: 46 | self.code = code 47 | if message is not None: 48 | self.message = message 49 | if description is not None: 50 | self.description = description 51 | 52 | @property 53 | def code(self): 54 | """Gets the code of this Fault. # noqa: E501 55 | 56 | error code # noqa: E501 57 | 58 | :return: The code of this Fault. # noqa: E501 59 | :rtype: int 60 | """ 61 | return self._code 62 | 63 | @code.setter 64 | def code(self, code): 65 | """Sets the code of this Fault. 66 | 67 | error code # noqa: E501 68 | 69 | :param code: The code of this Fault. # noqa: E501 70 | :type code: int 71 | """ 72 | 73 | self._code = code 74 | 75 | @property 76 | def message(self): 77 | """Gets the message of this Fault. # noqa: E501 78 | 79 | error message # noqa: E501 80 | 81 | :return: The message of this Fault. # noqa: E501 82 | :rtype: str 83 | """ 84 | return self._message 85 | 86 | @message.setter 87 | def message(self, message): 88 | """Sets the message of this Fault. 89 | 90 | error message # noqa: E501 91 | 92 | :param message: The message of this Fault. # noqa: E501 93 | :type message: str 94 | """ 95 | 96 | self._message = message 97 | 98 | @property 99 | def description(self): 100 | """Gets the description of this Fault. # noqa: E501 101 | 102 | error description # noqa: E501 103 | 104 | :return: The description of this Fault. # noqa: E501 105 | :rtype: str 106 | """ 107 | return self._description 108 | 109 | @description.setter 110 | def description(self, description): 111 | """Sets the description of this Fault. 112 | 113 | error description # noqa: E501 114 | 115 | :param description: The description of this Fault. # noqa: E501 116 | :type description: str 117 | """ 118 | 119 | self._description = description 120 | 121 | def to_dict(self): 122 | """Returns the model properties as a dict""" 123 | result = {} 124 | 125 | for attr, _ in six.iteritems(self.openapi_types): 126 | value = getattr(self, attr) 127 | if isinstance(value, list): 128 | result[attr] = list(map( 129 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 130 | value 131 | )) 132 | elif hasattr(value, "to_dict"): 133 | result[attr] = value.to_dict() 134 | elif isinstance(value, dict): 135 | result[attr] = dict(map( 136 | lambda item: (item[0], item[1].to_dict()) 137 | if hasattr(item[1], "to_dict") else item, 138 | value.items() 139 | )) 140 | else: 141 | result[attr] = value 142 | 143 | return result 144 | 145 | def to_str(self): 146 | """Returns the string representation of the model""" 147 | return pprint.pformat(self.to_dict()) 148 | 149 | def __repr__(self): 150 | """For `print` and `pprint`""" 151 | return self.to_str() 152 | 153 | def __eq__(self, other): 154 | """Returns true if both objects are equal""" 155 | if not isinstance(other, Fault): 156 | return False 157 | 158 | return self.to_dict() == other.to_dict() 159 | 160 | def __ne__(self, other): 161 | """Returns true if both objects are not equal""" 162 | if not isinstance(other, Fault): 163 | return True 164 | 165 | return self.to_dict() != other.to_dict() 166 | -------------------------------------------------------------------------------- /python/ks_api_client/models/tslomodify.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class Tslomodify(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'orderIndicator': 'int', 24 | 'spread': 'float', 25 | 'trailingPrice': 'float' 26 | } 27 | 28 | attribute_map = { 29 | 'orderIndicator': 'orderIndicator', 30 | 'spread': 'spread', 31 | 'trailingPrice': 'trailingPrice' 32 | } 33 | 34 | def __init__(self, orderIndicator=None, spread=None, trailingPrice=None, local_vars_configuration=None): # noqa: E501 35 | """Tslomodify - a model defined in OpenAPI""" # noqa: E501 36 | if local_vars_configuration is None: 37 | local_vars_configuration = Configuration() 38 | self.local_vars_configuration = local_vars_configuration 39 | 40 | self._orderIndicator = None 41 | self._spread = None 42 | self._trailingPrice = None 43 | self.discriminator = None 44 | 45 | if orderIndicator is not None: 46 | self.orderIndicator = orderIndicator 47 | if spread is not None: 48 | self.spread = spread 49 | if trailingPrice is not None: 50 | self.trailingPrice = trailingPrice 51 | 52 | @property 53 | def orderIndicator(self): 54 | """Gets the orderIndicator of this Tslomodify. # noqa: E501 55 | 56 | Order Indicator to modify Order # noqa: E501 57 | 58 | :return: The orderIndicator of this Tslomodify. # noqa: E501 59 | :rtype: int 60 | """ 61 | return self._orderIndicator 62 | 63 | @orderIndicator.setter 64 | def orderIndicator(self, orderIndicator): 65 | """Sets the orderIndicator of this Tslomodify. 66 | 67 | Order Indicator to modify Order # noqa: E501 68 | 69 | :param orderIndicator: The orderIndicator of this Tslomodify. # noqa: E501 70 | :type orderIndicator: int 71 | """ 72 | 73 | self._orderIndicator = orderIndicator 74 | 75 | @property 76 | def spread(self): 77 | """Gets the spread of this Tslomodify. # noqa: E501 78 | 79 | Spread of the order # noqa: E501 80 | 81 | :return: The spread of this Tslomodify. # noqa: E501 82 | :rtype: float 83 | """ 84 | return self._spread 85 | 86 | @spread.setter 87 | def spread(self, spread): 88 | """Sets the spread of this Tslomodify. 89 | 90 | Spread of the order # noqa: E501 91 | 92 | :param spread: The spread of this Tslomodify. # noqa: E501 93 | :type spread: float 94 | """ 95 | 96 | self._spread = spread 97 | 98 | @property 99 | def trailingPrice(self): 100 | """Gets the trailingPrice of this Tslomodify. # noqa: E501 101 | 102 | Triling price of TSLO Order. # noqa: E501 103 | 104 | :return: The trailingPrice of this Tslomodify. # noqa: E501 105 | :rtype: float 106 | """ 107 | return self._trailingPrice 108 | 109 | @trailingPrice.setter 110 | def trailingPrice(self, trailingPrice): 111 | """Sets the trailingPrice of this Tslomodify. 112 | 113 | Triling price of TSLO Order. # noqa: E501 114 | 115 | :param trailingPrice: The trailingPrice of this Tslomodify. # noqa: E501 116 | :type trailingPrice: float 117 | """ 118 | 119 | self._trailingPrice = trailingPrice 120 | 121 | def to_dict(self): 122 | """Returns the model properties as a dict""" 123 | result = {} 124 | 125 | for attr, _ in six.iteritems(self.openapi_types): 126 | value = getattr(self, attr) 127 | if isinstance(value, list): 128 | result[attr] = list(map( 129 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 130 | value 131 | )) 132 | elif hasattr(value, "to_dict"): 133 | result[attr] = value.to_dict() 134 | elif isinstance(value, dict): 135 | result[attr] = dict(map( 136 | lambda item: (item[0], item[1].to_dict()) 137 | if hasattr(item[1], "to_dict") else item, 138 | value.items() 139 | )) 140 | else: 141 | result[attr] = value 142 | 143 | return result 144 | 145 | def to_str(self): 146 | """Returns the string representation of the model""" 147 | return pprint.pformat(self.to_dict()) 148 | 149 | def __repr__(self): 150 | """For `print` and `pprint`""" 151 | return self.to_str() 152 | 153 | def __eq__(self, other): 154 | """Returns true if both objects are equal""" 155 | if not isinstance(other, Tslomodify): 156 | return False 157 | 158 | return self.to_dict() == other.to_dict() 159 | 160 | def __ne__(self, other): 161 | """Returns true if both objects are not equal""" 162 | if not isinstance(other, Tslomodify): 163 | return True 164 | 165 | return self.to_dict() != other.to_dict() 166 | -------------------------------------------------------------------------------- /python/ks_api_client/models/margin_det.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class MarginDet(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'instrumentToken': 'int', 24 | 'normal': 'float', 25 | 'supermultiple': 'float', 26 | 'mtf': 'float' 27 | } 28 | 29 | attribute_map = { 30 | 'instrumentToken': 'instrumentToken', 31 | 'normal': 'normal', 32 | 'supermultiple': 'supermultiple', 33 | 'mtf': 'mtf' 34 | } 35 | 36 | def __init__(self, instrumentToken=None, normal=None, supermultiple=None, mtf=None, local_vars_configuration=None): # noqa: E501 37 | """MarginDet - a model defined in OpenAPI""" # noqa: E501 38 | if local_vars_configuration is None: 39 | local_vars_configuration = Configuration() 40 | self.local_vars_configuration = local_vars_configuration 41 | 42 | self._instrumentToken = None 43 | self._normal = None 44 | self._supermultiple = None 45 | self._mtf = None 46 | self.discriminator = None 47 | 48 | if instrumentToken is not None: 49 | self.instrumentToken = instrumentToken 50 | if normal is not None: 51 | self.normal = normal 52 | if supermultiple is not None: 53 | self.supermultiple = supermultiple 54 | if mtf is not None: 55 | self.mtf = mtf 56 | 57 | @property 58 | def instrumentToken(self): 59 | """Gets the instrumentToken of this MarginDet. # noqa: E501 60 | 61 | 62 | :return: The instrumentToken of this MarginDet. # noqa: E501 63 | :rtype: int 64 | """ 65 | return self._instrumentToken 66 | 67 | @instrumentToken.setter 68 | def instrumentToken(self, instrumentToken): 69 | """Sets the instrumentToken of this MarginDet. 70 | 71 | 72 | :param instrumentToken: The instrumentToken of this MarginDet. # noqa: E501 73 | :type instrumentToken: int 74 | """ 75 | 76 | self._instrumentToken = instrumentToken 77 | 78 | @property 79 | def normal(self): 80 | """Gets the normal of this MarginDet. # noqa: E501 81 | 82 | Order Status # noqa: E501 83 | 84 | :return: The normal of this MarginDet. # noqa: E501 85 | :rtype: float 86 | """ 87 | return self._normal 88 | 89 | @normal.setter 90 | def normal(self, normal): 91 | """Sets the normal of this MarginDet. 92 | 93 | Order Status # noqa: E501 94 | 95 | :param normal: The normal of this MarginDet. # noqa: E501 96 | :type normal: float 97 | """ 98 | 99 | self._normal = normal 100 | 101 | @property 102 | def supermultiple(self): 103 | """Gets the supermultiple of this MarginDet. # noqa: E501 104 | 105 | Order Status # noqa: E501 106 | 107 | :return: The supermultiple of this MarginDet. # noqa: E501 108 | :rtype: float 109 | """ 110 | return self._supermultiple 111 | 112 | @supermultiple.setter 113 | def supermultiple(self, supermultiple): 114 | """Sets the supermultiple of this MarginDet. 115 | 116 | Order Status # noqa: E501 117 | 118 | :param supermultiple: The supermultiple of this MarginDet. # noqa: E501 119 | :type supermultiple: float 120 | """ 121 | 122 | self._supermultiple = supermultiple 123 | 124 | @property 125 | def mtf(self): 126 | """Gets the mtf of this MarginDet. # noqa: E501 127 | 128 | Order Status # noqa: E501 129 | 130 | :return: The mtf of this MarginDet. # noqa: E501 131 | :rtype: float 132 | """ 133 | return self._mtf 134 | 135 | @mtf.setter 136 | def mtf(self, mtf): 137 | """Sets the mtf of this MarginDet. 138 | 139 | Order Status # noqa: E501 140 | 141 | :param mtf: The mtf of this MarginDet. # noqa: E501 142 | :type mtf: float 143 | """ 144 | 145 | self._mtf = mtf 146 | 147 | def to_dict(self): 148 | """Returns the model properties as a dict""" 149 | result = {} 150 | 151 | for attr, _ in six.iteritems(self.openapi_types): 152 | value = getattr(self, attr) 153 | if isinstance(value, list): 154 | result[attr] = list(map( 155 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 156 | value 157 | )) 158 | elif hasattr(value, "to_dict"): 159 | result[attr] = value.to_dict() 160 | elif isinstance(value, dict): 161 | result[attr] = dict(map( 162 | lambda item: (item[0], item[1].to_dict()) 163 | if hasattr(item[1], "to_dict") else item, 164 | value.items() 165 | )) 166 | else: 167 | result[attr] = value 168 | 169 | return result 170 | 171 | def to_str(self): 172 | """Returns the string representation of the model""" 173 | return pprint.pformat(self.to_dict()) 174 | 175 | def __repr__(self): 176 | """For `print` and `pprint`""" 177 | return self.to_str() 178 | 179 | def __eq__(self, other): 180 | """Returns true if both objects are equal""" 181 | if not isinstance(other, MarginDet): 182 | return False 183 | 184 | return self.to_dict() == other.to_dict() 185 | 186 | def __ne__(self, other): 187 | """Returns true if both objects are not equal""" 188 | if not isinstance(other, MarginDet): 189 | return True 190 | 191 | return self.to_dict() != other.to_dict() 192 | -------------------------------------------------------------------------------- /python/docs/README.md: -------------------------------------------------------------------------------- 1 | # ks_api_client 2 | No description provided 3 | 4 | - API version: 1.0.1 5 | - Package version: 1.1.0 6 | 7 | ## Requirements. 8 | 9 | Python 2.7 and 3.4+ 10 | 11 | ## Installation & Usage 12 | ### pip install 13 | 14 | If the python package is hosted on a repository, you can install directly using: 15 | 16 | ```sh 17 | pip install -e "git+https://github.com/paramatrixtech/ksapi.git#egg=ks_api_client&subdirectory=./python" 18 | ``` 19 | (you may need to run `pip` with root permission: `sudo pip install -e "git+https://github.com/paramatrixtech/ksapi.git#egg=ks_api_client&subdirectory=./python"`) 20 | 21 | Then import the package: 22 | ```python 23 | import ks_api_client 24 | ``` 25 | 26 | ### Setuptools 27 | 28 | Install via [Setuptools](http://pypi.python.org/pypi/setuptools). 29 | 30 | ```sh 31 | python setup.py install --user 32 | ``` 33 | (or `sudo python setup.py install` to install the package for all users) 34 | 35 | Then import the package: 36 | ```python 37 | import ks_api_client 38 | ``` 39 | 40 | ## Getting Started 41 | 42 | Please follow the [installation procedure](#installation--usage) and then run the following: 43 | 44 | ```python 45 | from ks_api_client import ks_api 46 | # Defining the host is optional and defaults to https://sbx.kotaksecurities.com/apim 47 | # See configuration.py for a list of all supported configuration parameters. 48 | client = ks_api.KSTradeApi(access_token = "", userid = "", consumer_key = "",ip = "127.0.0.1", app_id = "", \ 49 | hosts=["https://tradeapi.kotaksecurities.com/apim"], proxy_url = '', proxy_user = '', \ 50 | proxy_pass = '', consumer_secret = "") 51 | 52 | # Get session for user 53 | client.login(password = "") 54 | 55 | #Generated session token 56 | client.session_2fa(access_code = "") 57 | 58 | # Place an order 59 | client.place_order(order_type = "O", instrument_token = 727, transaction_type = "BUY",\ 60 | quantity = 1, price = 0, disclosed_quantity = 0, trigger_price = 0,\ 61 | validity = "GFD", variety = "REGULAR", tag = "string", product = "NORMAL", smart_order_routing="string") 62 | 63 | client.place_order(order_type = "N", instrument_token = 727, transaction_type = "BUY",\ 64 | quantity = 1, price = 0, disclosed_quantity = 0, trigger_price = 0,\ 65 | validity = "GFD", variety = "REGULAR", tag = "string") 66 | 67 | # Modify an order 68 | client.modify_order(order_id = "", price = 0, quantity = 1, disclosed_quantity = 0, trigger_price = 0, validity = "GFD") 69 | 70 | # Cancel an order 71 | client.cancel_order(order_id = "") 72 | 73 | # Get Report Orders 74 | client.order_report() 75 | 76 | # Get Report Orders for order id 77 | client.order_report(order_id = "") 78 | 79 | # Get FNO Report Orders for order id 80 | client.order_report(order_id = "", is_fno = "Y") 81 | 82 | # Get Trade Report 83 | client.trade_report() 84 | 85 | # Get Trade Report for order id 86 | client.trade_report(order_id = "") 87 | 88 | # Get FNO Trade Report for order id 89 | client.trade_report(order_id = "", is_fno = "Y") 90 | 91 | # Get Margin required 92 | order_info = [ 93 | {"instrument_token": 727, "quantity": 1, "price": 1300, "amount": 0, "trigger_price": 1190}, 94 | {"instrument_token": 1374, "quantity": 1, "price": 1200, "amount": 0, "trigger_price": 1150} 95 | ] 96 | client.margin_required(transaction_type = "BUY",order_info = order_info) 97 | 98 | # Get Margin 99 | client.margin() 100 | 101 | # Get Positions 102 | client.positions(position_type = "TODAYS") 103 | 104 | # Get Quote details 105 | client.quote(instrument_token = 110) 106 | 107 | # Get Historical data 108 | client.history("historicalprices",{"exchange":"bse","cocode":"476","fromdate":"01-jan-2014","todate":"08-oct-2015"}) 109 | client.history("historicalprices-unadjusted",{"exchange":"bse","co_code":"476","date":"16-Jun-2016"}) 110 | client.history("NSEFNO_HistoricalContinuousChart",{"symbol":"HDFC","expiry type": "near"}) 111 | client.history("LiveorEODHistorical",{"exchange":"BSE","co_code":"5400","period":"Y","cnt":"3"}) 112 | 113 | # Subscribe to instrument token's stream. 114 | def callback_method(message): 115 | print(message) 116 | print("Your logic/computation will come here.") 117 | client.subscribe(input_tokens="745,754", callback=callback_method) 118 | 119 | # Unsubscribe from streaming service. 120 | client.unsubscribe() 121 | 122 | #Terminate user's Session 123 | client.logout() 124 | ``` 125 | ## Documentation for API Endpoints 126 | 127 | All URIs are relative to *https://sbx.kotaksecurities.com/apim* 128 | 129 | Class | Method | Description 130 | ------------ | ------------- | ------------- 131 | *SessionApi* | [**ks_api.KSTradeApi**](SessionApi.md#session_init) | Initialise Session 132 | *SessionApi* | [**login**](SessionApi.md#login) | Login using Userid 133 | *SessionApi* | [**session_2fa**](SessionApi.md#session_2fa) | Generate final Session Token 134 | *OrderApi* | [**place_order**](OrderApi.md#place_order) | Place a New order 135 | *OrderApi* | [**modify_order**](OrderApi.md#modify_order) | Modify an existing order 136 | *OrderApi* | [**cancel_order**](OrderApi.md#cancel_order) | Cancel an order 137 | *ReportsApi* | [**order_report**](ReportsApi.md#order_report) | Get order report 138 | *ReportsApi* | [**trade_report**](ReportsApi.md#trade_report) | Get trade report 139 | *MarginApi* | [**margin_required**](MarginApi.md#margin_required) | Get Margin Required for an order by amount or quantity. 140 | *MarginApi* | [**margin**](MarginApi.md#margin) | Get all calculated margins. 141 | *PositionsApi* | [**positions**](PositionsApi.md#positions) | Get's Open position. 142 | *QuoteApi* | [**quote**](QuoteApi.md#quote_details) | Get Quote details 143 | *HistoricalApi* | [**history**](HistoricalApi.md#history) | Get historical data. 144 | *StreamingApi* | [**subscribe**](StreamingApi.md#subscribe) | Subscribe to streaming api of specified instrument tokens. 145 | *StreamingApi* | [**unsubscribe**](StreamingApi.md#unsubscribe) | Unsubscribe from streaming api. 146 | *SessionApi* | [**logout**](SessionApi.md#logout) | Invalidate Session Token 147 | 148 | 149 | -------------------------------------------------------------------------------- /python/ks_api_client/models/bracketplace.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class Bracketplace(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'Spread': 'float', 24 | 'trailingPrice': 'float', 25 | 'bookProfit': 'float', 26 | 'bookDisclosedQty': 'int' 27 | } 28 | 29 | attribute_map = { 30 | 'Spread': 'Spread', 31 | 'trailingPrice': 'trailingPrice', 32 | 'bookProfit': 'bookProfit', 33 | 'bookDisclosedQty': 'bookDisclosedQty' 34 | } 35 | 36 | def __init__(self, Spread=None, trailingPrice=None, bookProfit=None, bookDisclosedQty=None, local_vars_configuration=None): # noqa: E501 37 | """Bracketplace - a model defined in OpenAPI""" # noqa: E501 38 | if local_vars_configuration is None: 39 | local_vars_configuration = Configuration() 40 | self.local_vars_configuration = local_vars_configuration 41 | 42 | self._Spread = None 43 | self._trailingPrice = None 44 | self._bookProfit = None 45 | self._bookDisclosedQty = None 46 | self.discriminator = None 47 | 48 | if Spread is not None: 49 | self.Spread = Spread 50 | if trailingPrice is not None: 51 | self.trailingPrice = trailingPrice 52 | if bookProfit is not None: 53 | self.bookProfit = bookProfit 54 | if bookDisclosedQty is not None: 55 | self.bookDisclosedQty = bookDisclosedQty 56 | 57 | @property 58 | def Spread(self): 59 | """Gets the Spread of this Bracketplace. # noqa: E501 60 | 61 | Spread of the order # noqa: E501 62 | 63 | :return: The Spread of this Bracketplace. # noqa: E501 64 | :rtype: float 65 | """ 66 | return self._Spread 67 | 68 | @Spread.setter 69 | def Spread(self, Spread): 70 | """Sets the Spread of this Bracketplace. 71 | 72 | Spread of the order # noqa: E501 73 | 74 | :param Spread: The Spread of this Bracketplace. # noqa: E501 75 | :type Spread: float 76 | """ 77 | 78 | self._Spread = Spread 79 | 80 | @property 81 | def trailingPrice(self): 82 | """Gets the trailingPrice of this Bracketplace. # noqa: E501 83 | 84 | Triling price of TSLO Order. # noqa: E501 85 | 86 | :return: The trailingPrice of this Bracketplace. # noqa: E501 87 | :rtype: float 88 | """ 89 | return self._trailingPrice 90 | 91 | @trailingPrice.setter 92 | def trailingPrice(self, trailingPrice): 93 | """Sets the trailingPrice of this Bracketplace. 94 | 95 | Triling price of TSLO Order. # noqa: E501 96 | 97 | :param trailingPrice: The trailingPrice of this Bracketplace. # noqa: E501 98 | :type trailingPrice: float 99 | """ 100 | 101 | self._trailingPrice = trailingPrice 102 | 103 | @property 104 | def bookProfit(self): 105 | """Gets the bookProfit of this Bracketplace. # noqa: E501 106 | 107 | Book Profit Price of the order # noqa: E501 108 | 109 | :return: The bookProfit of this Bracketplace. # noqa: E501 110 | :rtype: float 111 | """ 112 | return self._bookProfit 113 | 114 | @bookProfit.setter 115 | def bookProfit(self, bookProfit): 116 | """Sets the bookProfit of this Bracketplace. 117 | 118 | Book Profit Price of the order # noqa: E501 119 | 120 | :param bookProfit: The bookProfit of this Bracketplace. # noqa: E501 121 | :type bookProfit: float 122 | """ 123 | 124 | self._bookProfit = bookProfit 125 | 126 | @property 127 | def bookDisclosedQty(self): 128 | """Gets the bookDisclosedQty of this Bracketplace. # noqa: E501 129 | 130 | Quantity to be disclosed in bracket order # noqa: E501 131 | 132 | :return: The bookDisclosedQty of this Bracketplace. # noqa: E501 133 | :rtype: int 134 | """ 135 | return self._bookDisclosedQty 136 | 137 | @bookDisclosedQty.setter 138 | def bookDisclosedQty(self, bookDisclosedQty): 139 | """Sets the bookDisclosedQty of this Bracketplace. 140 | 141 | Quantity to be disclosed in bracket order # noqa: E501 142 | 143 | :param bookDisclosedQty: The bookDisclosedQty of this Bracketplace. # noqa: E501 144 | :type bookDisclosedQty: int 145 | """ 146 | 147 | self._bookDisclosedQty = bookDisclosedQty 148 | 149 | def to_dict(self): 150 | """Returns the model properties as a dict""" 151 | result = {} 152 | 153 | for attr, _ in six.iteritems(self.openapi_types): 154 | value = getattr(self, attr) 155 | if isinstance(value, list): 156 | result[attr] = list(map( 157 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 158 | value 159 | )) 160 | elif hasattr(value, "to_dict"): 161 | result[attr] = value.to_dict() 162 | elif isinstance(value, dict): 163 | result[attr] = dict(map( 164 | lambda item: (item[0], item[1].to_dict()) 165 | if hasattr(item[1], "to_dict") else item, 166 | value.items() 167 | )) 168 | else: 169 | result[attr] = value 170 | 171 | return result 172 | 173 | def to_str(self): 174 | """Returns the string representation of the model""" 175 | return pprint.pformat(self.to_dict()) 176 | 177 | def __repr__(self): 178 | """For `print` and `pprint`""" 179 | return self.to_str() 180 | 181 | def __eq__(self, other): 182 | """Returns true if both objects are equal""" 183 | if not isinstance(other, Bracketplace): 184 | return False 185 | 186 | return self.to_dict() == other.to_dict() 187 | 188 | def __ne__(self, other): 189 | """Returns true if both objects are not equal""" 190 | if not isinstance(other, Bracketplace): 191 | return True 192 | 193 | return self.to_dict() != other.to_dict() 194 | -------------------------------------------------------------------------------- /python/docs/ReportsApi.md: -------------------------------------------------------------------------------- 1 | # ks_api_client.ReportsApi 2 | 3 | All URIs are relative to "host" parameter 4 | 5 | Method | Description 6 | ------------- | ------------- 7 | [**order_report**](ReportsApi.md#order_report) | Get order report 8 | [**trade_report**](ReportsApi.md#trade_report) | Get trade report 9 | 10 | 11 | # **order_report** 12 | > object order_report(order_id) 13 | 14 | Get order report 15 | 16 | Returns the full order report for a client in case order_id is not provided 17 | else returns the order report for a client of provided order_id. 18 | 19 | ### Example 20 | 21 | 22 | ```python 23 | from ks_api_client import ks_api 24 | 25 | client = ks_api.KSTradeApi(access_token = "", userid = "", consumer_key = "",ip = "127.0.0.1", app_id = "", \ 26 | host = "https://tradeapi.kotaksecurities.com/apim", consumer_secret = "") 27 | 28 | #First initialize session and generate session token 29 | try: 30 | # Get full order report 31 | client.order_report() 32 | 33 | # Get order report by order id 34 | client.order_report(order_id = "2200922000576") 35 | 36 | # Get fno order report by order id 37 | client.order_report(order_id = "2200922000576", is_fno = "Y") 38 | 39 | except Exception as e: 40 | print("Exception when calling ReportsApi->order_report: %s\n" % e) 41 | ``` 42 | 43 | 44 | ### Parameters 45 | 46 | Name | Type | Description | Notes 47 | ------------- | ------------- | ------------- | ------------- 48 | **order_id** | **str**| Order ID of the order | [optional] 49 | **is_fno** | **str** | Is order of FNO type? ("Y" or "N") | [optional] 50 | 51 | ### Return type 52 | 53 | object 54 | 55 | ### Sample response 56 | ```python3 57 | { 58 | "success": [ 59 | { 60 | "activityTimestamp": "Aug 25 2021 10:24:04:000AM", 61 | "disclosedQuantity": 0, 62 | "exchOrderId": "", 63 | "exchTradeId": "-", 64 | "exchangeStatus": "Order sent to Exchange", 65 | "filledQuantity": 0, 66 | "message": "", 67 | "orderQuantity": 1, 68 | "price": 0, 69 | "status": "NEWF", 70 | "statusInfo": "Confirmation Pending", 71 | "statusMessage": "Confirmation pending from Exchange", 72 | "triggerPrice": 0, 73 | "validity": "Good For Day", 74 | "version": 1 75 | }, 76 | { 77 | "activityTimestamp": "Aug 25 2021 10:24:05:000AM", 78 | "disclosedQuantity": 0, 79 | "exchOrderId": "1000000000002144", 80 | "exchTradeId": "-", 81 | "exchangeStatus": "Order Confirmed", 82 | "filledQuantity": 0, 83 | "message": "", 84 | "orderQuantity": 1, 85 | "price": 0, 86 | "status": "OPN", 87 | "statusInfo": "", 88 | "statusMessage": "Open", 89 | "triggerPrice": 0, 90 | "validity": "Good For Day", 91 | "version": 2 92 | } 93 | ] 94 | } 95 | ``` 96 | 97 | ### HTTP request headers 98 | 99 | - **Accept**: application/json 100 | 101 | ### HTTP response details 102 | | Status code | Description | Response headers | 103 | |-------------|-------------|------------------| 104 | **200** | Order Report of a client | - | 105 | **400** | Invalid or missing input parameters | - | 106 | **403** | Invalid session, please re-login to continue | - | 107 | **429** | Too many requests to the API | - | 108 | **500** | Unexpected error | - | 109 | **502** | Not able to communicate with OMS | - | 110 | **503** | Trade API service is unavailable | - | 111 | **504** | Gateway timeout, trade API is unreachable | - | 112 | 113 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 114 | 115 | # **trade_report** 116 | > object trade_report(order_id) 117 | 118 | Get trade report 119 | 120 | Returns the full trade report for a client in case order_id is not provided 121 | else returns the trade report for a client of provided order_id. 122 | 123 | ### Example 124 | 125 | 126 | ```python 127 | from ks_api_client import ks_api 128 | 129 | client = ks_api.KSTradeApi(access_token = "", userid = "", consumer_key = "",ip = "127.0.0.1", app_id = "", \ 130 | host = "https://tradeapi.kotaksecurities.com/apim", consumer_secret = "") 131 | 132 | #First initialize session and generate session token 133 | 134 | try: 135 | # Get full trade report 136 | client.trade_report() 137 | 138 | # Get trade report by order id 139 | client.trade_report(order_id = "2211111002990") 140 | 141 | # Get fno trade report by order id 142 | client.trade_report(order_id = "2211111002990", is_fno = "Y") 143 | 144 | except ApiException as e: 145 | print("Exception when calling ReportsApi->trade_report: %s\n" % e) 146 | ``` 147 | 148 | 149 | ### Parameters 150 | 151 | Name | Type | Description | Notes 152 | ------------- | ------------- | ------------- | ------------- 153 | **order_id** | **str**| Order ID of the order| [optional] 154 | **is_fno** | **str** | Is order of FNO type? ("Y" or "N") | [optional] 155 | 156 | ### Return type 157 | 158 | object 159 | 160 | ### Sample response 161 | ```python3 162 | { 163 | 'success': [ 164 | { 165 | 'activityTimestamp': 'Dec 8 2021 12: 08: 24: 000PM', 166 | 'disclosedQuantity': 0, 167 | 'exchOrderId': '', 168 | 'exchTradeId': '-', 169 | 'exchangeStatus': 'Order sent to Exchange', 170 | 'filledQuantity': 0, 171 | 'message': '', 172 | 'orderQuantity': 25, 173 | 'price': 36157, 174 | 'status': 'NEWF', 175 | 'statusInfo': 'Confirmation Pending', 176 | 'statusMessage': 'Confirmation pending from Exchange', 177 | 'triggerPrice': 0, 178 | 'validity': 'Good For Day', 179 | 'version': 1 180 | }, 181 | { 182 | 'activityTimestamp': 'Dec 8 2021 12: 08: 24: 000PM', 183 | 'disclosedQuantity': 0, 184 | 'exchOrderId': '1100000000032549', 185 | 'exchTradeId': '-', 186 | 'exchangeStatus': 'Order Confirmed', 187 | 'filledQuantity': 0, 188 | 'message': '', 189 | 'orderQuantity': 25, 190 | 'price': 36157, 191 | 'status': 'OPN', 192 | 'statusInfo': '', 193 | 'statusMessage': 'Open', 194 | 'triggerPrice': 0, 195 | 'validity': 'Good For Day', 196 | 'version': 2 197 | } 198 | ] 199 | } 200 | ``` 201 | 202 | ### HTTP request headers 203 | 204 | - **Accept**: application/json 205 | 206 | ### HTTP response details 207 | | Status code | Description | Response headers | 208 | |-------------|-------------|------------------| 209 | **200** | Trade Report of a client | - | 210 | **400** | Invalid or missing input parameters | - | 211 | **403** | Invalid session, please re-login to continue | - | 212 | **429** | Too many requests to the API | - | 213 | **500** | Unexpected error | - | 214 | **502** | Not able to communicate with OMS | - | 215 | **503** | Trade API service is unavailable | - | 216 | **504** | Gateway timeout, trade API is unreachable | - | 217 | 218 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 219 | -------------------------------------------------------------------------------- /python/ks_api_client/api/historical_api.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | from __future__ import absolute_import 5 | 6 | import re # noqa: F401 7 | 8 | # python 2 and python 3 compatibility library 9 | import six 10 | 11 | from ks_api_client.api_client import ApiClient 12 | from ks_api_client.exceptions import ( # noqa: F401 13 | ApiTypeError, 14 | ApiValueError 15 | ) 16 | 17 | 18 | class HistoricalApi(object): 19 | 20 | def __init__(self, api_client=None): 21 | if api_client is None: 22 | api_client = ApiClient() 23 | self.api_client = api_client 24 | 25 | def get_resource(self, resource, input, **kwargs): # noqa: E501 26 | """Get historical data # noqa: E501 27 | 28 | Get Historical data # noqa: E501 29 | This method makes a synchronous HTTP request by default. To make an 30 | asynchronous HTTP request, please pass async_req=True 31 | 32 | >>> thread = api.get_resource(resource, input, async_req=True) 33 | >>> result = thread.get() 34 | 35 | :param resource: (required) 36 | :type resource: str 37 | :param input: (required) 38 | :type input: str 39 | :param async_req: Whether to execute the request asynchronously. 40 | :type async_req: bool, optional 41 | :param _preload_content: if False, the urllib3.HTTPResponse object will 42 | be returned without reading/decoding response 43 | data. Default is True. 44 | :type _preload_content: bool, optional 45 | :param _request_timeout: timeout setting for this request. If one 46 | number provided, it will be total request 47 | timeout. It can also be a pair (tuple) of 48 | (connection, read) timeouts. 49 | :return: Returns the result object. 50 | If the method is called asynchronously, 51 | returns the request thread. 52 | :rtype: object 53 | """ 54 | kwargs['_return_http_data_only'] = True 55 | return self.get_resource_with_http_info(resource, input, **kwargs) # noqa: E501 56 | 57 | def get_resource_with_http_info(self, resource, input, **kwargs): # noqa: E501 58 | """Get historical data # noqa: E501 59 | 60 | Get Historical data # noqa: E501 61 | This method makes a synchronous HTTP request by default. To make an 62 | asynchronous HTTP request, please pass async_req=True 63 | 64 | >>> thread = api.get_resource_with_http_info(resource, input, async_req=True) 65 | >>> result = thread.get() 66 | 67 | :param resource: (required) 68 | :type resource: str 69 | :param input: (required) 70 | :type input: str 71 | :param async_req: Whether to execute the request asynchronously. 72 | :type async_req: bool, optional 73 | :param _return_http_data_only: response data without head status code 74 | and headers 75 | :type _return_http_data_only: bool, optional 76 | :param _preload_content: if False, the urllib3.HTTPResponse object will 77 | be returned without reading/decoding response 78 | data. Default is True. 79 | :type _preload_content: bool, optional 80 | :param _request_timeout: timeout setting for this request. If one 81 | number provided, it will be total request 82 | timeout. It can also be a pair (tuple) of 83 | (connection, read) timeouts. 84 | :param _request_auth: set to override the auth_settings for an a single 85 | request; this effectively ignores the authentication 86 | in the spec for a single request. 87 | :type _request_auth: dict, optional 88 | :return: Returns the result object. 89 | If the method is called asynchronously, 90 | returns the request thread. 91 | :rtype: tuple(object, status_code(int), headers(HTTPHeaderDict)) 92 | """ 93 | 94 | local_var_params = locals() 95 | 96 | all_params = [ 97 | 'resource', 98 | 'input' 99 | ] 100 | all_params.extend( 101 | [ 102 | 'async_req', 103 | '_return_http_data_only', 104 | '_preload_content', 105 | '_request_timeout', 106 | '_request_auth' 107 | ] 108 | ) 109 | 110 | for key, val in six.iteritems(local_var_params['kwargs']): 111 | if key not in all_params: 112 | raise ApiTypeError( 113 | "Got an unexpected keyword argument '%s'" 114 | " to method get_resource" % key 115 | ) 116 | local_var_params[key] = val 117 | del local_var_params['kwargs'] 118 | # verify the required parameter 'resource' is set 119 | if self.api_client.client_side_validation and ('resource' not in local_var_params or # noqa: E501 120 | local_var_params['resource'] is None): # noqa: E501 121 | raise ApiValueError("Missing the required parameter `resource` when calling `get_resource`") # noqa: E501 122 | # verify the required parameter 'input' is set 123 | if self.api_client.client_side_validation and ('input' not in local_var_params or # noqa: E501 124 | local_var_params['input'] is None): # noqa: E501 125 | raise ApiValueError("Missing the required parameter `input` when calling `get_resource`") # noqa: E501 126 | 127 | collection_formats = {} 128 | 129 | path_params = {} 130 | if 'resource' in local_var_params: 131 | path_params['resource'] = local_var_params['resource'] # noqa: E501 132 | if 'input' in local_var_params: 133 | path_params['input'] = local_var_params['input'] # noqa: E501 134 | 135 | query_params = [] 136 | 137 | header_params = {} 138 | 139 | form_params = [] 140 | local_var_files = {} 141 | 142 | body_params = None 143 | # HTTP header `Accept` 144 | header_params['Accept'] = self.api_client.select_header_accept( 145 | ['application/json']) # noqa: E501 146 | 147 | # Authentication setting 148 | auth_settings = ['bearerAuth'] # noqa: E501 149 | 150 | return self.api_client.call_api( 151 | '/trade/1.0.0/equity/{resource}/i/{input}', 'GET', 152 | path_params, 153 | query_params, 154 | header_params, 155 | body=body_params, 156 | post_params=form_params, 157 | files=local_var_files, 158 | response_type='object', # noqa: E501 159 | auth_settings=auth_settings, 160 | async_req=local_var_params.get('async_req'), 161 | _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 162 | _preload_content=local_var_params.get('_preload_content', True), 163 | _request_timeout=local_var_params.get('_request_timeout'), 164 | collection_formats=collection_formats, 165 | _request_auth=local_var_params.get('_request_auth')) 166 | -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | # ks_api_client 2 | No description provided 3 | 4 | - API version: 1.0.1 5 | - Package version: 1.1.0 6 | 7 | ## Requirements. 8 | 9 | Python 2.7 and 3.4+ 10 | 11 | ## Installation & Usage 12 | ### pip install 13 | 14 | If the python package is hosted on a repository, you can install directly using: 15 | 16 | ```sh 17 | pip install -e "git+https://github.com/paramatrixtech/ksapi.git#egg=ks_api_client&subdirectory=./python" 18 | ``` 19 | (you may need to run `pip` with root permission: `sudo pip install -e "git+https://github.com/paramatrixtech/ksapi.git#egg=ks_api_client&subdirectory=./python"`) 20 | 21 | Then import the package: 22 | ```python 23 | import ks_api_client 24 | ``` 25 | 26 | ### Settings configurations: 27 | - Add your configuration in settings.py file or create "settings_file" environment variable with your settings.py file path e.g. settings_file=/etc/ksapi/settings.py (for linux) or settings_file=C:\\\Users\\\ksapi\\\Desktop\\\settings.py (for Windows). 28 | - Add all the required parameters in the settings.py file, then no need to pass those paramaters during KSTradeApi object creation. 29 | 30 | 31 | ### Setuptools 32 | 33 | Install via [Setuptools](http://pypi.python.org/pypi/setuptools). 34 | 35 | ```sh 36 | python setup.py install --user 37 | ``` 38 | (or `sudo python setup.py install` to install the package for all users) 39 | 40 | Then import the package: 41 | ```python 42 | import ks_api_client 43 | ``` 44 | 45 | ## Getting Started 46 | 47 | Please follow the [installation procedure](#installation--usage) and then refer to the sample code below for various API requests: 48 | 49 | ```python 50 | from ks_api_client import ks_api 51 | # Defining the host is optional and defaults to https://sbx.kotaksecurities.com/apim 52 | # See configuration.py for a list of all supported configuration parameters. 53 | client = ks_api.KSTradeApi(access_token = "", userid = "", consumer_key = "",ip = "127.0.0.1", app_id = "test", \ 54 | host = "https://tradeapi.kotaksecurities.com/apim", consumer_secret = "") 55 | 56 | # Initiate login and generate OTT 57 | client.login(password = "") 58 | 59 | #Complete login and generate session token 60 | client.session_2fa() 61 | #You can choose to use a day-to-day access code by adding accesscode parameter : client.session_2fa(access_code = "") 62 | 63 | # Place an order. 64 | # Order_type can be "N", "MIS", "MTF". "SOR". Set variety as "AMO" for post-market orders. 65 | # Please check detailed documentation (see bottom of page) for more details on each variable. 66 | # Instrument tokens can be found at the following urls (NOTE: Please replace DD_MM_YYYY with the latest date for updated instrument tokens, for example 27_05_2021 will give tokens for 27 may): 67 | # Equity: https://preferred.kotaksecurities.com/security/production/TradeApiInstruments_Cash_DD_MM_YYYY.txt 68 | # Derivatives: https://preferred.kotaksecurities.com/security/production/TradeApiInstruments_FNO_DD_MM_YYYY.txt 69 | client.place_order(order_type = "N", instrument_token = 727, transaction_type = "BUY",\ 70 | quantity = 1, price = 0, disclosed_quantity = 0, trigger_price = 0,\ 71 | tag = "string", validity = "GFD", variety = "REGULAR") 72 | 73 | # Modify an order 74 | client.modify_order(order_id = "", price = 0, quantity = 1, disclosed_quantity = 0, trigger_price = 0, validity = "GFD") 75 | 76 | # Cancel an order 77 | client.cancel_order(order_id = "") 78 | 79 | # Get Order Book 80 | client.order_report() 81 | 82 | # Get Detailed Order Report for specific order id [equity] . 83 | client.order_report(order_id = "") 84 | 85 | # Get Detailed Order Report for specific order id [FNO] . 86 | client.order_report(order_id = "", is_fno = "Y") 87 | 88 | # Get Trade Book 89 | client.trade_report() 90 | 91 | # Get Detailed Trade Report for specific order id [equity] . 92 | client.trade_report(order_id = "") 93 | 94 | # Get Detailed Trade Report for specific order id [FNO] . 95 | client.trade_report(order_id = "", is_fno = "Y") 96 | 97 | # Get Margin required for Equity orders. 98 | order_info = [ 99 | {"instrument_token": 727, "quantity": 1, "price": 1300, "amount": 0, "trigger_price": 1190}, 100 | {"instrument_token": 1374, "quantity": 1, "price": 1200, "amount": 0, "trigger_price": 1150} 101 | ] 102 | client.margin_required(transaction_type = "BUY",order_info = order_info) 103 | 104 | # Get Available Margin 105 | client.margin() 106 | 107 | # Get Positions. position_type can be "TODAYS", "OPEN", "STOCKS". 108 | client.positions(position_type = "TODAYS") 109 | 110 | # Get Quote details. 111 | client.quote(instrument_token = "110") 112 | # Get Quotes for multiple tokens at once. Separate tokens by a hyphen. 113 | client.quote(instrument_token = "727-1250") 114 | 115 | 116 | # Websocket: 117 | 118 | # Subscribe to instrument price feed: 119 | def callback_method(message): 120 | print(message) 121 | print("Your logic/computation will come here.") 122 | client.subscribe(input_tokens="745,754", callback=callback_method) 123 | # Response structure: 124 | # ignore, ignore, Best buy price, Best buy quantity, Best sell price, Best sell quantity, Last trade price, High price, Low price, 125 | # Average trade price, Closing price, Open price, Net change percentage, Total sell quantity, Total buy quantity, Total trade qty, 126 | # Open Interest, Total trade value, Last trade quantity, Last trade time, Net change, Upper circuit limit, Lower circuit limit 127 | 128 | # Subscribe to order status update websocket 129 | # (instrument token supplied in function is merely a placeholder and serves no purpose here): 130 | def callback_method(message): 131 | print(message) 132 | print("Your logic/computation will come here.") 133 | client.subscribe(input_tokens="727", callback=callback_method, broadcast_host="https://wstreamer.kotaksecurities.com/feed/orders") 134 | 135 | 136 | # Unsubscribe from streaming service. 137 | client.unsubscribe() 138 | 139 | #Terminate user's Session 140 | client.logout() 141 | ``` 142 | ## Documentation for API Endpoints 143 | 144 | All URIs are relative to "host" parameter 145 | 146 | Class | Method | Description 147 | ------------ | ------------- | ------------- 148 | *SessionApi* | [**ks_api.KSTradeApi**](docs/SessionApi.md#session_init) | Initialise Session 149 | *SessionApi* | [**login**](docs/SessionApi.md#login) | Login using Userid 150 | *SessionApi* | [**session_2fa**](docs/SessionApi.md#session_2fa) | Generate final Session Token 151 | *OrderApi* | [**place_order**](docs/OrderApi.md#place_order) | Place a New order 152 | *OrderApi* | [**modify_order**](docs/OrderApi.md#modify_order) | Modify an existing order 153 | *OrderApi* | [**cancel_order**](docs/OrderApi.md#cancel_order) | Cancel an order 154 | *ReportsApi* | [**order_report**](docs/ReportsApi.md#order_report) | Get order report 155 | *ReportsApi* | [**trade_report**](docs/ReportsApi.md#trade_report) | Get trade report 156 | *MarginApi* | [**margin_required**](docs/MarginApi.md#margin_required) | Get Margin Required for an order by amount or quantity. 157 | *MarginApi* | [**margin**](docs/MarginApi.md#margin) | Get all calculated margins. 158 | *PositionsApi* | [**positions**](docs/PositionsApi.md#positions) | Get's Open position. 159 | *QuoteApi* | [**quote**](docs/QuoteApi.md#quote_details) | Get Quote details 160 | *StreamingApi* | [**subscribe**](docs/StreamingApi.md#subscribe) | Subscribe to streaming api of specified instrument tokens. 161 | *StreamingApi* | [**unsubscribe**](docs/StreamingApi.md#unsubscribe) | Unsubscribe from streaming api. 162 | *SessionApi* | [**logout**](docs/SessionApi.md#logout) | Invalidate Session Token 163 | 164 | 165 | -------------------------------------------------------------------------------- /python/ks_api_client/models/bracketmodify.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class Bracketmodify(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'orderIndicator': 'int', 24 | 'Spread': 'float', 25 | 'trailingPrice': 'float', 26 | 'bookProfit': 'float', 27 | 'bookDisclosedQty': 'int' 28 | } 29 | 30 | attribute_map = { 31 | 'orderIndicator': 'orderIndicator', 32 | 'Spread': 'Spread', 33 | 'trailingPrice': 'trailingPrice', 34 | 'bookProfit': 'bookProfit', 35 | 'bookDisclosedQty': 'bookDisclosedQty' 36 | } 37 | 38 | def __init__(self, orderIndicator=None, Spread=None, trailingPrice=None, bookProfit=None, bookDisclosedQty=None, local_vars_configuration=None): # noqa: E501 39 | """Bracketmodify - a model defined in OpenAPI""" # noqa: E501 40 | if local_vars_configuration is None: 41 | local_vars_configuration = Configuration() 42 | self.local_vars_configuration = local_vars_configuration 43 | 44 | self._orderIndicator = None 45 | self._Spread = None 46 | self._trailingPrice = None 47 | self._bookProfit = None 48 | self._bookDisclosedQty = None 49 | self.discriminator = None 50 | 51 | if orderIndicator is not None: 52 | self.orderIndicator = orderIndicator 53 | if Spread is not None: 54 | self.Spread = Spread 55 | if trailingPrice is not None: 56 | self.trailingPrice = trailingPrice 57 | if bookProfit is not None: 58 | self.bookProfit = bookProfit 59 | if bookDisclosedQty is not None: 60 | self.bookDisclosedQty = bookDisclosedQty 61 | 62 | @property 63 | def orderIndicator(self): 64 | """Gets the orderIndicator of this Bracketmodify. # noqa: E501 65 | 66 | Order Indicator to modify Order # noqa: E501 67 | 68 | :return: The orderIndicator of this Bracketmodify. # noqa: E501 69 | :rtype: int 70 | """ 71 | return self._orderIndicator 72 | 73 | @orderIndicator.setter 74 | def orderIndicator(self, orderIndicator): 75 | """Sets the orderIndicator of this Bracketmodify. 76 | 77 | Order Indicator to modify Order # noqa: E501 78 | 79 | :param orderIndicator: The orderIndicator of this Bracketmodify. # noqa: E501 80 | :type orderIndicator: int 81 | """ 82 | 83 | self._orderIndicator = orderIndicator 84 | 85 | @property 86 | def Spread(self): 87 | """Gets the Spread of this Bracketmodify. # noqa: E501 88 | 89 | Spread of the order # noqa: E501 90 | 91 | :return: The Spread of this Bracketmodify. # noqa: E501 92 | :rtype: float 93 | """ 94 | return self._Spread 95 | 96 | @Spread.setter 97 | def Spread(self, Spread): 98 | """Sets the Spread of this Bracketmodify. 99 | 100 | Spread of the order # noqa: E501 101 | 102 | :param Spread: The Spread of this Bracketmodify. # noqa: E501 103 | :type Spread: float 104 | """ 105 | 106 | self._Spread = Spread 107 | 108 | @property 109 | def trailingPrice(self): 110 | """Gets the trailingPrice of this Bracketmodify. # noqa: E501 111 | 112 | Triling price of TSLO Order. # noqa: E501 113 | 114 | :return: The trailingPrice of this Bracketmodify. # noqa: E501 115 | :rtype: float 116 | """ 117 | return self._trailingPrice 118 | 119 | @trailingPrice.setter 120 | def trailingPrice(self, trailingPrice): 121 | """Sets the trailingPrice of this Bracketmodify. 122 | 123 | Triling price of TSLO Order. # noqa: E501 124 | 125 | :param trailingPrice: The trailingPrice of this Bracketmodify. # noqa: E501 126 | :type trailingPrice: float 127 | """ 128 | 129 | self._trailingPrice = trailingPrice 130 | 131 | @property 132 | def bookProfit(self): 133 | """Gets the bookProfit of this Bracketmodify. # noqa: E501 134 | 135 | Book Profit Price of the order # noqa: E501 136 | 137 | :return: The bookProfit of this Bracketmodify. # noqa: E501 138 | :rtype: float 139 | """ 140 | return self._bookProfit 141 | 142 | @bookProfit.setter 143 | def bookProfit(self, bookProfit): 144 | """Sets the bookProfit of this Bracketmodify. 145 | 146 | Book Profit Price of the order # noqa: E501 147 | 148 | :param bookProfit: The bookProfit of this Bracketmodify. # noqa: E501 149 | :type bookProfit: float 150 | """ 151 | 152 | self._bookProfit = bookProfit 153 | 154 | @property 155 | def bookDisclosedQty(self): 156 | """Gets the bookDisclosedQty of this Bracketmodify. # noqa: E501 157 | 158 | Quantity to be disclosed in bracket order # noqa: E501 159 | 160 | :return: The bookDisclosedQty of this Bracketmodify. # noqa: E501 161 | :rtype: int 162 | """ 163 | return self._bookDisclosedQty 164 | 165 | @bookDisclosedQty.setter 166 | def bookDisclosedQty(self, bookDisclosedQty): 167 | """Sets the bookDisclosedQty of this Bracketmodify. 168 | 169 | Quantity to be disclosed in bracket order # noqa: E501 170 | 171 | :param bookDisclosedQty: The bookDisclosedQty of this Bracketmodify. # noqa: E501 172 | :type bookDisclosedQty: int 173 | """ 174 | 175 | self._bookDisclosedQty = bookDisclosedQty 176 | 177 | def to_dict(self): 178 | """Returns the model properties as a dict""" 179 | result = {} 180 | 181 | for attr, _ in six.iteritems(self.openapi_types): 182 | value = getattr(self, attr) 183 | if isinstance(value, list): 184 | result[attr] = list(map( 185 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 186 | value 187 | )) 188 | elif hasattr(value, "to_dict"): 189 | result[attr] = value.to_dict() 190 | elif isinstance(value, dict): 191 | result[attr] = dict(map( 192 | lambda item: (item[0], item[1].to_dict()) 193 | if hasattr(item[1], "to_dict") else item, 194 | value.items() 195 | )) 196 | else: 197 | result[attr] = value 198 | 199 | return result 200 | 201 | def to_str(self): 202 | """Returns the string representation of the model""" 203 | return pprint.pformat(self.to_dict()) 204 | 205 | def __repr__(self): 206 | """For `print` and `pprint`""" 207 | return self.to_str() 208 | 209 | def __eq__(self, other): 210 | """Returns true if both objects are equal""" 211 | if not isinstance(other, Bracketmodify): 212 | return False 213 | 214 | return self.to_dict() == other.to_dict() 215 | 216 | def __ne__(self, other): 217 | """Returns true if both objects are not equal""" 218 | if not isinstance(other, Bracketmodify): 219 | return True 220 | 221 | return self.to_dict() != other.to_dict() 222 | -------------------------------------------------------------------------------- /python/ks_api_client/models/order_info.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | 4 | import pprint 5 | import re # noqa: F401 6 | 7 | import six 8 | 9 | from ks_api_client.configuration import Configuration 10 | 11 | 12 | class OrderInfo(object): 13 | 14 | 15 | """ 16 | Attributes: 17 | openapi_types (dict): The key is attribute name 18 | and the value is attribute type. 19 | attribute_map (dict): The key is attribute name 20 | and the value is json key in definition. 21 | """ 22 | openapi_types = { 23 | 'instrumentToken': 'int', 24 | 'quantity': 'int', 25 | 'price': 'float', 26 | 'amount': 'int', 27 | 'triggerPrice': 'float' 28 | } 29 | 30 | attribute_map = { 31 | 'instrumentToken': 'instrumentToken', 32 | 'quantity': 'quantity', 33 | 'price': 'price', 34 | 'amount': 'amount', 35 | 'triggerPrice': 'triggerPrice' 36 | } 37 | 38 | def __init__(self, instrumentToken=None, quantity=None, price=None, amount=None, triggerPrice=None, local_vars_configuration=None): # noqa: E501 39 | """OrderInfo - a model defined in OpenAPI""" # noqa: E501 40 | if local_vars_configuration is None: 41 | local_vars_configuration = Configuration() 42 | self.local_vars_configuration = local_vars_configuration 43 | 44 | self._instrumentToken = None 45 | self._quantity = None 46 | self._price = None 47 | self._amount = None 48 | self._triggerPrice = None 49 | self.discriminator = None 50 | 51 | if instrumentToken is not None: 52 | self.instrumentToken = instrumentToken 53 | if quantity is not None: 54 | self.quantity = quantity 55 | if price is not None: 56 | self.price = price 57 | if amount is not None: 58 | self.amount = amount 59 | if triggerPrice is not None: 60 | self.triggerPrice = triggerPrice 61 | 62 | @property 63 | def instrumentToken(self): 64 | """Gets the instrumentToken of this OrderInfo. # noqa: E501 65 | 66 | Instrument token of the scrip to be traded.
Instrument tokens can be found at the following urls (NOTE: Please replace DD_MM_YYYY with the latest date for updated instrument tokens, for example 27_05_2021 will give tokens for 27 may):
Equity: https://preferred.kotaksecurities.com/security/production/TradeApiInstruments_Cash_DD_MM_YYYY.txt
Derivatives: https://preferred.kotaksecurities.com/security/production/TradeApiInstruments_FNO_DD_MM_YYYY.txt # noqa: E501 67 | 68 | :return: The instrumentToken of this OrderInfo. # noqa: E501 69 | :rtype: int 70 | """ 71 | return self._instrumentToken 72 | 73 | @instrumentToken.setter 74 | def instrumentToken(self, instrumentToken): 75 | """Sets the instrumentToken of this OrderInfo. 76 | 77 | Instrument token of the scrip to be traded.
Instrument tokens can be found at the following urls (NOTE: Please replace DD_MM_YYYY with the latest date for updated instrument tokens, for example 27_05_2021 will give tokens for 27 may):
Equity: https://preferred.kotaksecurities.com/security/production/TradeApiInstruments_Cash_DD_MM_YYYY.txt
Derivatives: https://preferred.kotaksecurities.com/security/production/TradeApiInstruments_FNO_DD_MM_YYYY.txt # noqa: E501 78 | 79 | :param instrumentToken: The instrumentToken of this OrderInfo. # noqa: E501 80 | :type instrumentToken: int 81 | """ 82 | 83 | self._instrumentToken = instrumentToken 84 | 85 | @property 86 | def quantity(self): 87 | """Gets the quantity of this OrderInfo. # noqa: E501 88 | 89 | Order quantity - specified in same unit as quoted in market depth # noqa: E501 90 | 91 | :return: The quantity of this OrderInfo. # noqa: E501 92 | :rtype: int 93 | """ 94 | return self._quantity 95 | 96 | @quantity.setter 97 | def quantity(self, quantity): 98 | """Sets the quantity of this OrderInfo. 99 | 100 | Order quantity - specified in same unit as quoted in market depth # noqa: E501 101 | 102 | :param quantity: The quantity of this OrderInfo. # noqa: E501 103 | :type quantity: int 104 | """ 105 | 106 | self._quantity = quantity 107 | 108 | @property 109 | def price(self): 110 | """Gets the price of this OrderInfo. # noqa: E501 111 | 112 | Order Price, non zero positive for limit order and zero for market order # noqa: E501 113 | 114 | :return: The price of this OrderInfo. # noqa: E501 115 | :rtype: float 116 | """ 117 | return self._price 118 | 119 | @price.setter 120 | def price(self, price): 121 | """Sets the price of this OrderInfo. 122 | 123 | Order Price, non zero positive for limit order and zero for market order # noqa: E501 124 | 125 | :param price: The price of this OrderInfo. # noqa: E501 126 | :type price: float 127 | """ 128 | 129 | self._price = price 130 | 131 | @property 132 | def amount(self): 133 | """Gets the amount of this OrderInfo. # noqa: E501 134 | 135 | Order Amount # noqa: E501 136 | 137 | :return: The amount of this OrderInfo. # noqa: E501 138 | :rtype: int 139 | """ 140 | return self._amount 141 | 142 | @amount.setter 143 | def amount(self, amount): 144 | """Sets the amount of this OrderInfo. 145 | 146 | Order Amount # noqa: E501 147 | 148 | :param amount: The amount of this OrderInfo. # noqa: E501 149 | :type amount: int 150 | """ 151 | 152 | self._amount = amount 153 | 154 | @property 155 | def triggerPrice(self): 156 | """Gets the triggerPrice of this OrderInfo. # noqa: E501 157 | 158 | Trigger price, required for stoploss or supermultiple order # noqa: E501 159 | 160 | :return: The triggerPrice of this OrderInfo. # noqa: E501 161 | :rtype: float 162 | """ 163 | return self._triggerPrice 164 | 165 | @triggerPrice.setter 166 | def triggerPrice(self, triggerPrice): 167 | """Sets the triggerPrice of this OrderInfo. 168 | 169 | Trigger price, required for stoploss or supermultiple order # noqa: E501 170 | 171 | :param triggerPrice: The triggerPrice of this OrderInfo. # noqa: E501 172 | :type triggerPrice: float 173 | """ 174 | 175 | self._triggerPrice = triggerPrice 176 | 177 | def to_dict(self): 178 | """Returns the model properties as a dict""" 179 | result = {} 180 | 181 | for attr, _ in six.iteritems(self.openapi_types): 182 | value = getattr(self, attr) 183 | if isinstance(value, list): 184 | result[attr] = list(map( 185 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 186 | value 187 | )) 188 | elif hasattr(value, "to_dict"): 189 | result[attr] = value.to_dict() 190 | elif isinstance(value, dict): 191 | result[attr] = dict(map( 192 | lambda item: (item[0], item[1].to_dict()) 193 | if hasattr(item[1], "to_dict") else item, 194 | value.items() 195 | )) 196 | else: 197 | result[attr] = value 198 | 199 | return result 200 | 201 | def to_str(self): 202 | """Returns the string representation of the model""" 203 | return pprint.pformat(self.to_dict()) 204 | 205 | def __repr__(self): 206 | """For `print` and `pprint`""" 207 | return self.to_str() 208 | 209 | def __eq__(self, other): 210 | """Returns true if both objects are equal""" 211 | if not isinstance(other, OrderInfo): 212 | return False 213 | 214 | return self.to_dict() == other.to_dict() 215 | 216 | def __ne__(self, other): 217 | """Returns true if both objects are not equal""" 218 | if not isinstance(other, OrderInfo): 219 | return True 220 | 221 | return self.to_dict() != other.to_dict() 222 | --------------------------------------------------------------------------------