How to create as sell order @ high price
I would like to create a sell order in backtrader which will sell @high price. How do i code the same? I have tried the following
But the same does not work. Self.high is defined as high price.
vladisld last edited by
AFAIU the Backtrader engine tries to emulate the real time broker behavior. I doubt you could always sell at bar's high in real-life, right ? Because the high price happened in the past ( at the time the bar is reported)
The only case where your order will be filled @current_bar_high is when the next bar high will be higher than the current one ( similarly to the real life ), or when you are issuing the limit order before the current bar (on previous bar) and somehow guess the next bar high price.
J T last edited by
tianjixuetu last edited by
backtrader don't have self.high in strategy,unless you define it。maybe you should use
data = self.getdatabyname( your data's name) self.order=self.sell(exectype=bt.Order.Limit, price=data.high)
but you know,it is a limit order ,so your sell order maybe not fill or execute.