From e41df7e321eade31df9eb8dd4d8a7773661914bb Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 26 Mar 2023 01:21:20 +0800 Subject: [PATCH] xfunding: add wip list --- pkg/strategy/xfunding/strategy.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/strategy/xfunding/strategy.go b/pkg/strategy/xfunding/strategy.go index edb0ce432..3786d232c 100644 --- a/pkg/strategy/xfunding/strategy.go +++ b/pkg/strategy/xfunding/strategy.go @@ -17,6 +17,14 @@ import ( "github.com/c9s/bbgo/pkg/types" ) +// WIP: +// - track fee token price for cost +// - buy enough BNB before creating positions +// - transfer the rest BNB into the futures account +// - add slack notification support +// - use neutral position to calculate the position cost +// - customize profit stats for this funding fee strategy + const ID = "xfunding" // Position State Transitions: @@ -290,6 +298,8 @@ func (s *Strategy) CrossRun(ctx context.Context, orderExecutionRouter bbgo.Order s.spotOrderExecutor = s.allocateOrderExecutor(ctx, s.spotSession, instanceID, s.SpotPosition) s.spotOrderExecutor.TradeCollector().OnTrade(func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value) { + s.NeutralPosition.AddTrade(trade) + // we act differently on the spot account // when opening a position, we place orders on the spot account first, then the futures account, // and we need to accumulate the used quote amount @@ -331,6 +341,8 @@ func (s *Strategy) CrossRun(ctx context.Context, orderExecutionRouter bbgo.Order s.futuresOrderExecutor = s.allocateOrderExecutor(ctx, s.futuresSession, instanceID, s.FuturesPosition) s.futuresOrderExecutor.TradeCollector().OnTrade(func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value) { + s.NeutralPosition.AddTrade(trade) + if s.positionType != types.PositionShort { return }