A Package designed for connecting to a Stock Broker that uses Symphony Fintech Solutions Pvt. Ltd for there API.
Project description
Introduction
- This package is written to be used as a XTS API Client in Python.
- With the correct API credentials, User can access XTS interactive & market data.
Reference
-
This is a python client package for XTS API. XTS is product from Symphony Fintech Solutions Pvt. Ltd.. The original documentation for XTS Clinet is linked here.
-
This package is a derivative work of the original package written by Symphony Fintech Solutions Pvt. Ltd..
-
Link for original GitHub Repository. It takes inspirations from the original, however it differs in the implimentation.
Package Structure
- To better consume the package, the user should have a clear understanding of the architecture of the package.
Here is the folder structure of the project:
└───xts_api_client
│ interactive_socket.py
│ interactive_socket_client.py
│ market_data_socket.py
│ market_data_socket_client.py
│ py.typed
│ xts_connect.py
│ xts_connect_async.py
│ xts_exception.py
│ __init__.py
│
├───helper
helper.py
helper_classes.py
__init__.py
There are two version of xts_connect. A synchronous version & an asynchronous version.
xts_connect.py
- This module is written for simple test cases & basic understanding of the API, however in practical cases, user will have to use asynchronous methods.
xts_connect_async.py
- For all intensive purposes, this module will be used only because of the nature of application.
Getting Started
- The user should have API Key, API Secret Key & the URL with Port details for using this package.
- XTS API is a REST based Trading API with Socket IO streaming component. This client makes it easier to consume the data from API into Python.
- In XTS, there are two types of API, one for trading (interactive sessions) & one for market data.
Trading API
- Trading APIs allows to integrate trading system with XTS Platform for placing orders, monitor your positions, manage your portfolio and much more.
Market Data API
- Market Data API is a mixed HTTP REST and HTTP streaming API. It provides access to live quotes data on a wide range of symbols.
Steps to use the Package
- Here's an example code block that loads API credentials from environment variables and uses them to log in to a MarketData API. It has been explained in subsequest steps.
import os
from dotenv import load_dotenv
load_dotenv()
API_key = os.getenv("API_KEY")
API_secret = os.getenv("API_SECRET")
API_source = os.getenv("API_SOURCE")
API_root = os.getenv("API_URL")
"""""""""""""""""""""""""""""""""""""""
|DataDrame for Cash Market|
"""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect_async import XTSConnect
from xts_api_client.helper.helper import cm_master_string_to_df
import asyncio
async def main():
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = await xt_market_data.marketdata_login()
market_data_get_master = await xt_market_data.get_master(
exchangeSegmentList = [xt_market_data.EXCHANGE_NSECM] # Works for BSECM as well.
)
print((cm_master_string_to_df(market_data_get_master['result'])))
if __name__ == "__main__":
asyncio.run(main())
""""""""""""""""""""""""""""""""""""""""""
Step 1. Instantiate XTS class into object before login.
- Import class 'XTSConnect' & then instantiate it as shown.
- Write your apikey, secretkey, source & root. Root is the URL with port included.
from xts_api_client.xts_connect_async import XTSConnect
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
Step 2. Logging in.
- As mentioned earlier, there are two types of API in XTS. The below example is for market data API.
- After instantiating XTSConnect. Use the method marketdata login to log in & access data.
response_marketdata_login = await xt_market_data.marketdata_login()
If the credentials are correct, printing 'response_marketdata_login' will five a JSON like following.
{'type': 'success', 'code': 'e-response-0010', 'description': 'Provided Valid Credentials', 'result': {'token': data removed, 'userID': data removed, 'appVersion': data removed, 'application_expiry_date': data removed}}
Step 3. Getting Configuration.
- Once you have logged in through market_data_API, you can get the configuration for the market data.
market_data_get_config = await xt_market_data.get_config()
Printing the 'market_data_get_config' will give JSON like following.
{'type': 'success', 'code': 's-response-0001', 'description': 'Fetched configurations successfully', 'result': __{'exchangeSegments': {'NSECM': 1, 'NSEFO': 2, 'NSECD': 3, 'NSECO': 4, 'SLBM': 5, 'NIFSC': 7, 'BSECM': 11, 'BSEFO': 12, 'BSECD': 13, 'BSECO': 14, 'NCDEX': 21, 'MSECM': 41, 'MSEFO': 42, 'MSECD': 43, 'MCXFO': 51}__, 'xtsMessageCode': {'touchlineEvent': 1501, 'marketDepthEvent': 1502, 'indexDataEvent': 1504, 'candleDataEvent': 1505, 'openInterestEvent': 1510, 'instrumentPropertyChangeEvent': 1105, 'ltpEvent': 1512}, 'publishFormat': ['Binary', 'JSON'], 'broadCastMode': ['Full', 'Partial'], 'instrumentType': {'1': 'Futures', '2': 'Options', '4': 'Spread', '8': 'Equity', '16': 'Spot', '32': 'PreferenceShares', '64': 'Debentures', '128': 'Warrants',
'256': 'Miscellaneous', '512': 'MutualFund', 'Futures': 1, 'Options': 2, 'Spread': 4, 'Equity': 8, 'Spot': 16, 'PreferenceShares': 32, 'Debentures': 64, 'Warrants': 128, 'Miscellaneous': 256, 'MutualFund': 512}}}
Step 4. Getting the Master Data.
- XTS provides API Call to fetch all tradable as well as some additional Instrument/contract masters in a single structure.
- This call can be made once in a day and the response can be persisted in local storage or file as per you application design and you can fetch instrumented or Symbols from this dataset throughout the day.
- The type of master is a dictionary, that contains all the data sepearted by "|".
- The parameter 'exchangeSegmentList' takes a list of exchange segments. In XTS, NSE has few segments as shown in the cofig output above.
market_data_get_master = await xt_market_data.get_master(
exchangeSegmentList = [xt_market_data.EXCHANGE_NSECM] # Works for BSECM as well.
)
- Both above & below code will give same result.
market_data_get_master = await xt_market_data.get_master(
exchangeSegmentList = ['NSECM']
)
A snippet of print of market_data_get_master.
...nNSECM|11369|8|TTKHLTCARE|TTKHLTCARE-EQ|EQ|TTKHLTCARE-EQ|1100100011369|1798.7|1199.2|66709|0.05|1|1|TTKHLTCARE|INE910C01018|1|1|TTK HEALTHCARE LIMITED-EQ|0|-1|-1\nNSECM|20364|8|771KL43|771KL43-SG|SG|771KL43-SG|1100100020364|102.37|92.62|1025599|0.01|100|1|771KL43|IN2020230172|1|1|SDL KL 7.71% 2043-SG|0|-1|-1\nNSECM|21711|8|68PN26|68PN26-SG|SG|68PN26-SG|1100100021711|108.7|98.35|965899|0.01|100|1|68PN26|IN2820200052|1|1|SDL PN 6.8% 2026-SG|0|-1|-1'}
Step 5. Getting the OHLC Data.
- The data is available in the form of a candle timestamp with epoch from 1970, Open, High, Low, Close, Volume, OI.
- The least compression available is 60(1 minute) for both event stream and long polling (GET at 1 Request Per Second).
- Other supported intervals for GET (long polling ) Request are 2 minute, 3 minutes, 5 minutes, 15 minutes, 30 minutes , hourly and daily.
- Format of startTime & endTime is "MMM DD YYYY HHMMSS". In the example given below 091500 means morning nine fifteen in IST. Market open time :-) .
marget_data_get_ohlc = await xt_market_data.get_ohlc(
exchangeSegment = xt_market_data.EXCHANGE_NSECM,
exchangeInstrumentID = 22,
startTime = "Dec 02 2024 091500",
endTime = "Dec 02 2024 093000",
compressionValue = 60)
Printing market_data_get_ohlc will give a dictionary, as shown below.
{'type': 'success', 'code': 's-instrument-0002', 'description': 'Data found', 'result': {'exchangeSegment': 'NSECM', 'exchangeInstrumentID': '22', 'dataReponse': DELETED FOR DATA PRIVACY}}
Helper Functions/Methods available in package.
- Helper function are written inside the package to serve as an example to end user on how to use the package.
- Examples for both synchronous & asynchronous versions are shown.
XTS_Helper
cm_master_string_to_df:
Converts the response of cm_master API to a pandas DataFrame. This function takes a string response from the cm_master API, which contains data separated by the '|' character, and converts it into a pandas DataFrame. The DataFrame will have predefined column headers.
Parameters: cm_master_result of string type : The string response from the cm_master API.
Returns: pd.DataFrame: A pandas DataFrame containing the parsed data from the cm_master_result string.
"""""""""""""""""""""""""""""""""""""""
|DataDrame for Cash Market|
"""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect_async import XTSConnect
from xts_api_client.helper.helper import cm_master_string_to_df
import asyncio
async def main():
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = await xt_market_data.marketdata_login()
market_data_get_master = await xt_market_data.get_master(
exchangeSegmentList = [xt_market_data.EXCHANGE_NSECM] # Works for BSECM as well.
)
print((cm_master_string_to_df(market_data_get_master['result'])))
if __name__ == "__main__":
asyncio.run(main())
""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
|DataDrame for Cash Market|
"""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect import XTSConnect
from xts_api_client.helper.helper import cm_master_string_to_df
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = xt_market_data.marketdata_login()
market_data_get_master = xt_market_data.get_master(
exchangeSegmentList = [xt_market_data.EXCHANGE_NSECM] # Works for BSECM as well
)
print(cm_master_string_to_df(market_data_get_master['result']))
""""""""""""""""""""""""""""""""""""""""""
fo_master_string_to_df:
Converts the response of master API to pandas DataFrame for fo segment. This function takes a string response from the fo_master API, splits it into lines, and then categorizes each line into futures or options based on the number of columns. It then converts these categorized lines into pandas DataFrames with appropriate column headers.
Parameters: fo_master_result of string type : The string response from the fo_master API.
Returns: tuple: A tuple containing three pandas DataFrames:
fut_master_df: DataFrame containing futures data.
opt_master_df: DataFrame containing options data.
fut_spread_df: DataFrame Containing future spread data.
"""""""""""""""""""""""""""""""""""""""
|Tuple of DataDrame for FO Market|
"""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect_async import XTSConnect
from xts_api_client.helper.helper import fo_master_string_to_df
import asyncio
async def main():
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = await xt_market_data.marketdata_login()
market_data_get_master = await xt_market_data.get_master(
exchangeSegmentList = [xt_market_data.EXCHANGE_BSEFO] # Works for BSECM as well.
)
"""
future_master_df = fo_master_string_to_df(market_data_get_master['result'])
print(future_master_df[0]) # This will give DataFrame for Future.
options_master_df = fo_master_string_to_df(market_data_get_master['result'])
print(options_master_df[1]) # This will give DataFrame for Options.
future_master_df = fo_master_string_to_df(market_data_get_master['result'])
print(future_master_df[2]) # This will give DataFrame for Spread.
"""
print((fo_master_string_to_df(market_data_get_master['result'])))
if __name__ == "__main__":
asyncio.run(main())
""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
|Tuple of DataDrame for FO Market|
"""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect import XTSConnect
from xts_api_client.helper.helper import fo_master_string_to_df
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = xt_market_data.marketdata_login()
market_data_get_master = xt_market_data.get_master(
exchangeSegmentList = [xt_market_data.EXCHANGE_NSEFO] # Works for BSECM as well.
)
"""
future_master_df = fo_master_string_to_df(market_data_get_master['result'])
print(future_master_df[0]) # This will give DataFrame for Future.
options_master_df = fo_master_string_to_df(market_data_get_master['result'])
print(options_master_df[1]) # This will give DataFrame for Options.
fut_spread_df = fo_master_string_to_df(market_data_get_master['result'])
print(fut_spread_df[2]) # This will give DataFrame for Options.
"""
print(fo_master_string_to_df(market_data_get_master['result']))
""""""""""""""""""""""""""""""""""""""""""
cm_master_df_to_xts_cm_instrument_list:
Converts the pandas DataFrame of cm_master API to list of xts_cm_Instrument objects.
Parameters: cm_master_df with pd.DataFrame type & series_list_to_include with list type. Example of List ["EQ","BE","BZ","SM","A","B"].
Returns: list of XTS Cash Market Instruments.
"""""""""""""""""""""""""""""""""""""""
|List of InstrumentID for Cash Market|
"""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect_async import XTSConnect
from xts_api_client.helper.helper import cm_master_string_to_df, cm_master_df_to_xts_cm_instrument_list
import asyncio
async def main():
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = await xt_market_data.marketdata_login()
market_data_get_master = await xt_market_data.get_master(
exchangeSegmentList = [xt_market_data.EXCHANGE_NSECM] # Works for BSE as well.
)
#User can swap NSEFO with BSEFO if needed.
cm_master_df = cm_master_string_to_df(market_data_get_master['result'])
cm_instrument_list=cm_master_df_to_xts_cm_instrument_list(
cm_master_df = cm_master_df,
series_list_to_include = ["EQ","BE","BZ","SM","A","B"] # "EQ","BE","BZ" Are for NSE & "SM","A","B" are for BSE.
)
print(cm_instrument_list)
if __name__ == "__main__":
asyncio.run(main())
""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
|List of InstrumentID for Cash Market|
"""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect import XTSConnect
from xts_api_client.helper.helper import cm_master_string_to_df, cm_master_df_to_xts_cm_instrument_list
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = xt_market_data.marketdata_login()
market_data_get_master = xt_market_data.get_master(
exchangeSegmentList = [xt_market_data.EXCHANGE_NSECM] # Works for BSE as well.
)
#User can swap NSEFO with BSEFO if needed.
cm_master_df = cm_master_string_to_df(market_data_get_master['result'])
cm_instrument_list=cm_master_df_to_xts_cm_instrument_list(
cm_master_df = cm_master_df,
series_list_to_include = ["EQ","BE","BZ","SM","A","B"] # "EQ","BE","BZ" Are for NSE & "SM","A","B" are for BSE.
)
print(cm_instrument_list)
""""""""""""""""""""""""""""""""""""""""""
fo_master_df_to_xts_future_instrument_list:
Converts the pandas DataFrame of fo_master API to list of xts_future_Instrument objects.
Parameters: fo_master_df with pd.DataFrame type & series_list_to_include with list type. Example of List ["FUTIDX","FUTSTK","IF"].
Returns: list of XTS Futures Instruments.
"""""""""""""""""""""""""""""""""""""""""""""
|List of Instrument Id for Future Contracts|
"""""""""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect_async import XTSConnect
from xts_api_client.helper.helper import fo_master_string_to_df, fo_master_df_to_xts_future_instrument_list
import asyncio
async def main():
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = await xt_market_data.marketdata_login()
market_data_get_master = await xt_market_data.get_master(
exchangeSegmentList = [xt_market_data.EXCHANGE_NSEFO] # Works for BSE as well.
)
fo_master_df = fo_master_string_to_df(market_data_get_master['result'])
future_instrument_list = fo_master_df_to_xts_future_instrument_list(fo_master_df[0],
series_list_to_include = ["FUTIDX","FUTSTK","IF"] # "FUTIDX","FUTSTK" are for NSE & "IF" is for BSE.
)
print(future_instrument_list)
if __name__ == "__main__":
asyncio.run(main())
""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""
|List of Instrument Id for Future Contracts|
"""""""""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect import XTSConnect
from xts_api_client.helper.helper import fo_master_string_to_df, fo_master_df_to_xts_future_instrument_list
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = xt_market_data.marketdata_login()
market_data_get_master = xt_market_data.get_master(
exchangeSegmentList = [xt_market_data.EXCHANGE_NSEFO] # Works for BSE as well.
)
fo_master_df = fo_master_string_to_df(market_data_get_master['result'])
future_instrument_list = fo_master_df_to_xts_future_instrument_list(fo_master_df[0],
series_list_to_include = ["FUTIDX","FUTSTK","IF"] # "FUTIDX","FUTSTK" are for NSE & "IF" is for BSE.
)
print(future_instrument_list)
""""""""""""""""""""""""""""""""""""""""""
fo_master_df_to_xts_options_instrument_list:
Converts the pandas DataFrame of fo_master API to list of xts_optoins_Instrument objects
Parameters: fo_master_df with pd.DataFrame type & series_list_to_include with list type. Example of List : ["OPTIDX","OPTSTK","IO"].
Returns: list of XTS Options Instruments.
"""""""""""""""""""""""""""""""""""""""""""""
|List of Instrument Id for Options Contracts|
"""""""""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect_async import XTSConnect
from xts_api_client.helper.helper import fo_master_string_to_df, fo_master_df_to_xts_options_instrument_list
import asyncio
async def main():
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = await xt_market_data.marketdata_login()
market_data_get_master = await xt_market_data.get_master(
exchangeSegmentList = [xt_market_data.EXCHANGE_NSEFO] # Works for BSE as well.
)
#User can swap NSEFO with BSEFO if needed.
fo_master_df = fo_master_string_to_df(market_data_get_master['result'])
options_instrument_list = fo_master_df_to_xts_options_instrument_list(fo_master_df[1],
series_list_to_include = ["OPTIDX","OPTSTK","IO"] # "OPTIDX","OPTSTK" are for NSE & "IO" is for BSE.
)
print(options_instrument_list)
if __name__ == "__main__":
asyncio.run(main())
""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""
|List of Instrument Id for Options Contracts|
"""""""""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect import XTSConnect
from xts_api_client.helper.helper import fo_master_string_to_df, fo_master_df_to_xts_options_instrument_list
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = xt_market_data.marketdata_login()
market_data_get_master = xt_market_data.get_master(
exchangeSegmentList = [xt_market_data.EXCHANGE_NSEFO] # Works for BSE as well.
)
#User can swap NSEFO with BSEFO if needed.
fo_master_df = fo_master_string_to_df(market_data_get_master['result'])
options_instrument_list = fo_master_df_to_xts_options_instrument_list(fo_master_df[1],
series_list_to_include = ["OPTIDX","OPTSTK","IO"] # "OPTIDX","OPTSTK" are for NSE & "IO" is for BSE.
)
print(options_instrument_list)
""""""""""""""""""""""""""""""""""""""""""
ohlc_to_df:
Converts XTS-API(from XTS.Connect.get_ohlc()) generated OHLC data to pandas DataFrame.
Parameters: The return of XTS.Connect.get_ohlc() method with dictionary type. Example of dict : {'type': 'success', 'code': 's-instrument-0002', 'description': 'Data found', 'result': {'exchangeSegment': 'NSECM', 'exchangeInstrumentID': '22', 'dataReponse': 'data removed'}} Returns: A pd.DataFrame from the OHLC values.
"""""""""""""""""""""""""""""""""""""""
|OHLC for Cash Market|
"""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect_async import XTSConnect
from xts_api_client.helper.helper import ohlc_to_df
import asyncio
async def main():
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = await xt_market_data.marketdata_login()
marget_data_get_ohlc = await xt_market_data.get_ohlc(
exchangeSegment = xt_market_data.EXCHANGE_NSECM, # Also Works for BSECM
exchangeInstrumentID = 22, # When using BSECM, Use BSE instrument Id like "526530"
startTime = "Dec 02 2024 091500", #Time in IST
endTime = "Dec 02 2024 133000", #Time in IST, 24 hour clock.
compressionValue = 60) # 60 represents 1 minute. Check Documentation for different values.
# Change the values oh OHLC parameters as required.
ohlc_df = ohlc_to_df(marget_data_get_ohlc)
print(ohlc_df)
if __name__ == "__main__":
asyncio.run(main())
""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
|OHLC for Cash Market|
"""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect import XTSConnect
from xts_api_client.helper.helper import ohlc_to_df
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = xt_market_data.marketdata_login()
marget_data_get_ohlc = xt_market_data.get_ohlc(
exchangeSegment = xt_market_data.EXCHANGE_NSECM, # Also Works for BSECM
exchangeInstrumentID = 22, # When using BSECM, Use BSE instrument Id like "526530"
startTime = "Dec 02 2024 091500", #Time in IST
endTime = "Dec 02 2024 133000", #Time in IST, 24 hour clock.
compressionValue = 60) # 60 represents 1 minute. Check Documentation for different values.
# Change the values oh OHLC parameters as required.
ohlc_df = ohlc_to_df(marget_data_get_ohlc)
print(ohlc_df)
""""""""""""""""""""""""""""""""""""""""""
equityticker_exchangeInstrumentId_dict:
Converts XTS-API DataFrame (generated from XTS.Connect.get_master() with helper functoin cm_master_string_to_df/fo_master_string_to_df) to a dictionary. So that user can search Instrument Id with ticker symbol. IT ONLY WORKS FOR CASH MARKET.
Parameters: The return of cm_master_string_to_df/fo_master_string_to_df methods with the pd.DataFrame type. Returns: A Dictionary containing Ticker Symbol as keys & Exchange Instrument Id as values.
"""""""""""""""""""""""""""""""""""""""""""""""""""
|Ticker:ExchangeInstrumentId Dict for Cash Market|
"""""""""""""""""""""""""""""""""""""""""""""""""""
from xts_api_client.xts_connect import XTSConnect
from xts_api_client.helper.helper import cm_master_string_to_df
from xts_api_client.helper.helper import ticker_exchangeInstrumentId_dict
xt_market_data = XTSConnect(
apiKey = API_key,
secretKey = API_secret,
source = API_source,
root = API_root
)
response_marketdata_login = xt_market_data.marketdata_login()
market_data_get_master = xt_market_data.get_master(exchangeSegmentList = [xt_market_data.EXCHANGE_NSECM]) # Works for BSECM as well.
cm_master_df = cm_master_string_to_df(market_data_get_master['result'])
ticker_exchInstrumentID_dict = ticker_exchangeInstrumentId_dict(cm_master_df)
print(ticker_exchInstrumentID_dict.get('RELIANCE')) # Reliance is kept here as an example. User can print "ticker_exchInstrumentID_dict" for full data.
""""""""""""""""""""""""""""""""""""""""""
dostime_secomds_to_unixtime:
Converts the MS DOS time that is used by NSE & BSE to Unix epoch time. * The MS-DOS time/date format uses midnight on January 1, 1980 as a sentinel value, or epoch. * Unix epoch starts from midnight on January 1, 1970. The function also allowes to add timezone info to the converted time. by default it will add the timezone info of Asia/Kolkata. IMPORTANT: Adding timezone info makes the time aware about time zone. but the value of Uniux will remain UNCHNAGED!
Parameters: ms dos time in seconds. Returns: Time in unix epoch.
from xts_api_client.helper.helper import dostime_secomds_to_unixtime
print(dostime_secomds_to_unixtime(1420378549, "UTC"))
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xts_api_client-0.1.3.tar.gz.
File metadata
- Download URL: xts_api_client-0.1.3.tar.gz
- Upload date:
- Size: 15.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e3b7d521679d463c9d54b11bb9bd274a6c3b460dc8d7346f963093a7cc41350
|
|
| MD5 |
8ac49ac23ef83ac75c4f8ce4c25e7b26
|
|
| BLAKE2b-256 |
9aacf5559c1d4666c7d2edd5a575407e5e24412fc09608f4ea47af74c80e5e21
|
File details
Details for the file xts_api_client-0.1.3-py3-none-any.whl.
File metadata
- Download URL: xts_api_client-0.1.3-py3-none-any.whl
- Upload date:
- Size: 29.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b5451f437442b578a0b8a8cc135a72e536b331ea78a6fac615d8ab8089ac372
|
|
| MD5 |
f9efbb5186f8ca6bae71290784ef483b
|
|
| BLAKE2b-256 |
b02488b615ae26259573ff7a1aa4c8fee9f03a207ef794a07431481740c8d512
|