@backtrader said in Implement stop loss:
No, under buy_price, because your are talking about stop-loss (you are in the market), people will understand the price at which you bought your asset and not the expected (and yet unknown) price at which the next order, the stop-loss one will execute.
Got this. I've declared a new variable which is store buy_price and updates it in notify order method with order.executed.price.
@scottz1 said in My Orders dont get Closed (wrong implementation of SL/TP?):
Looks ok basically. However,
remember to add logic for partial fills so the tp/sl orders will have the correct size.
remember to check existing position so as not to overwrite self.order and end up doubling your position.
One of the latest additions lets you do direct time comparisons directly to lines to generate signals. Probably nobody has used it yet. An example:
lines = ('mysignal',)
self.lines.mysignal = self.data.datetime > datetime.time(10, 30)
This generates an indicator which can be used as a signal to only execute orders when the daily time goes over 10:30.
But since you are probably looking for day, you'll need to work it out in the next method comparing the self.data.datetime.date() (maybe even getting the weekday) against something of your choosing
@Harel-Rozental said in Smart optimizations and Backtrader:
I managed to get my optimizations to run as quick as optstrategy by subclassing Cerebro and pulling out some stuff out of run() and addstrategy() into different functions (one to initialize data loading, and another which gets re-executed from outside the class for optimization).
I also manage multiprocessing from the outside.
Do you mind to share some code? Or kind of a layout of what and where was implemented in more details?
The problem is that the bricks need to be placed at a timestamp. At each timestamp you only have one output value for the lines of the data feed (in general these will be OHLC)
In summary: you cannot therefore generate multiple bricks. Generating bricks of dissimilar sizes, what you apparently have already achieved, is your only possibility.
@ab_trader - I am doing my best. I have already submitted pull requests for new Fisher Transform indicator and Simulated Order. And I am sharing all my code snippets here along with explanations whenever relevant.
When I say the framework should have this or that, I dont mean that someone should implement them but that we shall implement it for everybody's benefit.
Thanks for the link. I was thinking to create simple strategy in bt which will go thru all of the contracts and return me continuous contract data feed built by my rules.
Since I am using daily bars I am not so concerned about live trading right now. I is beneficial, but not mandatory.