For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
can we use self.position.set(size=100, price=15.01) to initialize a data's initial size and price?
-
in this post , it use data_pos.set(pos_size, pos_price) in a analyzer. So my question is: in a strategy's init method, can we use self.position.set(size=100, price=15.01) to initialize a data's initial size and price? Is it safe?
-
Technically it should work ( in
start
method for example), however IMHO it is better to set the position outsize the strategy code - just in case you would like to re-use your strategy in live-trading or otherwise keep you strategy code independent of external setup.Analyzer is probably a better place - you may always switch the analyzer on for back testing and off for live trading for example - leaving your strategy code intact.