I found the Error, It was in my code ==> []
Thanks for this great platform.
Chears,
I found the Error, It was in my code ==> []
Thanks for this great platform.
Chears,
Hello,
When my python script place an order, and the order value is below the IdealPro minimum value (placing an Odd Lot Order).
Ideal pro report an error code : 399, with error message :
Warning: Your order size is below the EUR 20000 IdealPro minimum and will be routed as an odd lot order.
The order is reported as rejected by the Backtrader platform, but in reality the order seems executed.
See the log below :
2020-08-12 16:44:00,597 [MainThread ] [INFO ] [2020-08-12T03:44:00][10 seconds][Close: 1.1753][Alpha: -0.94][Lot: -75863.0][Position: -70541]
2020-08-12 16:44:00,598 [MainThread ] [INFO ] *** SELL mod: -5322.00
2020-08-12 16:44:01,355 [MainThread ] [INFO ] ********** STORE NOTIF :<error id=2258, errorCode=399, errorMsg=Order Message:
SELL 5,322 EUR.USD Forex
Warning: Your order size is below the EUR 20000 IdealPro minimum and will be routed as an odd lot order.>
2020-08-12 16:44:10,643 [MainThread ] [INFO ] *** Order Rejected
2020-08-12 16:44:10,643 [MainThread ] [INFO ] *** SELL EXECUTED, Price: 1.1752, Cost: 6254.414400000001, Comm 2.5
2020-08-12 16:44:10,644 [MainThread ] [INFO ] [2020-08-12T03:44:10][10 seconds][Close: 1.1752][Alpha: -0.94][Lot: -75863.0][Position: -75863]
As you can see the new position match the previous target lot value.
My goal is to load the positions open by backtrader in a previous run/session.
The previous positions are also opened by bt.
But the previous trades are not recognized by bt as "bt position".
Thanks for the help,
Hi,
I use Backtrader in live mode with IB.
Each time cerebro start, the trades are not initialized. So when the strategy place an order a new trade will be open.
Is there a way to initialized the trades with the position already open ?
Thanks for the help.
Alexandre
Thanks a lot @Zachary-Harris, very useful !
Hello,
When my python script place an order, and the order value is below the IdealPro minimum value (placing an Odd Lot Order).
Ideal pro report an error code : 399, with error message :
Warning: Your order size is below the EUR 20000 IdealPro minimum and will be routed as an odd lot order.
The order is reported as rejected by the Backtrader platform, but in reality the order seems executed.
See the log below :
2020-08-12 16:44:00,597 [MainThread ] [INFO ] [2020-08-12T03:44:00][10 seconds][Close: 1.1753][Alpha: -0.94][Lot: -75863.0][Position: -70541]
2020-08-12 16:44:00,598 [MainThread ] [INFO ] *** SELL mod: -5322.00
2020-08-12 16:44:01,355 [MainThread ] [INFO ] ********** STORE NOTIF :<error id=2258, errorCode=399, errorMsg=Order Message:
SELL 5,322 EUR.USD Forex
Warning: Your order size is below the EUR 20000 IdealPro minimum and will be routed as an odd lot order.>
2020-08-12 16:44:10,643 [MainThread ] [INFO ] *** Order Rejected
2020-08-12 16:44:10,643 [MainThread ] [INFO ] *** SELL EXECUTED, Price: 1.1752, Cost: 6254.414400000001, Comm 2.5
2020-08-12 16:44:10,644 [MainThread ] [INFO ] [2020-08-12T03:44:10][10 seconds][Close: 1.1752][Alpha: -0.94][Lot: -75863.0][Position: -75863]
As you can see the new position match the previous target lot value.
I found the Error, It was in my code ==> []
Thanks for this great platform.
Chears,
The resampling code :
stockkwargs = dict(
dataname='EUR.USD',
sectype='CASH',
exchange='IDEALPRO',
# timeframe=bt.TimeFrame.Seconds,
# compression=1
)
data = ibstore.getdata( **stockkwargs)
cerebro.resampledata(data, name=stockkwargs['dataname'], timeframe=bt.TimeFrame.Seconds, compression=1)
cerebro.resampledata(data, name=stockkwargs['dataname'], timeframe=bt.TimeFrame.Seconds, compression=2)
cerebro.resampledata(data, name=stockkwargs['dataname'], timeframe=bt.TimeFrame.Seconds, compression=4)
cerebro.resampledata(data, name=stockkwargs['dataname'], timeframe=bt.TimeFrame.Seconds, compression=8)
cerebro.resampledata(data, name=stockkwargs['dataname'], timeframe=bt.TimeFrame.Seconds, compression=16)
Hi,
There is something I don't understand in the behavior of my script when I resample data.
I'm resampling the same data in another time-frame with different compression values.
See below :
Server Version: 76
TWS Time at connection:20200723 14:22:55 AWST
***** DATA NOTIF: DELAYED
EUR.USD, 10, 2020-07-23 00:53:04, 1.16, compression=16
EUR.USD, 10, 2020-07-23 00:53:04, 1.16, compression=8
EUR.USD, 10, 2020-07-23 00:53:04, 1.16, compression=4
EUR.USD, 10, 2020-07-23 00:53:04, 1.16, compression=1
EUR.USD, 11, 2020-07-23 00:53:04, 1.16, compression=8
EUR.USD, 11, 2020-07-23 00:53:04, 1.16, compression=4
EUR.USD, 11, 2020-07-23 00:53:05, 1.16, compression=1
EUR.USD, 12, 2020-07-23 00:53:04, 1.16, compression=4
EUR.USD, 12, 2020-07-23 00:53:06, 1.16, compression=1
EUR.USD, 13, 2020-07-23 00:53:07, 1.16, compression=1
EUR.USD, 14, 2020-07-23 00:53:08, 1.16, compression=1
EUR.USD, 15, 2020-07-23 00:53:09, 1.16, compression=1
My understanding is the following :
in the strategy data0 will be updated every 1 second
in the strategy data1 will be updated every 2 seconds
in the strategy data2 will be updated every 4 seconds
in the strategy data3 will be updated every 8 seconds
in the strategy data4 will be updated every 16 seconds
When I log the output of the data in the next(self) of my strategy it doesn't seem to be the case :
WS Time at connection:20200723 12:11:49 AWST
***** DATA NOTIF: DELAYED
EUR.USD, 4, 2020-07-22 22:41:52, 1.16, 1.16, 1.16, 1.16, -4.00, compression=16
EUR.USD, 4, 2020-07-22 22:41:52, 1.16, 1.16, 1.16, 1.16, -4.00, compression=8
EUR.USD, 4, 2020-07-22 22:41:52, 1.16, 1.16, 1.16, 1.16, -4.00, compression=4
EUR.USD, 4, 2020-07-22 22:41:52, 1.16, 1.16, 1.16, 1.16, -2.00, compression=2
EUR.USD, 4, 2020-07-22 22:41:52, 1.16, 1.16, 1.16, 1.16, -1.00, compression=1
EUR.USD, 5, 2020-07-22 22:41:52, 1.16, 1.16, 1.16, 1.16, -2.00, compression=2
EUR.USD, 5, 2020-07-22 22:41:53, 1.16, 1.16, 1.16, 1.16, -1.00, compression=1
EUR.USD, 6, 2020-07-22 22:41:54, 1.16, 1.16, 1.16, 1.16, -2.00, compression=2
EUR.USD, 6, 2020-07-22 22:41:54, 1.16, 1.16, 1.16, 1.16, -1.00, compression=1
EUR.USD, 7, 2020-07-22 22:41:55, 1.16, 1.16, 1.16, 1.16, -1.00, compression=1
EUR.USD, 8, 2020-07-22 22:41:56, 1.16, 1.16, 1.16, 1.16, -1.00, compression=1
EUR.USD, 9, 2020-07-22 22:41:57, 1.16, 1.16, 1.16, 1.16, -1.00, compression=1
At the beginning I receive updates from the 4 compressed data.
In Live my strategy only receive data0 updates :
***** DATA NOTIF: LIVE
EUR.USD, 1801, 2020-07-23 01:22:56, 1.16, compression=1
EUR.USD, 1802, 2020-07-23 01:22:59, 1.16, compression=1
EUR.USD, 1803, 2020-07-23 01:22:59, 1.16, compression=1
EUR.USD, 1804, 2020-07-23 01:23:01, 1.16, compression=1
EUR.USD, 1805, 2020-07-23 01:23:02, 1.16, compression=1
Am I missing something ?
How can I have, on the same original data set, several data feeds with different compression values ?
Thanks for your help,