ejtraderLabs / ejtraderCT

The best Python Ctrader FIX API Perfect for HFT
MIT License
59 stars 20 forks source link

Get Positions only works in Debug #10

Closed dragonflyuk closed 1 year ago

dragonflyuk commented 1 year ago

I've been playing with the Python API Class, and managed to connect to my broker Pepperstone, however, my first real test is to list open positions, so I've enabled "DEBUG" logging, and used the sample code

positions = api.positions()
print(positions)

Watching the debug code the correct data is in debug logging, however the returned value is []

So then I used Thonny to step through the code, and if I step through my code, the correct data is returned and printed, however if I let the debugger simply run past the code, not result is returned.

Using Python 3.10.6 if it makes any difference.

Thanks.

traderpedroso commented 1 year ago

I've been playing with the Python API Class, and managed to connect to my broker Pepperstone, however, my first real test is to list open positions, so I've enabled "DEBUG" logging, and used the sample code

positions = api.positions()
print(positions)

Watching the debug code the correct data is in debug logging, however the returned value is []

So then I used Thonny to step through the code, and if I step through my code, the correct data is returned and printed, however if I let the debugger simply run past the code, not result is returned.

Using Python 3.10.6 if it makes any difference.

Thanks.

are you on version 1.0.6 just update to 1.0.7 pip install ejtraderCT -U ou git pull fixed on the last version

dragonflyuk commented 1 year ago

Just double checked running 1.0.7 using pip

traderpedroso commented 1 year ago

Just double checked running 1.0.7 using pip

ill open account on ppton to check, thank you and let you know as Sooners possible

dragonflyuk commented 1 year ago

I have found that if I place 1s sleep between connecting the ctrader, and calling the positions, then I get one position.

So I am now get a single position but I know there are actually 3 positions.

have you loop to get all the positions

for position in positions:
         print(position['pos_id'])