Closed YASHGUPTA2611 closed 2 years ago
Hi, similar question here I guess: let's say i have buy/sell signals; but at every trade i want to simulate stop loss/stop profit; how can I take this into consideration in the backtesting?
Example: 2021/1/1 buy signal; i want to put stop loss at -1% and stop profit at +3% 2021/1/2 : market drop -2% so I want stop loss at -1% executed (even though no sell signal) etc
Thanks!
@RogerMichel
there is already stop loss and take profit (https://github.com/enzoampil/fastquant/blob/4683879bc51bac24fed2ff8bc52d1a528a9f2203/python/fastquant/strategies/base.py#L52-L54)
You simply need to state the number when you create the strategy https://github.com/enzoampil/fastquant/blob/4683879bc51bac24fed2ff8bc52d1a528a9f2203/python/fastquant/strategies/base.py#L386-L396
Let's say i have initial_cash = 100000 and according to my strategy there are 3 buy signals in the starting and i wand to limit my buy signals to only one. So the below approach is right? or do we have any alternative?
this will not work.
def buy_signal you are defining a function which should be its own line. I highly suggest going over the backtrader quickstart guide https://www.backtrader.com/docu/quickstart/quickstart/
what fastquant does is handle the main backtrader so all you need is to create the buy_signal and sell_signal. no need to add count. it will automatically handle the signals and buy using the first signal. if there is another buy before a sell, it wont do anything
Below is my strategy that i implemented. In the starting my strategy takes the trade and buy 2 times then sell only one. I only want to trade one time and will give buy prop and sell prop. How will i do it??
This is a case of slippage and this really happens even in real life scenarios. You can try changing the slippage to 0
Okay understood @mikeejazmines . Thanks for the reply.
Please give more details on the issue/ask