-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
-
The entry size plot shows a short signal was received at around March 1987, but no trade has been made, I don't know why
I was using the HSI index as the dataset, and the strategy is simple, if the Z-value < -threshold the short the index, if >threshold then long it, it works at Oct 87 but failed at March, I am confusing now
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 3 comments 3 replies
-
截屏2021年09月30日 上午10 51 47
It seems the first trade signal always been ignored, but why? Is this designed or a bug? How can I fix this?
Beta Was this translation helpful? Give feedback.
All reactions
-
This is SignalStrategy
code. Welcome to investigate. 😅
It seems the first trade signal always been ignored, but why?
Z.shift()
produces one leading NaN
value, but NaN != 0
, hence +1. Can you confirm?
Beta Was this translation helpful? Give feedback.
All reactions
-
Beta Was this translation helpful? Give feedback.
All reactions
-
Referring to:
It seems the first trade signal always been ignored, but why?
You do print(sum(signal.head(100) != 0))
and get 40, whereas there are only 39 trades. The extra one is the 0-indexed NaN.
Beta Was this translation helpful? Give feedback.
All reactions
-
There is no Nan in the signal :(, 6 signals and 5 trades
You can see my full code in colab:
https://colab.research.google.com/drive/1l4Ki7tcdlhjEqfcuhdETdxbupIwyB6KS?usp=sharing
Beta Was this translation helpful? Give feedback.
All reactions
-
Opened this as issue #495. Welcome to subscribe and/or investigate further. Note that SignalStrategy
doesn't close trades unless exit_portion=
is set—rather it just uses Strategy.buy
and Strategy.sell
...
backtesting.py/backtesting/lib.py
Lines 423 to 437 in 7671f04
So this may play a role. 🤔
Beta Was this translation helpful? Give feedback.