Hello, I write below codes to submit order to buy or sell stocks. I am paper trading only.
def subscribe_updates(self): self.conn.register(r'account_updates', self.on_account_updates) self.conn.register(r'trade_updates', self.on_trade_updates) self.conn.run(['account_updates', 'trade_updates']) async def on_account_updates(self, conn, channel, data): print('account updates: ', channel, data) self.cash = data['cash'] async def on_trade_updates(self, conn, channel, data): print('order: ', data.order)
However, I found 2 issues with the above code:
- the feedback from server have a delay, I don’t think it is in realtime
- sell or buy stock only trigger trade_updates channel. In my opinion, buy stock will reduce money and sell stock will add money, why account_updates does not get triggered? Or any bugs in my code?
Thanks for your help