Shoonya-Dev / ShoonyaApi-py

139 stars 132 forks source link

Get lts and quotes #61

Open bibinvargheset opened 1 year ago

bibinvargheset commented 1 year ago

if there was a function to get ltps and quotes of a list of instruments it would be very helpful for strategy implementations

def ltp( self, *instruments) Retrieve last price for list of instruments.

instruments is a list of instruments, Instrument are in the format of exchange:tradingsymbol. For example NSE:INFY

https://kite.trade/docs/pykiteconnect/v3/#kiteconnect.KiteConnect.ltp

williamzerner commented 1 year ago

You can get ltp by streaming the data using test_realtime.py and store it in csv which is located in the test folder. And then use another program to read the data stored with the help of pandas. To get in the format NSE:INFY... i have no clue but again you can use pandas to create your own format

bibinvargheset commented 1 year ago

You can get ltp by streaming the data using test_realtime.py and store it in csv which is located in the test folder. And then use another program to read the data stored with the help of pandas. To get in the format NSE:INFY... i have no clue but again you can use pandas to create your own format

What are you replying to my issue was how to fetch multiple signal quotes /ltp in one call, I am not asking about realtime streaming please read the issue before repling

williamzerner commented 1 year ago

What are you replying to my issue was how to fetch multiple signal quotes /ltp in one call, I am not asking about realtime streaming please read the issue before repling

you can use get_time_series function and then get the close of the latest candle. That will be your ltp. If you are asking about an inbuilt function , it doesnt exist.

bibinvargheset commented 1 year ago

Yes, thats why we are asking to create one, which will be very helpful for many API implementation and will reduce time delay and server calls as it is implemented in most other leading broker apis, like zerodha, upstocks , samco etc,

DeepBhuptani commented 1 year ago
instruments = ['NSE:INFY','NSE:INFY','NSE:INFY']
for n in range(len(instruments)):
    symbl = api.searchscrip(exchange = instruments[n][:3], searchtext = instruments[n][4:])
    tokn = symbl['values'][0]['token']
    print(api.get_quotes(exchange = instruments[n][:3], token = tokn)['lp'])
bibinvargheset commented 1 year ago
instruments = ['NSE:INFY','NSE:INFY','NSE:INFY']
for n in range(len(instruments)):
    symbl = api.searchscrip(exchange = instruments[n][:3], searchtext = instruments[n][4:])
    tokn = symbl['values'][0]['token']
    print(api.get_quotes(exchange = instruments[n][:3], token = tokn)['lp'])

are you trying to demonstrate what python has for loops or how inefficient the current solution is by using the for loop it will take forever to get multiple quotes.

CosmicTrader commented 1 year ago

Agree with bibinvargheset, this feature is very helpful when you are trading options specially highly volatiles ones like index, fetching prices for more individually is costly both in terms of time and server calls. Team SHOONYA please make this feature available. And there bugs in many other APIs, please try to solve them fast.