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

Why no trade after the signal received? #486

AetherTL started this conversation in General
Discussion options

截屏2021年09月30日 上午10 17 05

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

You must be logged in to vote

Replies: 3 comments 3 replies

Comment options

截屏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?

You must be logged in to vote
1 reply
Comment options

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?

Comment options

thanks for your reply The signal list is perfectly matched so I don’t think Z.shift() matters here, also Z.shift only =nan at first date right? In my example the first signal was received at 43rd bar.
...
在 2021年9月30日,下午6:44,kernc ***@***.***> 写道:  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? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
You must be logged in to vote
1 reply
Comment options

kernc Oct 1, 2021
Maintainer

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.

Comment options

截屏2021年10月04日 上午9 51 17

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

You must be logged in to vote
1 reply
Comment options

kernc Oct 4, 2021
Maintainer

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 ...

exit_portion = self.__exit_signal[-1]
if exit_portion > 0:
for trade in self.trades:
if trade.is_long:
trade.close(exit_portion)
elif exit_portion < 0:
for trade in self.trades:
if trade.is_short:
trade.close(-exit_portion)
entry_size = self.__entry_signal[-1]
if entry_size > 0:
self.buy(size=entry_size)
elif entry_size < 0:
self.sell(size=-entry_size)

So this may play a role. 🤔
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants

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