For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
How data parameter in buy, sell and close work?
backtrader14 last edited by backtrader14
I am trying to understand how data parameter in buy, sell and close work. According to the docs
data (default: None) For which data the order has to be created. If None then the first data in the system, self.datas or self.data0 (aka self.data) will be used
I assumed that when we initiate
self.close()bactrader uses the close price as the default point of entry. But when I did something like this
it is throwing error. So how does data parameter in buy, sell and close work?
backtrader administrators last edited by
datais the target and NOT a price. The doc says that the argument
priceis where you put the price. Although for some orders, there is more than once price.
You probably want to read about the execution types, to understand when you can and you cannot determine the price.