edtechre / pybroker

Algorithmic Trading in Python with Machine Learning
https://www.pybroker.com
Other
2.06k stars 256 forks source link

Can ctx.score work with ctx.sell_shares? #131

Closed none2003 closed 4 months ago

none2003 commented 4 months ago

Hi @edtechre,

In example of Rotational Trading, ctx.score was used to pair with ctx.buy_shares, can it work with ctx.sell_shares?

As a counterexample, how to achieve: "We cover the currently held stock short position if it is no longer ranked among the bottom five 20-day ROCs. Otherwise, we rank all stocks by their 20-day ROC and sell the bottom two ranked. "

edtechre commented 4 months ago

Yes, just make sure to set max_short_positions.