{"id":38584427,"url":"https://github.com/upstox/upstox-python","last_synced_at":"2026-01-17T08:18:03.356Z","repository":{"id":62586586,"uuid":"94565304","full_name":"upstox/upstox-python","owner":"upstox","description":"Official Python SDK for accessing Upstox API","archived":false,"fork":false,"pushed_at":"2025-11-11T12:41:07.000Z","size":499,"stargazers_count":176,"open_issues_count":7,"forks_count":123,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-11-11T14:25:24.845Z","etag":null,"topics":["python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/upstox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-06-16T17:09:16.000Z","updated_at":"2025-11-11T12:35:18.000Z","dependencies_parsed_at":"2023-12-13T14:31:53.384Z","dependency_job_id":"d021dca4-766e-43cc-9ab6-169c032a1b65","html_url":"https://github.com/upstox/upstox-python","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/upstox/upstox-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstox%2Fupstox-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstox%2Fupstox-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstox%2Fupstox-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstox%2Fupstox-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/upstox","download_url":"https://codeload.github.com/upstox/upstox-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstox%2Fupstox-python/sbom","scorecard":{"id":911522,"data":{"date":"2025-08-11","repo":{"name":"github.com/upstox/upstox-python","commit":"5682a318e6c9a72b78a3004e8037f3f80ff870af"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/semgrep.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Maintained","score":1,"reason":"2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/semgrep.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/upstox/upstox-python/semgrep.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/semgrep.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/upstox/upstox-python/semgrep.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":4,"reason":"branch protection is not maximal on development and all release branches","details":["Info: 'allow deletion' disabled on branch 'master'","Info: 'force pushes' disabled on branch 'master'","Info: 'branch protection settings apply to administrators' is required to merge on branch 'master'","Warn: 'stale review dismissal' is disabled on branch 'master'","Info: required approving review count is 2 on branch 'master'","Warn: codeowners review is required - but no codeowners file found in repo","Warn: 'last push approval' is disabled on branch 'master'","Warn: 'up-to-date branches' is disabled on branch 'master'","Info: status check found to merge onto on branch 'master'","Info: PRs are required in order to make changes on branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"15 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2025-49 / GHSA-5rjg-fvgr-3xxf","Warn: Project is vulnerable to: GHSA-cx63-2mw6-8hw5","Warn: Project is vulnerable to: PYSEC-2022-43012 / GHSA-r9hx-vwmv-q579","Warn: Project is vulnerable to: GHSA-34jh-p97f-mpxf","Warn: Project is vulnerable to: PYSEC-2023-212 / GHSA-g4mx-q9vg-27p4","Warn: Project is vulnerable to: PYSEC-2023-207 / GHSA-gwvm-45gx-3cf8","Warn: Project is vulnerable to: PYSEC-2019-133 / GHSA-mh33-7rrq-662w","Warn: Project is vulnerable to: GHSA-pq67-6m6q-mj2v","Warn: Project is vulnerable to: PYSEC-2019-132 / GHSA-r64q-w8jr-g9qp","Warn: Project is vulnerable to: PYSEC-2023-192 / GHSA-v845-jxx5-vc9f","Warn: Project is vulnerable to: PYSEC-2020-148 / GHSA-wqvq-5m8c-6g24","Warn: Project is vulnerable to: PYSEC-2018-32 / GHSA-www2-v7xj-xrc6","Warn: Project is vulnerable to: PYSEC-2021-108","Warn: Project is vulnerable to: PYSEC-2020-92 / GHSA-hj5v-574p-mj7c","Warn: Project is vulnerable to: PYSEC-2022-42969"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T19:23:25.590Z","repository_id":62586586,"created_at":"2025-08-24T19:23:25.590Z","updated_at":"2025-08-24T19:23:25.590Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28504359,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python"],"created_at":"2026-01-17T08:18:03.263Z","updated_at":"2026-01-17T08:18:03.336Z","avatar_url":"https://github.com/upstox.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Upstox Python SDK for API v2\n\n[![PyPI](https://img.shields.io/pypi/v/upstox-python-sdk?label=upstox-python-sdk)](https://pypi.python.org/pypi/upstox-python-sdk)\n\n## Introduction\n\nThe official Python client for communicating with the \u003ca href=\"https://upstox.com/uplink/\"\u003eUpstox API\u003c/a\u003e.\n\nUpstox API is a set of rest APIs that provide data required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (using Websocket), and more, with the easy to understand API collection. \n\n- API version: v2\n- Package version: 2.19.0\n- Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen\n\nThis Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project.\n\n## Documentation.\n\n\u003ca href=\"https://upstox.com/developer/api-documentation\"\u003eUpstox API Documentation\u003c/a\u003e\n\n## Requirements.\n\nPython 2.7 and 3.4+\n\n## Installation \u0026 Usage\n### pip install\n\nIf the python package is hosted on Github, you can install directly from Github\n\n```sh\npip install upstox-python-sdk\n```\n(you may need to run `pip` with root permission: `sudo pip install upstox-python-sdk`)\n\nThen import the package:\n```python\nimport upstox_client \n```\n\n### Setuptools\n\nInstall via [Setuptools](http://pypi.python.org/pypi/setuptools).\n\n```sh\npython setup.py install --user\n```\n(or `sudo python setup.py install` to install the package for all users)\n\nThen import the package:\n```python\nimport upstox_client\n```\n\n## Sandbox Mode\nWe recommend using the sandbox environment for testing purposes. To enable sandbox mode, set the `sandbox` flag to `True` in the configuration object.\n\n```python\nimport upstox_client\nfrom upstox_client.rest import ApiException\n\nconfiguration = upstox_client.Configuration(sandbox=True)\nconfiguration.access_token = 'SANDBOX_ACCESS_TOKEN'\n\napi_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))\nbody = upstox_client.PlaceOrderV3Request(quantity=1, product=\"D\",validity=\"DAY\", price=9.12, tag=\"string\", instrument_token=\"NSE_EQ|INE669E01016\", order_type=\"LIMIT\",\n                                         transaction_type=\"BUY\", disclosed_quantity=0, trigger_price=0.0, is_amo=True, slice=True)\n\ntry:\n    api_response = api_instance.place_order(body)\n    print(api_response)\nexcept ApiException as e:\n    print(\"Exception when calling OrderApi-\u003eplace_order: %s\\n\" % e)\n```\nTo learn more about the sandbox environment and the available sandbox APIs, please visit the [Upstox API documentation - Sandbox](https://upstox.com/developer/api-documentation/sandbox).\n\n## Algo Name Support\n\nThe SDK supports passing an algorithm name for order tracking and management. When provided, the SDK will pass the algo name as `X-Algo-Name` header.\n\n```python\nimport upstox_client\nfrom upstox_client.rest import ApiException\n\nconfiguration = upstox_client.Configuration()\nconfiguration.access_token = 'ACCESS_TOKEN'\n\napi_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))\nbody = upstox_client.PlaceOrderV3Request(quantity=1, product=\"D\", validity=\"DAY\", price=20, \n                                        instrument_token=\"NSE_EQ|INE528G01035\", order_type=\"LIMIT\", \n                                        transaction_type=\"BUY\", disclosed_quantity=0, trigger_price=0, \n                                        is_amo=False, slice=True)\n\ntry:\n    api_response = api_instance.place_order(body, algo_name=\"your-algo-name\")\n    print(api_response)\nexcept ApiException as e:\n    print(\"Exception when calling OrderApiV3-\u003eplace_order: %s\\n\" % e)\n```\n\nOther order methods (modify, cancel, etc.) follow the same pattern by accepting an optional `algo_name` as a keyword parameter.\n\n\n## Documentation for API Endpoints\n\n- Place, Modify, and Cancel Order APIs are relative to `https://api-hft.upstox.com`\n- All other APIs are relative to `https://api.upstox.com`\n\nAPI Name | HTTP Request | Class | Documentation | Sample Codes\n------------ | ------------- | ------------- | ------------- | -------------\n**Expired Instruments** | | | |\nGet Expiries | **GET** /v2/expired-instruments/expiries| *ExpiredInstrumentApi* | [API Reference](https://upstox.com/developer/api-documentation/get-expiries) | [Sample Code](https://upstox.com/developer/api-documentation/get-expiries#sample-code-python_sdk)\nGet Expired Option Contracts | **GET**  /v2/expired-instruments/option/contract| *ExpiredInstrumentApi* | [API Reference](https://upstox.com/developer/api-documentation/get-expired-option-contracts) | [Sample Code](https://upstox.com/developer/api-documentation/get-expired-option-contracts#sample-code-python_sdk)\nGet Expired Future Contracts | **GET** /v2/expired-instruments/future/contract| *ExpiredInstrumentApi* | [API Reference](https://upstox.com/developer/api-documentation/get-expired-future-contracts) | [Sample Code](https://upstox.com/developer/api-documentation/get-expired-future-contracts#sample-code-python_sdk)\nGet Expired Historical Candle Data | **GET** /v2/expired-instruments/historical-candle/{expired_instrument_key}/{interval}/{to_date}/{from_date}| *ExpiredInstrumentApi* | [API Reference](https://upstox.com/developer/api-documentation/get-expired-historical-candle-data) | [Sample Code](https://upstox.com/developer/api-documentation/get-expired-historical-candle-data#sample-code-python_sdk)\n**Login** | | | |\nGet Token | **POST** /v2/login/authorization/token | *LoginApi* | [API Reference](https://upstox.com/developer/api-documentation/get-token) | [Sample Code](https://upstox.com/developer/api-documentation/get-token#sample-code-python_sdk)\nAccess Token Request | **POST** /v3/login/auth/token/request/{client_id} | *LoginApi* | [API Reference](https://upstox.com/developer/api-documentation/access-token-request) | [Sample Code](https://upstox.com/developer/api-documentation/access-token-request#sample-code-python_sdk)\nLogout | **DELETE** /v2/logout | *LoginApi* | [API Reference](https://upstox.com/developer/api-documentation/logout) | [Sample Code](https://upstox.com/developer/api-documentation/logout#sample-code-python_sdk)\n**User** | | | |\nGet Profile | **GET** /v2/user/profile | *UserApi* | [API Reference](https://upstox.com/developer/api-documentation/get-profile) | [Sample Code](https://upstox.com/developer/api-documentation/get-profile#sample-code-python_sdk)\nGet User Fund Margin | **GET** /v2/user/get-funds-and-margin | *UserApi* | [API Reference](https://upstox.com/developer/api-documentation/get-user-fund-margin) | [Sample Code](https://upstox.com/developer/api-documentation/get-user-fund-margin#sample-code-python_sdk)\n**Charges** | | | |\nGet Brokerage | **GET** /v2/charges/brokerage | *ChargeApi* | [API Reference](https://upstox.com/developer/api-documentation/get-brokerage) | [Sample Code](https://upstox.com/developer/api-documentation/get-brokerage#sample-code-python_sdk)\n**Margins** | | | |\nMargin | **POST** /v2/charges/margin | *ChargeApi* | [API Reference](https://upstox.com/developer/api-documentation/margin) | [Sample Code](https://upstox.com/developer/api-documentation/margin#sample-code-python_sdk)\n**Orders** | | | |\nPlace Order V3 | **POST** /v3/order/place | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/v3/place-order) | [Sample Code](https://upstox.com/developer/api-documentation/v3/place-order#sample-code-python_sdk)\nPlace Multi Order | **POST** /v2/order/multi/place | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/place-multi-order) | [Sample Code](https://upstox.com/developer/api-documentation/place-multi-order#sample-code-python_sdk)\nModify Order V3 | **PUT** /v3/order/modify | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/v3/modify-order) | [Sample Code](https://upstox.com/developer/api-documentation/v3/modify-order#sample-code-python_sdk)\nCancel Order V3 | **DELETE** /v3/order/cancel | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/v3/cancel-order) | [Sample Code](https://upstox.com/developer/api-documentation/v3/cancel-order#sample-code-python_sdk)\nCancel Multi Order | **DELETE** /v2/order/multi/cancel | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/cancel-multi-order) | [Sample Code](https://upstox.com/developer/api-documentation/cancel-multi-order#sample-code-python_sdk)\nExit All Position | **POST** /v2/order/positions/exit | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/exit-all-positions) | [Sample Code](https://upstox.com/developer/api-documentation/exit-all-positions#sample-code-python_sdk)\nGet Order Details | **GET** /v2/order/details | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/get-order-details) | [Sample Code](https://upstox.com/developer/api-documentation/get-order-details#sample-code-python_sdk)\nGet Order History | **GET** /v2/order/history | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/get-order-history) | [Sample Code](https://upstox.com/developer/api-documentation/get-order-history#sample-code-python_sdk)\nGet Trades By Order | **GET** /v2/order/trades | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/get-trades-by-order) | [Sample Code](https://upstox.com/developer/api-documentation/get-trades-by-order#sample-code-python_sdk)\nGet Trade History | **GET** /v2/order/trades/get-trades-for-day | *OrderApi* | [API Reference](https://upstox.com/developer/api-documentation/get-trade-history) | [Sample Code](https://upstox.com/developer/api-documentation/get-trade-history#sample-code-python_sdk)\n**GTT Order** | | | |\nPlace GTT Order | **POST** /v3/order/gtt/place | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/place-gtt-order) | [Sample Code](https://upstox.com/developer/api-documentation/place-gtt-order#sample-code-python_sdk)\nModify GTT Order | **PUT** /v3/order/gtt/modify | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/modify-gtt-order) | [Sample Code](https://upstox.com/developer/api-documentation/modify-gtt-order#sample-code-python_sdk)\nCancel GTT Order | **DELETE** /v3/order/gtt/cancel | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/cancel-gtt-order) | [Sample Code](https://upstox.com/developer/api-documentation/cancel-gtt-order#sample-code-python_sdk)\nGet GTT Order Details | **GET** /v3/order/gtt | *OrderApiV3* | [API Reference](https://upstox.com/developer/api-documentation/get-gtt-order-details) | [Sample Code](https://upstox.com/developer/api-documentation/get-gtt-order-details#sample-code-python_sdk)\n**Portfolio** | | | |\nGet Positions | **GET** /v2/portfolio/short-term-positions | *PortfolioApi* | [API Reference](https://upstox.com/developer/api-documentation/get-positions) | [Sample Code](https://upstox.com/developer/api-documentation/get-positions#sample-code-python_sdk)\nGet MTF Positions | **GET** /v3/portfolio/mtf | *PortfolioApi* | [API Reference](https://upstox.com/developer/api-documentation/get-mtf-positions) | [Sample Code](https://upstox.com/developer/api-documentation/get-mtf-positions#sample-code-python_sdk)\nConvert Positions | **PUT** /v2/portfolio/convert-position | *PortfolioApi* | [API Reference](https://upstox.com/developer/api-documentation/convert-positions) | [Sample Code](https://upstox.com/developer/api-documentation/convert-positions#sample-code-python_sdk)\nGet Holdings | **GET** /v2/portfolio/long-term-holdings | *PortfolioApi* | [API Reference](https://upstox.com/developer/api-documentation/get-holdings) | [Sample Code](https://upstox.com/developer/api-documentation/get-holdings#sample-code-python_sdk)\n**Trade Profit And Loss** | | | |\nGet Report Meta Data | **GET** /v2/trade/profit-loss/metadata | *TradeProfitAndLossApi* | [API Reference](https://upstox.com/developer/api-documentation/get-report-meta-data) | [Sample Code](https://upstox.com/developer/api-documentation/get-report-meta-data#sample-code-python_sdk)\nGet Profit And Loss Report | **GET** /v2/trade/profit-loss/data | *TradeProfitAndLossApi* | [API Reference](https://upstox.com/developer/api-documentation/get-profit-and-loss-report) | [Sample Code](https://upstox.com/developer/api-documentation/get-profit-and-loss-report#sample-code-python_sdk)\nGet Trade Charges | **GET** /v2/trade/profit-loss/charges | *TradeProfitAndLossApi* | [API Reference](https://upstox.com/developer/api-documentation/get-trade-charges) | [Sample Code](https://upstox.com/developer/api-documentation/get-trade-charges#sample-code-python_sdk)\n**Historical Data** | | | |\nGet Historical Candle Data V3 | **GET** /v3/historical-candle | *HistoryV3Api* | [API Reference](https://upstox.com/developer/api-documentation/v3/get-historical-candle-data) | [Sample Code](https://upstox.com/developer/api-documentation/v3/get-historical-candle-data#sample-code-python_sdk)\nGet Intra Day Candle Data V3 | **GET** /v3/intra-day-candle | *HistoryV3Api* | [API Reference](https://upstox.com/developer/api-documentation/v3/get-intra-day-candle-data) | [Sample Code](https://upstox.com/developer/api-documentation/v3/get-intra-day-candle-data#sample-code-python_sdk)\n**Market Quote** | | | |\nGet Full Market Quote | **GET** /v2/market-quote/quotes | *MarketQuoteApi* | [API Reference](https://upstox.com/developer/api-documentation/get-full-market-quote) | [Sample Code](https://upstox.com/developer/api-documentation/get-full-market-quote#sample-code-python_sdk)\nGet Market Quote OHLC | **GET** /v2/market-quote/ohlc | *MarketQuoteApi* | [API Reference](https://upstox.com/developer/api-documentation/get-market-quote-ohlc) | [Sample Code](https://upstox.com/developer/api-documentation/get-market-quote-ohlc#sample-code-python_sdk)\nLTP V3 | **GET** /v3/market-quote/ltp | *MarketQuoteV3Api* | [API Reference](https://upstox.com/developer/api-documentation/ltp-v3) | [Sample Code](https://upstox.com/developer/api-documentation/ltp-v3#sample-code-python_sdk)\nOption Greek | **GET** /v3/market-quote/greeks | *MarketQuoteV3Api* | [API Reference](https://upstox.com/developer/api-documentation/option-greek) | [Sample Code](https://upstox.com/developer/api-documentation/option-greek#sample-code-python_sdk)\n**Market Information** | | | |\nGet Market Holidays | **GET** /v2/market/holidays | *MarketHolidaysAndTimingsApi* | [API Reference](https://upstox.com/developer/api-documentation/get-market-holidays) | [Sample Code](https://upstox.com/developer/api-documentation/get-market-holidays#sample-code-python_sdk)\nGet Market Timings | **GET** /v2/market/timings | *MarketHolidaysAndTimingsApi* | [API Reference](https://upstox.com/developer/api-documentation/get-market-timings) | [Sample Code](https://upstox.com/developer/api-documentation/get-market-timings#sample-code-python_sdk)\nGet Market Status | **GET** /v2/market/status | *MarketHolidaysAndTimingsApi* | [API Reference](https://upstox.com/developer/api-documentation/get-market-status) | [Sample Code](https://upstox.com/developer/api-documentation/get-market-status#sample-code-python_sdk)\n**Option Chain** | | | |\nGet Option Contracts | **GET** /v2/option/contract | *OptionsApi* | [API Reference](https://upstox.com/developer/api-documentation/get-option-contracts) | [Sample Code](https://upstox.com/developer/api-documentation/get-option-contracts#sample-code-python_sdk)\nGet PC Option Chain | **GET** /v2/option/chain | *OptionsApi* | [API Reference](https://upstox.com/developer/api-documentation/get-pc-option-chain) | [Sample Code](https://upstox.com/developer/api-documentation/get-pc-option-chain#sample-code-python_sdk)\n\n## Documentation for Feeder Functions\n\nConnecting to the WebSocket for market and portfolio updates is streamlined through two primary Feeder functions:\n\n1. **MarketDataStreamer**: Offers real-time market updates, providing a seamless way to receive instantaneous information on various market instruments.\n2. **PortfolioDataStreamer**: Delivers updates related to the user's orders, enhancing the ability to track order status and portfolio changes effectively.\n\nBoth functions are designed to simplify the process of subscribing to essential data streams, ensuring users have quick and easy access to the information they need.\n\n### Detailed Explanation of Feeder Interface\n\n### MarketDataStreamer\n\n\nThe `MarketDataStreamerV3` interface is designed for effortless connection to the market WebSocket, enabling users to receive instantaneous updates on various instruments. The following example demonstrates how to quickly set up and start receiving market updates for selected instrument keys:\n\n```python\nimport upstox_client\n\ndef on_message(message):\n    print(message)\n\n\ndef main():\n    configuration = upstox_client.Configuration()\n    access_token = \u003cACCESS_TOKEN\u003e\n    configuration.access_token = access_token\n\n    streamer = upstox_client.MarketDataStreamerV3(\n        upstox_client.ApiClient(configuration), [\"NSE_INDEX|Nifty 50\", \"NSE_INDEX|Nifty Bank\"], \"full\")\n\n    streamer.on(\"message\", on_message)\n\n    streamer.connect()\n\n\nif __name__ == \"__main__\":\n    main()\n```\nIn this example, you first authenticate using an access token, then instantiate MarketDataStreamerV3 with specific instrument keys and a subscription mode. Upon connecting, the streamer listens for market updates, which are logged to the console as they arrive.\n\nFeel free to adjust the access token placeholder and any other specifics to better fit your actual implementation or usage scenario.\n\n### Exploring the MarketDataStreamerV3 Functionality\n\n#### Modes\n- **ltpc**: ltpc provides information solely about the most recent trade, encompassing details such as the last trade price, time of the last trade, quantity traded, and the closing price from the previous day.\n- **full**: The full option offers comprehensive information, including the latest trade prices, D5 depth, 1-minute, 30-minute, and daily candlestick data, along with some additional details. \n- **option_greeks**: Contains only option greeks.\n- **full_d30**: full_d30 includes Full mode data plus 30 market level quotes.      \n\n#### Functions\n1. **constructor MarketDataStreamerV3(apiClient, instrumentKeys, mode)**: Initializes the streamer with optional instrument keys and mode (`full`, `ltpc`, `option_greeks` or `full_d30`).\n2. **connect()**: Establishes the WebSocket connection.\n3. **subscribe(instrumentKeys, mode)**: Subscribes to updates for given instrument keys in the specified mode. Both parameters are mandatory.\n4. **unsubscribe(instrumentKeys)**: Stops updates for the specified instrument keys.\n5. **changeMode(instrumentKeys, mode)**: Switches the mode for already subscribed instrument keys.\n6. **disconnect()**: Ends the active WebSocket connection.\n7. **auto_reconnect(enable, interval, retryCount)**: Customizes auto-reconnect functionality. Parameters include a flag to enable/disable it, the interval(in seconds) between attempts, and the maximum number of retries.\n\n#### Events\n- **open**: Emitted upon successful connection establishment.\n- **close**: Indicates the WebSocket connection has been closed.\n- **message**: Delivers market updates.\n- **error**: Signals an error has occurred.\n- **reconnecting**: Announced when a reconnect attempt is initiated.\n- **autoReconnectStopped**: Informs when auto-reconnect efforts have ceased after exhausting the retry count.\n\nThe following documentation includes examples to illustrate the usage of these functions and events, providing a practical understanding of how to interact with the MarketDataStreamerV3 effectively.\n\n\u003cbr/\u003e\n\n1. Subscribing to Market Data on Connection Open with MarketDataStreamerV3\n\n```python\nimport upstox_client\n\ndef main():\n    configuration = upstox_client.Configuration()\n    access_token = \u003cACCESS_TOKEN\u003e\n    configuration.access_token = access_token\n\n    streamer = upstox_client.MarketDataStreamerV3(\n        upstox_client.ApiClient(configuration))\n\n    def on_open():\n        streamer.subscribe(\n            [\"NSE_EQ|INE020B01018\", \"NSE_EQ|INE467B01029\"], \"full\")\n\n    def on_message(message):\n        print(message)\n\n    streamer.on(\"open\", on_open)\n    streamer.on(\"message\", on_message)\n\n    streamer.connect()\n\nif __name__ == \"__main__\":\n    main()\n```\n\n\u003cbr/\u003e\n\n2. Subscribing to Instruments with Delays\n\n```python\nimport upstox_client\nimport time\n\n\ndef main():\n    configuration = upstox_client.Configuration()\n    access_token = \u003cACCESS_TOKEN\u003e\n    configuration.access_token = access_token\n\n    streamer = upstox_client.MarketDataStreamerV3(\n        upstox_client.ApiClient(configuration))\n\n    def on_open():\n        streamer.subscribe(\n            [\"NSE_EQ|INE020B01018\"], \"full\")\n\n    # Handle incoming market data messages\\\n    def on_message(message):\n        print(message)\n\n    streamer.on(\"open\", on_open)\n    streamer.on(\"message\", on_message)\n\n    streamer.connect()\n\n    time.sleep(5)\n    streamer.subscribe(\n        [\"NSE_EQ|INE467B01029\"], \"full\")\n\n\nif __name__ == \"__main__\":\n    main()\n\n```\n\n\u003cbr/\u003e\n\n3. Subscribing and Unsubscribing to Instruments\n\n```python\nimport upstox_client\nimport time\n\n\ndef main():\n    configuration = upstox_client.Configuration()\n    access_token = \u003cACCESS_TOKEN\u003e\n    configuration.access_token = access_token\n\n    streamer = upstox_client.MarketDataStreamerV3(\n        upstox_client.ApiClient(configuration))\n\n    def on_open():\n        print(\"Connected. Subscribing to instrument keys.\")\n        streamer.subscribe(\n            [\"NSE_EQ|INE020B01018\", \"NSE_EQ|INE467B01029\"], \"full\")\n\n    # Handle incoming market data messages\\\n    def on_message(message):\n        print(message)\n\n    streamer.on(\"open\", on_open)\n    streamer.on(\"message\", on_message)\n\n    streamer.connect()\n\n    time.sleep(5)\n    print(\"Unsubscribing from instrument keys.\")\n    streamer.unsubscribe([\"NSE_EQ|INE020B01018\", \"NSE_EQ|INE467B01029\"])\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n\u003cbr/\u003e\n\n4. Subscribe, Change Mode and Unsubscribe\n\n```python\nimport upstox_client\nimport time\n\ndef main():\n    configuration = upstox_client.Configuration()\n    access_token = \u003cACCESS_TOKEN\u003e\n    configuration.access_token = access_token\n\n    streamer = upstox_client.MarketDataStreamerV3(\n        upstox_client.ApiClient(configuration))\n\n    def on_open():\n        print(\"Connected. Subscribing to instrument keys.\")\n        streamer.subscribe(\n            [\"NSE_EQ|INE020B01018\", \"NSE_EQ|INE467B01029\"], \"full\")\n\n    # Handle incoming market data messages\\\n    def on_message(message):\n        print(message)\n\n    streamer.on(\"open\", on_open)\n    streamer.on(\"message\", on_message)\n\n    streamer.connect()\n\n    time.sleep(5)\n    print(\"Changing subscription mode to ltpc...\")\n    streamer.change_mode(\n        [\"NSE_EQ|INE020B01018\", \"NSE_EQ|INE467B01029\"], \"ltpc\")\n\n    time.sleep(5)\n    print(\"Unsubscribing from instrument keys.\")\n    streamer.unsubscribe([\"NSE_EQ|INE020B01018\", \"NSE_EQ|INE467B01029\"])\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n\u003cbr/\u003e\n\n5. Disable Auto-Reconnect\n\n```python\nimport upstox_client\nimport time\n\n\ndef main():\n    configuration = upstox_client.Configuration()\n    access_token = \u003cACCESS_TOKEN\u003e\n    configuration.access_token = access_token\n\n    streamer = upstox_client.MarketDataStreamerV3(\n        upstox_client.ApiClient(configuration))\n\n    def on_reconnection_halt(message):\n        print(message)\n\n    streamer.on(\"autoReconnectStopped\", on_reconnection_halt)\n\n    # Disable auto-reconnect feature\n    streamer.auto_reconnect(False)\n\n    streamer.connect()\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n\u003cbr/\u003e\n\n6. Modify Auto-Reconnect parameters\n\n```python\nimport upstox_client\n\n\ndef main():\n    configuration = upstox_client.Configuration()\n    access_token = \u003cACCESS_TOKEN\u003e\n    configuration.access_token = access_token\n\n    streamer = upstox_client.MarketDataStreamerV3(\n        upstox_client.ApiClient(configuration))\n\n    # Modify auto-reconnect parameters: enable it, set interval to 10 seconds, and retry count to 3\n    streamer.auto_reconnect(True, 10, 3)\n\n    streamer.connect()\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n\u003cbr/\u003e\n\n\n### PortfolioDataStreamer\n\nConnecting to the Portfolio WebSocket for real-time order updates is straightforward with the PortfolioDataStreamer function. Below is a concise guide to get you started on receiving updates:\n\n```python\nimport upstox_client\n\ndef on_message(message):\n    print(message)\n\n\ndef main():\n    configuration = upstox_client.Configuration()\n    access_token = \u003cACCESS_TOKEN\u003e\n    configuration.access_token = access_token\n\n    streamer = upstox_client.PortfolioDataStreamer(\n        upstox_client.ApiClient(configuration))\n\n    streamer.on(\"message\", on_message)\n\n    streamer.connect()\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\u003cbr/\u003e\n\nPosition, holding, and GTT order updates can be enabled by setting the corresponding flag to `True` in the constructor of the `PortfolioDataStreamer` class.\n\n```python\nimport upstox_client\nimport data_token\n\n\ndef on_message(message):\n    print(message)\n\n\ndef on_open():\n    print(\"connection opened\")\n\n\ndef main():\n    configuration = upstox_client.Configuration()\n    configuration.access_token = \u003cACCESS_TOKEN\u003e\n\n    streamer = upstox_client.PortfolioDataStreamer(upstox_client.ApiClient(configuration),\n                                                  order_update=True,\n                                                  position_update=True,\n                                                  holding_update=True,\n                                                  gtt_update=True)\n\n    streamer.on(\"message\", on_message)\n    streamer.on(\"open\", on_open)\n    streamer.connect()\n\n\nif __name__ == \"__main__\":\n    main()\n\n```\n\n\u003cbr/\u003e\n\n### Exploring the PortfolioDataStreamer Functionality\n\n#### Constructor Parameters\n1. **api_client**: Your API client instance\n2. **order_update**: Set to `True` to receive real-time order updates (default: `True`)\n3. **position_update**: Set to `True` to receive position updates (default: `False`) \n4. **holding_update**: Set to `True` to receive holding updates (default: `False`)\n5. **gtt_update**: Set to `True` to receive GTT order updates (default: `False`)\n\n#### Functions\n1. **constructor PortfolioDataStreamer()**: Initializes the streamer.\n2. **connect()**: Establishes the WebSocket connection.\n6. **disconnect()**: Ends the active WebSocket connection.\n7. **auto_reconnect(enable, interval, retryCount)**: Customizes auto-reconnect functionality. Parameters include a flag to enable/disable it, the interval(in seconds) between attempts, and the maximum number of retries.\n\n#### Events\n- **open**: Emitted upon successful connection establishment.\n- **close**: Indicates the WebSocket connection has been closed.\n- **message**: Delivers market updates.\n- **error**: Signals an error has occurred.\n- **reconnecting**: Announced when a reconnect attempt is initiated.\n- **autoReconnectStopped**: Informs when auto-reconnect efforts have ceased after exhausting the retry count.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupstox%2Fupstox-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fupstox%2Fupstox-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupstox%2Fupstox-python/lists"}