Kotak-Neo / kotak-neo-api

120 stars 112 forks source link

Is Order feed websocket available in the API ? #80

Open youngking1686 opened 1 year ago

youngking1686 commented 1 year ago

I see the below subscribe call to order feed in neo_api but don't know if it works or how to use, anyone using please throw some light.

neoapi.py --> subscribe_to_orderfeed()

aswinm227 commented 1 year ago

you may subscribe to the websocket, i think all the actions are available on it what actually you are trying to get

youngking1686 commented 1 year ago

you may subscribe to the websocket, i think all the actions are available on it what actually you are trying to get

Hi, I just want to get order status changes updated on any event from open to pending/open to completion etc, So that I can work on limit orders too.

If already available with api, please provide a sample code which I can try. Thanks.

aswinm227 commented 1 year ago

https://github.com/Kotak-Neo/kotak-neo-api/blob/main/docs/Order_report.md#order_report

youngking1686 commented 1 year ago

This is rest api call which already we use to check the order status. I am asking if there is any live order websocket which gives any order activities without having to call everytime.

aswinm227 commented 1 year ago

i think no

rosevinod commented 1 year ago

subscribe_to_orderfeed() works very well, you just need to write as follows: based on the order status, you can write your methods.


def on_message(message):
    print(f"--live--- order -- feed ----")
    message = json.loads(message)
    print(message)

def on_error(error_message):
    print(error_message)

def on_open(open_msg):
    print(open_msg)

def on_close(close_msg):
    print(close_msg)

def main():
    client = stock_main.startKotakEngineCold(on_message,on_error,on_close,on_open)   
    client.subscribe_to_orderfeed(on_message, on_close, on_error) 
crypt0inf0 commented 11 months ago

@rosevinod how to get ltp only from

inst_tokens = [ {"instrument_token": "65625", "exchange_segment": "nse_fo"} ]
ltp_value = c.subscribe(instrument_tokens = inst_tokens, isIndex=False, isDepth=False)
print(ltp_value[0].get('ltp'))

returns [{'ftm0': '04/01/1970 00:00:27', 'dtm1': '29/12/1971 15:09:28', 'fdtm': '15/12/2023 11:57:47', 'ltt': '15/12/2023 09:59:59', 'v': '14014000', 'ltp': '214.0000', 'ltq': '50', 'tbq': '143900', 'tsq': '70300', 'bp': '212.1500', 'sp': '216.0000', 'bq': '50', 'bs': '50', 'ap': '145.8300', 'lo': '97.9000', 'h': '236.9000', 'lcl': '0.0500', 'ucl': '485.6500', 'yh': '21474836.4800', 'yl': '21474836.4800', 'op': '118.0000', 'c': '94.3500', 'oi': '2795400', 'mul': '1', 'prec': '2', 'cng': '119.6500', 'nc': '126.8151', 'to': '2043661620.0000', 'name': 'sf', 'tk': '65625', 'e': 'nse_fo', 'ts': 'NIFTY23DEC21500CE'}]

rosevinod commented 11 months ago

@crypt0inf0 what do you mean?

crypt0inf0 commented 11 months ago

@rosevinod If I place a order and want to subscribe to that token to fetch the ltp and calculate the P/L and once it below a desired level I wish to close this position.