Replies: 2 comments 2 replies
-
You can add condition in front of the self.buy: for example, from:
to:
|
Beta Was this translation helpful? Give feedback.
2 replies
-
May be your present position is generating some profit which is used for taking the trade. As per documentation If size is a value between 0 and 1, it is interpreted as a fraction of current available liquidity (cash plus [Position.pl] minus used margin). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am new to Backtesting.py and I have the following question:
Within my strategy class I use the following to place an order based on some condition.
self.buy(sl = stopLoss, tp = takeProfit, size= .99999)
Before the run I also set:
bt = backtesting.Backtest(df_Test, MyStrategy, trade_on_close = True, exclusive_orders = False, cash = initialCash)
Here is part of the trading plot

Can someone explain to me why Backtesting starts another trade (see arrow) before the active trade becomes inactive since there is not enough available liquidity because size= .99999 (So if I understand the whole initial capital is committed to the previous trade)??
thanks
Beta Was this translation helpful? Give feedback.
All reactions