update postbacks are asynchronous - they'll come in random order for a given order.
its recommended that for every postback you call the api orderbook and verify the status yourself.
It is impossible for them to be skipped on a conditional basis. They are just lines inside a function that has no if statement or return or anything that could cause the lines to skip over.
@sujith Thanks for letting me know. I just reviewed the code and it turns out I had mistakenly put get_positions() such that it was getting called with every tick! Yeah, no wonder I got the walls of errors. The requests should dramatically reduce no…
Whats 200?
7-10k requests in what context? Is it orders? That averages at about 30-70.
Or are you talking about the number of times on_ticks() method is called? If thats what you say, then yes, but thats only because I have set get_positions() t…
@sujith @rakeshr I havent been polling kite.positions() for past 2-3 months now. Only call it once at the beginning and after an order is placed. As I mentioned, this has shown results, however, there are occasions, though rare, when it acts up and…
@SRIJAN There's literally a try-except block at the start of this thread. @rakeshr @sujith Is what Srijan said true? The issue is on my end here? Because I think its not. As Sujith has asked me multiple times before to not poll positions, since that…
And only re-fetch the position, if there is new orders placed i.e new position created.
This is what I am doing right now @rakeshr . I call kite.positions() at the very start and have it stored in a variable. I then only call kite.positions() when …
Hello @rakeshr I have a delay of sleep(0.2) incase there's the error comes up. What amount of delay do you recommend?
1. In your view is it possible to keep track of positions live, without ever calling kite.positions()?
2. I know there's on_orde…
Hello @sujith, I hope its ok to use this old thread as my question relates.
I have changed the code and now it only calls on kite.positions() when there is a kite.place_order() above it, meaning, only after the algo has ordered something, I call p…
@sujith
This is my on_order_update. I have also initialised it with buts not been working since the last time posted here. You have said that I will receive an update when its executed, but I am still getting nothing. There is no "data" from the o…
Got it.
I did place this in the algo today and initialised it with this
kws.on_order_update = on_order_update.
Yet there's nothing. No log entered in my log file as the "data" and on_order_update_list is empty. What could have happened here?
Since you're recommending websockets @SRIJAN as a viable alternative (which I will be happy to use btw, since it has less chance to throw the timeout error), kindly explain how do I go about actually implementing it when it is asynchronous? My algo …
I see. If thats the case then just calling kite.order_history(order_id) seems easier? @SRIJAN
And following this, this means that it still cant be fully relied upon as a position tracker, am I right?
yea, my bad, place_orders return the order_id. Now I know.
However, do you think that it might have gotten stuck somewhere in the api calls, order_history() or orders() in the above mentioned case? @sujith
@SRIJAN When you say its asynchronous, do you mean that an order is placed, its open and then complete, I might get complete as an update first and then open?
I had no idea one could get order_id from kite.place_orders() method. Will you guide how I can do that? I was under the impression that it just needs what type of order to place and what instrument to trade and thats it.
To get to order_id, one ne…
This is my retrieve order id funtion. It just readjusts the list and from kite.orders and gets me that id. Do I add a timer in here to avoid this from happening?
How do I tackle the kite.order_history() tho?
That is fine! I have things coded to wait 10 seconds after an order is placed, and if not placed, then its fine too. That part is covered and tested.
Thats not the issue, the issue that the code after "placed buy..." did not follow through. The log…
This is not the first time the algo has behaved unexpectedly during the starting seconds of the market. Sometimes, it skips some parts of a function altogether, but when restarted later, it works just as expected. Why is this?
I see. Using kite.ltp() is definitely preferable because thats what I am already doing. But it also gets called with every tick. I am wondering if that will also become an issue like kite.positions() did.
Thank you @rakeshr . I will check it out and revert if I have any queries.
I also checked out the thread that Mr Sujith provided in his initial response about the P&L. The formula there is > pnl = (sellValue - buyValue) + (netQuantity * …
@sujith @SRIJAN I have made some changes. I will see the performance for a few days and let you know how it goes. If theres an issue, should I continue on this thread itself? Kindly advice Sujith. Thanks.
Just positions API. How would I go about knowing whether I have a good stable network or not? My average upload and download speed is 120 Mbps, so speed is not an issue. How do I determine the stability?
I use kite.ltp() to see the P&L positions periodically. Is that ok or does that need some changing too?
> We would suggest you to use postbacks or order updates via websockets as events to fetch positions API.
Could you please link an API d…
I think I solved it. Basically had to import _thread then used _thread.interrupt_main() when i wanted the program to end and added kws.connect() to a try-except block for a neat exit -- is this ok?
Hello @rakeshr, the linked thread does not address my concerns.
I call kite.positions() outside the websocket code. I have also gotten the same error messages there as well. I dealt with them using the while-try-except method and it has handled …
Hello @sujith
In your linked thread, it says that the net = margin available. However, at the time when I called the margins API method, I had a decent amount in my Zerodha account, however it just showed 0 as you can see in the image. How to …
Clear view of the code and the error I get in the console
The console returns this, for further context:
runfile('/Users/apple/Desktop/AT/streaming_tick_data.py', wdir='/Users/apple/Desktop/AT')
Connection error: 1006 - connection was closed u…
yes, that is the entire error traceback. It repeats after every 3 or so seconds. I am contacting my IT team regarding the firewall and will let you know whats up asap
@sujith @rakeshr
I run into this issue immediately upon running. Its an home office network, I will contact my IT team tomorrow to see if the firewall thats in place is interfering with the connection the code is trying to make - is the firewall the reason for this…