@dasch That was EXACTLY the bit of information I needed - thank you!
Could you tell me where might I have found this information for myself?
I have been using BT for a couple years for backtesting on Forex. Now I am preparing to move into live trading, using Oanda.
I'm not sure what compression does in terms of live trading. If I say I want 1-minute bars, does Oanda handle that - does it accumulate the data and send it to my system once per minute? Or does Oanda send tick data and BT (or the Oanda API) summarizes it into 1M bars?
I am planning on running my algo on multiple currency pairs and time-frames, and I want to design this for reasonable performance and minimal traffic.
And question #2 if I can...
I see a lot more documentation "out there" for BT with Interactive Brokers than for Oanda. And the Oanda interface uses their V1 API. Should I be concerned that I am using a less used, possibly less tested and maintained platform?
@leecallen Never mind -- I figured it out.
The next bar at 7:45 hits both the SL and the TP. And then I remembered: in Backtrader the order events get processed before the next() logic. And some bug in my code (I know where it is) is posting the prev-bar datetime in my logging.
And I guess I need to set up OCO or bracket orders or something so my SL and TP can't both fire.
Hi. This is a big program, I have been using it for a long time, but yesterday I discovered a problem and it's driving me crazy.
I am back-testing using Forex 5M data.
I open a BUY market order on 7/24 at 14:00.
The order Completes (opening the order) in the next bar at 14:05 at price 1.11351.
I open a stop-loss order below my executed BUY price:
self.sell( exectype=bt.Order.Stop, price=1.11194, size=self.order_size )
and a take-profit order above my executed price:
self.sell( exectype=bt.Order.Limit, price=1.11520, size=self.order_size )
Many bars go by that don't have lows below my SL or highs above my TP.
Then the next morning at 7:40 I get this bar:
Date Time Open High Low Close Volume 25.04.2019 07:40:00.000 GMT-0400,1.11243,1.11260,1.11235,1.11259,1505.38
the low is still above my SL and the high is still below my TP, but both my SL and TP orders complete!
My next() method is printing each bar so I know that's the one.
Here's a dump of my SL order -- print(order) in the notify_order for status Completed:
2019-07-25T07:40:00-04:00, 1.11416 1.11433 1.11394 1.11396 33.958517326947884 1.0 2 Ref: 41 OrdType: 1 OrdType: Sell Status: 4 Status: Completed Size: -100 Price: 1.1119400000000002 Price Limit: None TrailAmount: None TrailPercent: None ExecType: 3 ExecType: Stop CommInfo: <backtrader.comminfo.CommInfoBase object at 0x7fde4c3ad780> End of Session: 737264.9999999999 Info: AutoOrderedDict([('type', 'sl'), ('parent', 40)]) Broker: None Alive: False 2019-07-25T07:40:00-04:00, order #41 SELL completed, info AutoOrderedDict([('type', 'sl'), ('parent', 40)]) price 1.11194 size 100.00 pnl -0.16 pprice 0.00000 balance 999
Why did that SL order fire?
I'm running Backtrader 18.104.22.168
Any ideas would be hugely appreciated.
Actually I think all the information I need is here:
I will work on that. If you can pass on any additional tips I would sure appreciate them.
In each call to optstrategy my program passes a list of values for a single variable. If there are 10 values, cerebro loads the data feed only 1 time.
But I am optimizing many variables, so I must call optstrategy many times, and each time it must load the data feed.