1

I would like to set up a backtesting strategy which allows me to trade up to a certain stock position such as 10000.

Therefore, I can go long or short up to 10000 but not over.

I have currently set up a backtesting strategy but I cannot work out how to stop it trading once it hits a limit.

If I buy 10000 then I should only be allowed to sell and not buy.

I have this:

df_tradable["Trade"].groupby(df_tradable["Date"]).cumsum()

This adds up all of my trades for a day. (Trade is +1 or -1 depending if buy or sell)

I can set up another check which only adds up P&L when my day traded is less than 10000 however I want to be able to sell again.

Is there an easy way to set this up please?

4

0 回答 0