krishnavelu / alice_blue

Official Python library for Alice Blue API trading
GNU General Public License v3.0
134 stars 82 forks source link

Last Traded Time (ltt) parameter is missing in the LiveFeedType.DEPTH_DATA response? #477

Closed PythonNovice5 closed 2 years ago

PythonNovice5 commented 2 years ago

I executed both LiveFeedType.DEPTH_DATA and LiveFeedType.TICK_DATA, but couldn't find the last traded time which is ltt. Am I doing something wrong?

Please help, as 'ltt (last traded time)' is really important parameter to design various time frame candles in algorithmic trading. In previous version of Aliceblue , this parameter was available.

krishnavelu commented 2 years ago

It's available as last_traded_time in data dict.

https://github.com/krishnavelu/alice_blue/blob/master/alice_blue/alice_blue.py#L435

PythonNovice5 commented 2 years ago

'last_traded_time' is not returned when I am executing the following code:

def event_handler_quote_update(message):

    print("FULL MESSAGE --------",message)

def open_callback():
    global socket_opened
    socket_opened = True

print("Execution starts here ...1")
alice.start_websocket(subscribe_callback=event_handler_quote_update,
                      socket_open_callback=open_callback)

while True:
    alice.subscribe(alice.get_instrument_by_token('NSE', '26000'), LiveFeedType.DEPTH_DATA)

Output

FULL MESSAGE -------- {'ml': '1', 'instrument': Instrument(exchange='NSE', token=26000, symbol=None, name=None, expiry=None, lot_size=None), 'ltp': 17314.65, 'percent_change': -0.1, 'close': 17331.8, 'tick_incr
ement': 0.05, 'lot_size': 1, 'price_precision': 2, 'bid_prices': [None, None, None, None, None], 'ask_prices': [None, None, None, None, None], 'bid_quantities': [None, None, None, None, None], 'ask_quantities':
 [None, None, None, None, None], 'buy_orders': [None, None, None, None, None], 'sell_orders': [None, None, None, None, None]}

I need nifty live feed with ltp and ltt, can you please help here?

PythonNovice5 commented 2 years ago

Hi Krishna,

I think I didn't get exchange time stamp as the market was closed yesterday, I ran the code for both TICK and DEPTH and got the exchange time stamp without any issues. And this time it's coming in acceptable format unlike the old one.

Thank you for the support, closing this issue!