From 924490b42de927fa1192ad295b3e8c70964d9f41 Mon Sep 17 00:00:00 2001 From: Rakesh R Date: Fri, 16 Jul 2021 11:04:19 +0530 Subject: [PATCH 1/8] feat: remove enum32 deps from install require --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 6af2020b..495098cd 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,6 @@ "requests>=2.18.4", "six>=1.11.0", "pyOpenSSL>=17.5.0", - "enum34>=1.1.6", "python-dateutil>=2.6.1", "autobahn[twisted]==19.11.2" ], From 14b8017debd34e9dd0343b6d635db70827e623f5 Mon Sep 17 00:00:00 2001 From: Vivek R Date: Mon, 9 Jan 2023 13:46:15 +0530 Subject: [PATCH 2/8] upgrade version to v4.2.0 --- kiteconnect/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kiteconnect/__version__.py b/kiteconnect/__version__.py index 00a47bf3..b8304b60 100644 --- a/kiteconnect/__version__.py +++ b/kiteconnect/__version__.py @@ -2,7 +2,7 @@ __description__ = "The official Python client for the Kite Connect trading API" __url__ = "https://kite.trade" __download_url__ = "https://github.com/zerodhatech/pykiteconnect" -__version__ = "4.1.0" +__version__ = "4.2.0" __author__ = "Zerodha Technology Pvt. Ltd. (India)" __author_email__ = "talk@zerodha.tech" __license__ = "MIT" From f9469a5b95930888d93be0b1b6368423c6e7e7ca Mon Sep 17 00:00:00 2001 From: Rakesh R Date: Mon, 31 Jul 2023 12:34:22 +0530 Subject: [PATCH 3/8] feat: add virtual contract note API --- examples/order_margins.py | 45 ++++++++++++++++++++++++++++++++- kiteconnect/connect.py | 12 ++++++++- tests/helpers/utils.py | 3 ++- tests/mock_responses | 2 +- tests/unit/test_connect.py | 52 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 110 insertions(+), 4 deletions(-) diff --git a/examples/order_margins.py b/examples/order_margins.py index 078bfdcb..abba2ff1 100644 --- a/examples/order_margins.py +++ b/examples/order_margins.py @@ -28,7 +28,7 @@ }] margin_detail = kite.order_margins(order_param_single) - logging.info("Required margin for single order: {}".format(order_param_single)) + logging.info("Required margin for single order: {}".format(margin_detail)) # Fetch margin detail for list of orders order_param_multi = [{ @@ -92,3 +92,46 @@ except Exception as e: logging.info("Error fetching order margin: {}".format(e)) + + +# Fetch virtual contract note charges +try: + order_book_params = [ + { + "order_id": "111111111", + "exchange": "NSE", + "tradingsymbol": "SBIN", + "transaction_type": "BUY", + "variety": "regular", + "product": "CNC", + "order_type": "MARKET", + "quantity": 1, + "average_price": 560 + }, + { + "order_id": "2222222222", + "exchange": "MCX", + "tradingsymbol": "GOLDPETAL23AUGFUT", + "transaction_type": "SELL", + "variety": "regular", + "product": "NRML", + "order_type": "LIMIT", + "quantity": 1, + "average_price": 5862 + }, + { + "order_id": "3333333333", + "exchange": "NFO", + "tradingsymbol": "NIFTY23AUG17900PE", + "transaction_type": "BUY", + "variety": "regular", + "product": "NRML", + "order_type": "LIMIT", + "quantity": 100, + "average_price": 1.5 + }] + + order_book_charges = kite.get_virtual_contract_note(order_book_params) + logging.info("Virtual contract note charges: {}".format(order_book_charges)) +except Exception as e: + logging.info("Error fetching virtual contract note charges: {}".format(e)) \ No newline at end of file diff --git a/kiteconnect/connect.py b/kiteconnect/connect.py index c3f49974..399f406f 100644 --- a/kiteconnect/connect.py +++ b/kiteconnect/connect.py @@ -161,7 +161,8 @@ class KiteConnect(object): # Margin computation endpoints "order.margins": "/margins/orders", - "order.margins.basket": "/margins/basket" + "order.margins.basket": "/margins/basket", + "order.contract_note": "/charges/orders", } def __init__(self, @@ -786,6 +787,15 @@ def basket_order_margins(self, params, consider_positions=True, mode=None): is_json=True, query_params={'consider_positions': consider_positions, 'mode': mode}) + def get_virtual_contract_note(self, params): + """ + Calculates detailed charges order-wise for the order book + - `params` is list of orders to fetch charges detail + """ + return self._post("order.contract_note", + params=params, + is_json=True) + def _warn(self, message): """ Add deprecation warning message """ warnings.simplefilter('always', DeprecationWarning) diff --git a/tests/helpers/utils.py b/tests/helpers/utils.py index a035d81e..f58d7d28 100644 --- a/tests/helpers/utils.py +++ b/tests/helpers/utils.py @@ -45,7 +45,8 @@ # Order margin & charges "order.margins": "order_margins.json", - "order.margins.basket": "basket_margins.json" + "order.margins.basket": "basket_margins.json", + "order.contract_note": "virtual_contract_note.json" } diff --git a/tests/mock_responses b/tests/mock_responses index 02d0831c..0dd520a4 160000 --- a/tests/mock_responses +++ b/tests/mock_responses @@ -1 +1 @@ -Subproject commit 02d0831c44d30a9f4ac647a3a2c89b3c0279f317 +Subproject commit 0dd520a4b2d871d599920b0fbb7ba2c158499b93 diff --git a/tests/unit/test_connect.py b/tests/unit/test_connect.py index 3f312382..e6b1ba23 100644 --- a/tests/unit/test_connect.py +++ b/tests/unit/test_connect.py @@ -417,3 +417,55 @@ def test_basket_order_margins(kiteconnect): assert margin_detail['orders'][0]['type'] == "equity" # Order charges assert margin_detail['orders'][0]['total'] != 0 + +@responses.activate +def test_virtual_contract_note(kiteconnect): + """ Test virtual contract note charges """ + responses.add( + responses.POST, + "{0}{1}".format(kiteconnect.root, kiteconnect._routes["order.contract_note"]), + body=utils.get_response("order.contract_note"), + content_type="application/json" + ) + + order_book_params = [{ + "order_id": "111111111", + "exchange": "NSE", + "tradingsymbol": "SBIN", + "transaction_type": "BUY", + "variety": "regular", + "product": "CNC", + "order_type": "MARKET", + "quantity": 1, + "average_price": 560 + }, + { + "order_id": "2222222222", + "exchange": "MCX", + "tradingsymbol": "GOLDPETAL23JULFUT", + "transaction_type": "SELL", + "variety": "regular", + "product": "NRML", + "order_type": "LIMIT", + "quantity": 1, + "average_price": 5862 + }, + { + "order_id": "3333333333", + "exchange": "NFO", + "tradingsymbol": "NIFTY2371317900PE", + "transaction_type": "BUY", + "variety": "regular", + "product": "NRML", + "order_type": "LIMIT", + "quantity": 100, + "average_price": 1.5 + }] + + order_book_charges = kiteconnect.get_virtual_contract_note(order_book_params) + # Order charges + assert order_book_charges[0]['charges']['transaction_tax_type'] == "stt" + assert order_book_charges[0]['charges']['total'] != 0 + # CTT tax type + assert order_book_charges[1]['charges']['transaction_tax_type'] == "ctt" + assert order_book_charges[1]['charges']['total'] != 0 From 415326854c0e4e80d269b0155d9f8e8859e195c2 Mon Sep 17 00:00:00 2001 From: Rakesh R Date: Mon, 31 Jul 2023 12:55:31 +0530 Subject: [PATCH 4/8] chore: remove CI support for py 2.7 --- .github/workflows/test-conda.yml | 2 +- .github/workflows/test.yml | 8 +------- setup.py | 1 - 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-conda.yml b/.github/workflows/test-conda.yml index f5c5d968..9d500ad6 100644 --- a/.github/workflows/test-conda.yml +++ b/.github/workflows/test-conda.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: os: ["ubuntu-20.04", "windows-latest"] - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, "3.10"] + python-version: [3.5, 3.6, 3.7, 3.8, 3.9, "3.10"] steps: - uses: conda-incubator/setup-miniconda@v2 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 04e583af..cf5b906b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,13 +9,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, windows-latest] - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, "3.10", pypy2, pypy3] - exclude: - - os: windows-latest - python-version: pypy3 - - os: windows-latest - python-version: pypy2 - + python-version: [3.5, 3.6, 3.7, 3.8, 3.9, "3.10"] steps: - uses: actions/checkout@v2 with: diff --git a/setup.py b/setup.py index 495098cd..7518f3c0 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,6 @@ "Programming Language :: Python", "Natural Language :: English", "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", From faf8dd81627331997d25ec548bec6012af9ef36f Mon Sep 17 00:00:00 2001 From: Rakesh R Date: Mon, 31 Jul 2023 16:04:17 +0530 Subject: [PATCH 5/8] feat: update version and readme for 5.0.0-beta release --- README.md | 10 ++++++++-- kiteconnect/__version__.py | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0ed56119..3ad3f718 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,14 @@ Kite Connect is a set of REST-like APIs that expose many capabilities required t ## v4 - Breaking changes -* Renamed ticker fields as per [kite connect doc](https://kite.trade/docs/connect/v3/websocket/#quote-packet-structure) -* Renamed `bsecds` to `bcd` in `ticker.EXCHANGE_MAP` +- Renamed ticker fields as per [kite connect doc](https://kite.trade/docs/connect/v3/websocket/#quote-packet-structure) +- Renamed `bsecds` to `bcd` in `ticker.EXCHANGE_MAP` + +## v5 - Breaking changes + +- **Drop Support for Python 2.7**: Starting from version v5, support for Python 2.7 has been discontinued. This decision was made due to the [announcement](https://github.com/actions/setup-python/issues/672) by `setup-python`, which stopped supporting Python 2.x since May 2023. + +- **For Python 2.x Users**: If you are using Python 2.x, you can continue using the `kiteconnect` library, but please stick to the <= 4.x.x versions of the library. You can find the previous releases on the [PyKiteConnect GitHub Releases](https://github.com/zerodha/pykiteconnect/releases) page. ## Installing the client diff --git a/kiteconnect/__version__.py b/kiteconnect/__version__.py index b8304b60..c51c8730 100644 --- a/kiteconnect/__version__.py +++ b/kiteconnect/__version__.py @@ -2,7 +2,7 @@ __description__ = "The official Python client for the Kite Connect trading API" __url__ = "https://kite.trade" __download_url__ = "https://github.com/zerodhatech/pykiteconnect" -__version__ = "4.2.0" +__version__ = "5.0.0-beta" __author__ = "Zerodha Technology Pvt. Ltd. (India)" __author_email__ = "talk@zerodha.tech" __license__ = "MIT" From ca308944714910feb64124e71bffba6bf53d9eae Mon Sep 17 00:00:00 2001 From: Vivek R Date: Mon, 16 Oct 2023 12:20:39 +0530 Subject: [PATCH 6/8] Update version to v5.0.0 --- kiteconnect/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kiteconnect/__version__.py b/kiteconnect/__version__.py index c51c8730..75bd39e1 100644 --- a/kiteconnect/__version__.py +++ b/kiteconnect/__version__.py @@ -2,7 +2,7 @@ __description__ = "The official Python client for the Kite Connect trading API" __url__ = "https://kite.trade" __download_url__ = "https://github.com/zerodhatech/pykiteconnect" -__version__ = "5.0.0-beta" +__version__ = "5.0.0" __author__ = "Zerodha Technology Pvt. Ltd. (India)" __author_email__ = "talk@zerodha.tech" __license__ = "MIT" From be7e02eae10507e481ccbc1e322b45ebaae92cc9 Mon Sep 17 00:00:00 2001 From: Rakesh R Date: Wed, 7 Feb 2024 12:43:38 +0530 Subject: [PATCH 7/8] fix: remove ping text from sendPing instead of binary --- .github/workflows/test-conda.yml | 4 ++++ dev_requirements.txt | 1 + kiteconnect/ticker.py | 4 ---- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-conda.yml b/.github/workflows/test-conda.yml index 9d500ad6..b011076f 100644 --- a/.github/workflows/test-conda.yml +++ b/.github/workflows/test-conda.yml @@ -24,6 +24,10 @@ jobs: - uses: actions/checkout@v2 with: submodules: true +<<<<<<< HEAD +======= + +>>>>>>> ef49655... fix: downgrade urllib3 version to support openSSL in workflow - name: Install dependencies shell: bash -l {0} run: | diff --git a/dev_requirements.txt b/dev_requirements.txt index 8ba38ee0..718d8a71 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -3,3 +3,4 @@ responses>=0.12.1 pytest-cov>=2.10.1 flake8>=3.8.4, <= 4.0.1 mock>=3.0.5 +urllib3<2.0 \ No newline at end of file diff --git a/kiteconnect/ticker.py b/kiteconnect/ticker.py index d906313e..ad858d7e 100644 --- a/kiteconnect/ticker.py +++ b/kiteconnect/ticker.py @@ -32,7 +32,6 @@ class KiteTickerClientProtocol(WebSocketClientProtocol): PING_INTERVAL = 2.5 KEEPALIVE_INTERVAL = 5 - _ping_message = "" _next_ping = None _next_pong_check = None _last_pong_time = None @@ -107,14 +106,11 @@ def onPong(self, response): # noqa def _loop_ping(self): # noqa """Start a ping loop where it sends ping message every X seconds.""" if self.factory.debug: - log.debug("ping => {}".format(self._ping_message)) if self._last_ping_time: log.debug("last ping was {} seconds back.".format(time.time() - self._last_ping_time)) # Set current time as last ping time self._last_ping_time = time.time() - # Send a ping message to server - self.sendPing(self._ping_message) # Call self after X seconds self._next_ping = self.factory.reactor.callLater(self.PING_INTERVAL, self._loop_ping) From 9f7d42dc1d167cfd87064eb70482720e3bdf2dc9 Mon Sep 17 00:00:00 2001 From: Rakesh R Date: Wed, 7 Feb 2024 15:07:05 +0530 Subject: [PATCH 8/8] fix: downgrade urllib3 version to support openSSL in workflow --- .github/workflows/test-conda.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test-conda.yml b/.github/workflows/test-conda.yml index b011076f..9d500ad6 100644 --- a/.github/workflows/test-conda.yml +++ b/.github/workflows/test-conda.yml @@ -24,10 +24,6 @@ jobs: - uses: actions/checkout@v2 with: submodules: true -<<<<<<< HEAD -======= - ->>>>>>> ef49655... fix: downgrade urllib3 version to support openSSL in workflow - name: Install dependencies shell: bash -l {0} run: |