Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

backtesting.tp/sl vs bank.tp/sl -> how to know more easily that my tp/sl are up to date #253

Answered by kernc
Benouare asked this question in Q&A
Discussion options

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 !

You must be logged in to vote

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

Comment options

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.

You must be logged in to vote
1 reply
Comment options

Thx for your advice.
I use your idea. And it looks that's is working well.

Answer selected by Benouare
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /