can we use self.position.set(size=100, price=15.01) to initialize a data's initial size and price?
Li Mike last edited by
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?
vladisld last edited by
Technically it should work ( in
startmethod 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.