Upstox Developer API
Project description
Upstox Python SDK for API v2
Introduction
The official Python client for communicating with the Upstox API.
Upstox 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.
- API version: v2
- Package version: 2.0.0
- Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen
This Python package is automatically generated by the Swagger Codegen project.
Documentation.
Requirements.
Python 2.7 and 3.4+
Installation & Usage
pip install
If the python package is hosted on Github, you can install directly from Github
pip install upstox-python-sdk
(you may need to run pip
with root permission: sudo pip install upstox-python-sdk
)
Then import the package:
import upstox_client
Setuptools
Install via Setuptools.
python setup.py install --user
(or sudo python setup.py install
to install the package for all users)
Then import the package:
import upstox_client
Getting Started
Please follow the installation procedure and then run the following:
from __future__ import print_function
import time
import upstox_client
from upstox_client.rest import ApiException
from pprint import pprint
# Configure OAuth2 access token for authorization: OAUTH2
configuration = upstox_client.Configuration()
configuration.access_token = 'YOUR_ACCESS_TOKEN'
# create an instance of the API class
api_instance = upstox_client.ChargeApi(upstox_client.ApiClient(configuration))
instrument_token = 'instrument_token_example' # str | Key of the instrument
quantity = 56 # int | Quantity with which the order is to be placed
product = 'product_example' # str | Product with which the order is to be placed
transaction_type = 'transaction_type_example' # str | Indicates whether its a BUY or SELL order
price = 3.4 # float | Price with which the order is to be placed
api_version = 'api_version_example' # str | API Version Header
try:
# Brokerage details
api_response = api_instance.get_brokerage(instrument_token, quantity, product, transaction_type, price, api_version)
pprint(api_response)
except ApiException as e:
print("Exception when calling ChargeApi->get_brokerage: %s\n" % e)
Documentation for API Endpoints
All URIs are relative to https://api-v2.upstox.com
Class | Method | HTTP request | Description |
---|---|---|---|
ChargeApi | get_brokerage | GET /charges/brokerage | Brokerage details |
HistoryApi | get_historical_candle_data | GET /historical-candle/{instrumentKey}/{interval}/{to_date} | Historical candle data |
HistoryApi | get_historical_candle_data1 | GET /historical-candle/{instrumentKey}/{interval}/{to_date}/{from_date} | Historical candle data |
HistoryApi | get_intra_day_candle_data | GET /historical-candle/intraday/{instrumentKey}/{interval} | Intra day candle data |
LoginApi | authorize | GET /login/authorization/dialog | Authorize API |
LoginApi | logout | DELETE /logout | Logout |
LoginApi | token | POST /login/authorization/token | Get token API |
MarketQuoteApi | get_full_market_quote | GET /market-quote/quotes | Market quotes and instruments - Full market quotes |
MarketQuoteApi | get_market_quote_ohlc | GET /market-quote/ohlc | Market quotes and instruments - OHLC quotes |
MarketQuoteApi | ltp | GET /market-quote/ltp | Market quotes and instruments - LTP quotes. |
OrderApi | cancel_order | DELETE /order/cancel | Cancel order |
OrderApi | get_order_book | GET /order/retrieve-all | Get order book |
OrderApi | get_order_details | GET /order/history | Get order details |
OrderApi | get_trade_history | GET /order/trades/get-trades-for-day | Get trades |
OrderApi | get_trades_by_order | GET /order/trades | Get trades for order |
OrderApi | modify_order | PUT /order/modify | Modify order |
OrderApi | place_order | POST /order/place | Place order |
PortfolioApi | convert_positions | PUT /portfolio/convert-position | Convert Positions |
PortfolioApi | get_holdings | GET /portfolio/long-term-holdings | Get Holdings |
PortfolioApi | get_positions | GET /portfolio/short-term-positions | Get Positions |
TradeProfitAndLossApi | get_profit_and_loss_charges | GET /trade/profit-loss/charges | Get profit and loss on trades |
TradeProfitAndLossApi | get_trade_wise_profit_and_loss_data | GET /trade/profit-loss/data | Get Trade-wise Profit and Loss Report Data |
TradeProfitAndLossApi | get_trade_wise_profit_and_loss_meta_data | GET /trade/profit-loss/metadata | Get profit and loss meta data on trades |
UserApi | get_profile | GET /user/profile | Get profile |
UserApi | get_user_fund_margin | GET /user/get-funds-and-margin | Get User Fund And Margin |
WebsocketApi | get_market_data_feed | GET /feed/market-data-feed | Market Data Feed |
WebsocketApi | get_market_data_feed_authorize | GET /feed/market-data-feed/authorize | Market Data Feed Authorize |
WebsocketApi | get_portfolio_stream_feed | GET /feed/portfolio-stream-feed | Portfolio Stream Feed |
WebsocketApi | get_portfolio_stream_feed_authorize | GET /feed/portfolio-stream-feed/authorize | Portfolio Stream Feed Authorize |
Documentation For Models
- ApiGatewayErrorResponse
- BrokerageData
- BrokerageTaxes
- BrokerageWrapperData
- CancelOrderData
- CancelOrderResponse
- ConvertPositionData
- ConvertPositionRequest
- ConvertPositionResponse
- Depth
- DepthMap
- DpPlan
- GetBrokerageResponse
- GetFullMarketQuoteResponse
- GetHistoricalCandleResponse
- GetHoldingsResponse
- GetIntraDayCandleResponse
- GetMarketQuoteLastTradedPriceResponse
- GetMarketQuoteOHLCResponse
- GetOrderBookResponse
- GetOrderResponse
- GetPositionResponse
- GetProfileResponse
- GetProfitAndLossChargesResponse
- GetTradeResponse
- GetTradeWiseProfitAndLossDataResponse
- GetTradeWiseProfitAndLossMetaDataResponse
- GetUserFundMarginResponse
- HistoricalCandleData
- HoldingsData
- IntraDayCandleData
- LogoutResponse
- MarketQuoteOHLC
- MarketQuoteSymbol
- MarketQuoteSymbolLtp
- ModifyOrderData
- ModifyOrderRequest
- ModifyOrderResponse
- OAuthClientException
- OAuthClientExceptionCause
- OAuthClientExceptionCauseStackTrace
- OAuthClientExceptionCauseSuppressed
- Ohlc
- OrderBookData
- OrderData
- OtherTaxes
- PlaceOrderData
- PlaceOrderRequest
- PlaceOrderResponse
- PositionData
- Problem
- ProfileData
- ProfitAndLossChargesData
- ProfitAndLossChargesTaxes
- ProfitAndLossChargesWrapperData
- ProfitAndLossMetaData
- ProfitAndLossMetaDataWrapper
- ProfitAndLossOtherChargesTaxes
- TokenRequest
- TokenResponse
- TradeData
- TradeWiseMetaData
- TradeWiseProfitAndLossData
- UserFundMarginData
- WebsocketAuthRedirectResponse
- WebsocketAuthRedirectResponseData
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file upstox-python-sdk-2.0.0.tar.gz
.
File metadata
- Download URL: upstox-python-sdk-2.0.0.tar.gz
- Upload date:
- Size: 73.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 541c8a8703486da06800e49f88a681c2a6ff724b6c659850f8ec596db2aecffa |
|
MD5 | 249b832a70e9bed85a3b1eacc871575a |
|
BLAKE2b-256 | 5b3322144e0e58257352b752046d176cb3c5a8e9a64245bb3716f06ca5c49c73 |