-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
-
Hi,
My case :
A week ago, my backtest "said" to me to buy Apple stocks at current price, that was 1 € (...), and to put my sl at 0.9, and my tp at 3. It said that, i normaly have 66% of chance of win with 2.4 PF (fake values, it's just an example).
Today, i am running the same strat, but with more data (1 week more of OHLC data) and my algo take it in case, and said to me that i must change my TP and SL, it should be ... tp 2.2, sl 1.3, with current price at 1.6.
So, to "detect" this changes, currently, I have to check "manualy". Currently, I run my strat, print the TP/SL in one side, open my bank account TP/SL in other side, and compare the values.
If run.tp != bank.tp -> must change bank.tp == run.tp (Same with sl)
When you have one stock, that's quiet easy to check, but if you have something as 20 stocks, it quiet hard to know that the sl/tp have changed and if you bank.tps/sls are up to date.
I would like to be able to know that with the "_strategy" with something like that :
if orders[-1].set_at == date.today():
print("New TP/SL, new values are {},{} for {}".format(orders[-1].tp,orders[-1].sl,stock_name))
Hope that's more or less clear ...
Best regards & cheers !
Beta Was this translation helpful? Give feedback.
All reactions
It's not entirely clear to me at least. 😅 What are you missing?
Something like:
if orders[-1].set_at == date.today():
can be achieved if you expand buy()
/sell()
:
class YourStrategy(Strategy): ... def buy(**kwargs): super().buy(**kwargs) last_order = self.orders[-1] last_order.set_at = date.today() ...
This would add .set_at
attribute on orders which you can filter on.
Replies: 1 comment 1 reply
-
It's not entirely clear to me at least. 😅 What are you missing?
Something like:
if orders[-1].set_at == date.today():
can be achieved if you expand buy()
/sell()
:
class YourStrategy(Strategy): ... def buy(**kwargs): super().buy(**kwargs) last_order = self.orders[-1] last_order.set_at = date.today() ...
This would add .set_at
attribute on orders which you can filter on.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thx for your advice.
I use your idea. And it looks that's is working well.
Beta Was this translation helpful? Give feedback.