Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STRATEGY: Detect abnormal volume increases using isolation forest #1863

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

narumiruna
Copy link
Collaborator

@narumiruna narumiruna commented Dec 13, 2024

This pull request introduces a new trading strategy named "Sentinel" and includes various changes to support its implementation. The most important changes include the addition of the configuration for the Sentinel strategy, updates to dependencies, and the implementation of the strategy itself.

Configuration and Dependencies:

  • config/sentinel.yaml: Added configuration for sessions, persistence, and exchange strategies, including settings for the Sentinel strategy.
  • go.mod: Added github.com/narumiruna/go-iforest as an indirect dependency.
  • pkg/cmd/strategy/builtin.go: Imported the Sentinel strategy to make it available for use.

Sentinel Strategy Implementation:

  • pkg/strategy/sentinel/strategy.go: Implemented the Sentinel strategy, including methods for initialization, default settings, subscription to market data, and running the strategy. The strategy uses an Isolation Forest algorithm to detect anomalies in trading volumes.

Utility Functions:

  • pkg/datatype/floats/slice.go: Added Var and Std methods to the Slice type to calculate variance and standard deviation, which are used in the Sentinel strategy.

@narumiruna narumiruna requested review from c9s and gx578007 December 13, 2024 09:46
@bbgokarma-bot
Copy link

Welcome back! @narumiruna, This pull request may get 442 BBG.

@narumiruna narumiruna changed the title WIP: STRATEGY: Add sentinel strategy to detect abnormal trading volume increases WIP: STRATEGY: Detect abnormal trading volume increases by isolation forest Dec 13, 2024
@narumiruna narumiruna changed the title WIP: STRATEGY: Detect abnormal trading volume increases by isolation forest WIP: STRATEGY: Detect abnormal trading volume increases using isolation forest Dec 13, 2024
@bbgokarma-bot
Copy link

Re-estimated karma: this pull request may get 449 BBG

@bbgokarma-bot
Copy link

Re-estimated karma: this pull request may get 438 BBG

@bbgokarma-bot
Copy link

Re-estimated karma: this pull request may get 456 BBG

@bbgokarma-bot
Copy link

Re-estimated karma: this pull request may get 459 BBG

@narumiruna narumiruna changed the title WIP: STRATEGY: Detect abnormal trading volume increases using isolation forest WIP: STRATEGY: Detect abnormal volume increases using isolation forest Dec 13, 2024
@narumiruna narumiruna changed the title WIP: STRATEGY: Detect abnormal volume increases using isolation forest STRATEGY: Detect abnormal volume increases using isolation forest Dec 13, 2024
c9s
c9s previously approved these changes Dec 14, 2024
pkg/strategy/sentinel/math.go Outdated Show resolved Hide resolved
return sum / float64(len(floats))
}

func calculateMovingMeanAndStdDev(samples []float64, length int) (float64, float64) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also have the std dev?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add std dev method for floats.Slice

@c9s c9s dismissed their stale review December 14, 2024 07:53

added few comments

@bbgokarma-bot
Copy link

Re-estimated karma: this pull request may get 492 BBG

@bbgokarma-bot
Copy link

Re-estimated karma: this pull request may get 511 BBG

@bbgokarma-bot
Copy link

Re-estimated karma: this pull request may get 537 BBG

@narumiruna narumiruna requested a review from c9s December 17, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants