I have a basic strategy where At the end of each day:
if signal > 0.4:
if spy not in open_orders:
order_target_percent(spy, 0.01)
if signal < -0.2:
if spy not in open_orders:
order_target_percent(spy, -0.01)
For example, If the 'signal' was > 0.4 for 5 days in a row, then a long position was opened for each of those 5 days, resulting in a total long position worth 0.05 of the portfolio.
I need to create some function which will close out each individual trade 10 days after it was opened.