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

Improve supertrend strategy #799

Merged
merged 16 commits into from Jul 7, 2022

Conversation

andycheng123
Copy link
Collaborator

@andycheng123 andycheng123 commented Jul 6, 2022

winningRatio: "1.50000000"
numOfLossTrade: 4
numOfProfitTrade: 6
grossProfit: "9510.58490673"
grossLoss: "-1616.37687265"
profits:
    - "962.02614650"
    - "1492.98331752"
    - "2013.07243890"
    - "0.00006635"
    - "557.31764608"
    - "4485.18529138"
losses:
    - "-402.85689998"
    - "-384.84449514"
    - "-376.47721820"
    - "-452.19825933"
mostProfitableTrade: "4485.18529138"
mostLossTrade: "-452.19825933"
profitFactor: "-5.88389073"
totalNetProfit: "7894.20803408"

BACK-TEST REPORT
===============================================
START TIME: Tue, 01 Mar 2022 00:00:00 UTC
END TIME: Thu, 30 Jun 2022 00:00:00 UTC
INITIAL TOTAL BALANCE: BalanceMap[BTC: 1, USDT: 10000]
FINAL TOTAL BALANCE: BalanceMap[BTC: 1.885876, USDT: 0.0000659]
binance BTCUSDT PROFIT AND LOSS REPORT
===============================================
TRADES SINCE: 2022-03-01 21:04:59.999 +0000 UTC
NUMBER OF TRADES: 19
AVERAGE COST: $ 20,199.45
BASE ASSET POSITION: 0.885876
TOTAL BUY VOLUME: 3.49511477
TOTAL SELL VOLUME: 2.60923877
CURRENT PRICE: $ 20,122.58
CURRENCY FEES:
 - FEE: 152.2463837
PROFIT: $ 7,894.21
UNREALIZED PROFIT: -$ 68.10
INITIAL ASSET IN USDT ~= 53160.00000 USDT (1 BTC = 43160)
FINAL ASSET IN USDT ~= 37948.69074 USDT (1 BTC = 20122.58)
REALIZED PROFIT: +7894.20803408 USDT
UNREALIZED PROFIT: -68.09728812 USDT
ASSET DECREASED: -15211.30925402 USDT (-28.61%)

@bbgokarma-bot
Copy link

Welcome back! @andycheng123, This pull request may get 358 BBG.

@andycheng123 andycheng123 requested review from c9s and zenixls2 July 6, 2022 03:16
@codecov
Copy link

codecov bot commented Jul 6, 2022

Codecov Report

Merging #799 (f877775) into main (e778db1) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

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

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e778db1...f877775. Read the comment docs.

@andycheng123 andycheng123 changed the title Improve supertrend strategy WIP: Improve supertrend strategy Jul 6, 2022
@bbgokarma-bot
Copy link

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

@andycheng123 andycheng123 changed the title WIP: Improve supertrend strategy Improve supertrend strategy Jul 6, 2022
s.fastDEMA.Update((*klines)[i].GetClose().Float64())
}
}
if klines, ok := kLineStore.KLinesOfInterval(s.slowDEMA.Interval); ok {
Copy link
Owner

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?

@@ -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 {
Copy link
Owner

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
}
}
Copy link
Owner

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?

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 {
Copy link
Owner

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?

Copy link
Collaborator Author

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"`
Copy link
Owner

Choose a reason for hiding this comment

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

use bbgo.ExitMethodSet

Copy link
Collaborator Author

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?

@bbgokarma-bot
Copy link

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

@bbgokarma-bot
Copy link

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

@andycheng123 andycheng123 changed the title Improve supertrend strategy WIP: Improve supertrend strategy Jul 6, 2022
@bbgokarma-bot
Copy link

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

@andycheng123 andycheng123 changed the title WIP: Improve supertrend strategy Improve supertrend strategy Jul 6, 2022
@bbgokarma-bot
Copy link

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

@bbgokarma-bot
Copy link

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

@@ -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"
Copy link
Owner

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 ?

@bbgokarma-bot
Copy link

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

@bbgokarma-bot
Copy link

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

@andycheng123 andycheng123 merged commit 72f18c1 into c9s:main Jul 7, 2022
@bbgokarma-bot
Copy link

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!

@andycheng123 andycheng123 deleted the improve/supertrend-strategy branch July 7, 2022 02:43
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.

None yet

3 participants