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:irr: a mean reversion based on box of klines in same direction #989

Merged
merged 11 commits into from
Nov 2, 2022

Conversation

austin362667
Copy link
Collaborator

@austin362667 austin362667 commented Oct 11, 2022

Due to the severe "delay" issue in binance 1s kline stream.
We've refactored irr strategy into backtesting mode (consume KLine onClose), and real-time mode (consume bookTicker which triggered every interval via goroutine)

Now we've redesigned the time ticker(goroutine) to consume aggerate trade market stream based on web socket .

Rollback to interval time trigger for a much easier programming model and really small intervals.

@bbgokarma-bot
Copy link

Welcome back! @austin362667, This pull request may get 289 BBG.

@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Merging #989 (6e29359) into main (7dd951e) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #989   +/-   ##
=======================================
  Coverage   19.88%   19.88%           
=======================================
  Files         420      420           
  Lines       31961    31961           
=======================================
  Hits         6356     6356           
  Misses      24999    24999           
  Partials      606      606           

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 7dd951e...6e29359. Read the comment docs.

@bbgokarma-bot
Copy link

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

@austin362667 austin362667 changed the title strategy:irr: add backtest/realtime ability strategy:irr: redesign interval trigger Oct 17, 2022
@bbgokarma-bot
Copy link

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

@bbgokarma-bot
Copy link

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

@bbgokarma-bot
Copy link

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

@bbgokarma-bot
Copy link

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

@austin362667 austin362667 changed the title strategy:irr: redesign interval trigger strategy:irr: redesigned to maker order Oct 17, 2022
return
}
bbgo.SendPhoto(&buffer)
return
Copy link
Owner

Choose a reason for hiding this comment

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

fix the lint issue

s.currentTradePrice = atomic.NewFloat64(trade.Price.Float64())
})

go func() {
Copy link
Owner

Choose a reason for hiding this comment

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

this part is not backtest-able

Quantity: s.Quantity,
Type: types.OrderTypeLimitMaker,
Price: fixedpoint.NewFromFloat(bestBid - s.Spread),
Tag: "irr short: buy",
Copy link
Owner

Choose a reason for hiding this comment

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

tag format is like this irrShortBuy

Copy link
Owner

Choose a reason for hiding this comment

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

but I guess you mean irrShortClose here

@@ -398,3 +486,31 @@ func (s *Strategy) CalcAssetValue(price fixedpoint.Value) fixedpoint.Value {
balances := s.session.GetAccount().Balances()
return balances[s.Market.BaseCurrency].Total().Mul(price).Add(balances[s.Market.QuoteCurrency].Total())
}

func (s *Strategy) rebalancePosition(bestBid, bestAsk float64, w float64) {
Copy link
Owner

Choose a reason for hiding this comment

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

it's better to pass ctx to the function

@bbgokarma-bot
Copy link

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

1 similar comment
@bbgokarma-bot
Copy link

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

@bbgokarma-bot
Copy link

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

@bbgokarma-bot
Copy link

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

strategy:irr: clean up

strategy:irr: clean up

strategy:irr: clean up
@bbgokarma-bot
Copy link

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

@austin362667 austin362667 changed the title strategy:irr: redesigned to maker order strategy:irr: a mean reversion based on box of klines in same direction Oct 19, 2022
@bbgokarma-bot
Copy link

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

@c9s c9s merged commit 335b90a into c9s:main Nov 2, 2022
@bbgokarma-bot
Copy link

Hi @austin362667,

Well done! 460 BBG has been sent to your polygon wallet. Please check the following tx:

https://polygonscan.com/tx/0x6cf14db81c3ca27db323704f4327fa3a5704b33800c0378802a33780b9865695

Thank you for your contribution!

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.

5 participants