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
Improve supertrend strategy #799
Improve supertrend strategy #799
Conversation
andycheng123
commented
Jul 6, 2022
•
edited
edited
Welcome back! @andycheng123, This pull request may get 358 BBG. |
Codecov Report
@@ Coverage Diff @@
## main #799 +/- ##
=======================================
Coverage 19.35% 19.35%
=======================================
Files 359 359
Lines 27302 27302
=======================================
Hits 5283 5283
Misses 21503 21503
Partials 516 516 Continue to review full report at Codecov.
|
Re-estimated karma: this pull request may get 363 BBG |
pkg/strategy/supertrend/strategy.go
Outdated
s.fastDEMA.Update((*klines)[i].GetClose().Float64()) | ||
} | ||
} | ||
if klines, ok := kLineStore.KLinesOfInterval(s.slowDEMA.Interval); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pull out this preload code to a function?
pkg/strategy/supertrend/strategy.go
Outdated
@@ -174,22 +252,26 @@ func (s *Strategy) setupIndicators() { | |||
} | |||
s.Supertrend = &indicator.Supertrend{IntervalWindow: types.IntervalWindow{Window: s.SupertrendWindow, Interval: s.Interval}, ATRMultiplier: s.SupertrendMultiplier} | |||
s.Supertrend.AverageTrueRange = &indicator.ATR{IntervalWindow: types.IntervalWindow{Window: s.SupertrendWindow, Interval: s.Interval}} | |||
s.Supertrend.Bind(kLineStore) | |||
// Preload | |||
if klines, ok := kLineStore.KLinesOfInterval(s.Supertrend.Interval); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
default: | ||
lgSignal = types.DirectionNone | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you pull this out to a function?
pkg/strategy/supertrend/strategy.go
Outdated
func init() { | ||
// Register the pointer of the strategy struct, | ||
// so that bbgo knows what struct to be used to unmarshal the configs (YAML or JSON) | ||
// Note: built-in strategies need to imported manually in the bbgo cmd package. | ||
bbgo.RegisterStrategy(ID, &Strategy{}) | ||
} | ||
|
||
// LinGre is Linear Regression baseline | ||
type LinGre struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to a single file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not enough to be a standalone indicator
should it be in a single file?
|
||
currentTakeProfitPrice fixedpoint.Value | ||
currentStopLossPrice fixedpoint.Value | ||
|
||
// ExitMethods Exit methods | ||
ExitMethods []bbgo.ExitMethod `json:"exits"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use bbgo.ExitMethodSet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExitMethodSet is not in this branch yet
replace it later?
Re-estimated karma: this pull request may get 474 BBG |
Re-estimated karma: this pull request may get 507 BBG |
Re-estimated karma: this pull request may get 515 BBG |
Re-estimated karma: this pull request may get 534 BBG |
Re-estimated karma: this pull request may get 539 BBG |
config/supertrend.yaml
Outdated
@@ -18,8 +18,8 @@ backtest: | |||
# for testing max draw down (MDD) at 03-12 | |||
# see here for more details | |||
# https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp | |||
startTime: "2022-04-01" | |||
endTime: "2022-04-30" | |||
startTime: "2022-03-01" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's always start from 2022-01-01 ?
Re-estimated karma: this pull request may get 554 BBG |
Re-estimated karma: this pull request may get 559 BBG |
Hi @andycheng123, Well done! 564 BBG has been sent to your polygon wallet. Please check the following tx: https://polygonscan.com/tx/0x0825524fe2de2bec4323f2fce06c090b62d7110723b3619e59b722d6c605b59f Thank you for your contribution! |