diff --git a/Makefile b/Makefile index aa6f076..e18dc26 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: clean build test run docker-* tag release NAME=trading-gpt -VERSION=0.14.10 +VERSION=0.15.1 clean: rm -rf build/* diff --git a/libs/bbgo b/libs/bbgo index a416ed2..9a2e2b9 160000 --- a/libs/bbgo +++ b/libs/bbgo @@ -1 +1 @@ -Subproject commit a416ed2b13f919effefe2e325fc3c7d52c7ef126 +Subproject commit 9a2e2b9a8a650aa577dba43cbf1780d1cffb1e20 diff --git a/pkg/env/exchange/exchange_entity.go b/pkg/env/exchange/exchange_entity.go index 3eb77af..decaff1 100644 --- a/pkg/env/exchange/exchange_entity.go +++ b/pkg/env/exchange/exchange_entity.go @@ -119,23 +119,6 @@ func (ent *ExchangeEntity) Actions() []*ttypes.ActionDesc { }, }, }, - { - Name: "close_position", - Description: "close position", - Samples: []ttypes.Sample{ - { - Input: []string{ - "BOLL data changed: UpBand:[2.92 2.92 2.92 2.92 2.92 2.92 2.92 2.92 2.92 2.91 2.91 2.90 2.90 2.89 2.89 2.89 2.89 2.89 2.89 2.90 2.92], SMA:[2.87 2.87 2.87 2.87 2.87 2.87 2.87 2.87 2.87 2.87 2.86 2.86 2.86 2.85 2.85 2.85 2.85 2.85 2.85 2.85 2.86], DownBand:[2.81 2.81 2.82 2.82 2.82 2.82 2.83 2.83 2.82 2.82 2.82 2.81 2.81 2.82 2.82 2.82 2.82 2.82 2.82 2.81 2.80]", - "RSI data changed: [2.66 2.65 2.65 2.64 2.64 2.63 2.63 2.63 2.63 2.63 2.63 2.64 2.65 2.66 2.67 2.67 2.68 2.68 2.68 2.68 2.69]", - "The current position is long, average cost: 2.736, and accumulated profit: 15.324", - "Analyze data, generate trading cmd", - }, - Output: []string{ - "Execute cmd: /close_position", - }, - }, - }, - }, { Name: "update_position", Description: "update position", @@ -162,6 +145,23 @@ func (ent *ExchangeEntity) Actions() []*ttypes.ActionDesc { }, }, }, + { + Name: "close_position", + Description: "close position", + Samples: []ttypes.Sample{ + { + Input: []string{ + "BOLL data changed: UpBand:[2.92 2.92 2.92 2.92 2.92 2.92 2.92 2.92 2.92 2.91 2.91 2.90 2.90 2.89 2.89 2.89 2.89 2.89 2.89 2.90 2.92], SMA:[2.87 2.87 2.87 2.87 2.87 2.87 2.87 2.87 2.87 2.87 2.86 2.86 2.86 2.85 2.85 2.85 2.85 2.85 2.85 2.85 2.86], DownBand:[2.81 2.81 2.82 2.82 2.82 2.82 2.83 2.83 2.82 2.82 2.82 2.81 2.81 2.82 2.82 2.82 2.82 2.82 2.82 2.81 2.80]", + "RSI data changed: [2.66 2.65 2.65 2.64 2.64 2.63 2.63 2.63 2.63 2.63 2.63 2.64 2.65 2.66 2.67 2.67 2.68 2.68 2.68 2.68 2.69]", + "The current position is long, average cost: 2.736, and accumulated profit: 15.324", + "Analyze data, generate trading cmd", + }, + Output: []string{ + "Execute cmd: /close_position", + }, + }, + }, + }, { Name: "no_action", Description: "No action to be taken", diff --git a/pkg/jarvis.go b/pkg/jarvis.go index 48dcac6..42984cd 100644 --- a/pkg/jarvis.go +++ b/pkg/jarvis.go @@ -545,14 +545,22 @@ func (s *Strategy) handlePositionChanged(_ctx context.Context, session ttypes.IS side = "long" } - msg = fmt.Sprintf("The current position is %s with %dx leverage, average cost: %.3f, and accumulated profit: %.3f%s", side, s.Leverage.Int(), position.AverageCost.Float64(), position.AccumulatedProfit.Float64(), "%") + msg = fmt.Sprintf("The current position is %s with %dx leverage, average cost: %.3f, and accumulated profit: %.3f%s.", side, s.Leverage.Int(), position.AverageCost.Float64(), position.AccumulatedProfit.Float64(), "%") + + if position.TpTriggerPx != nil { + msg += fmt.Sprintf("\nThe current position's take-profit trigger price is %s.", position.Market.FormatPrice(*position.TpTriggerPx)) + } + + if position.SlTriggerPx != nil { + msg += fmt.Sprintf("\nThe current position's stop-loss trigger price is %s.", position.Market.FormatPrice(*position.SlTriggerPx)) + } profits := position.GetProfitValues() if len(profits) > s.MaxWindowSize { profits = profits[len(profits)-s.MaxWindowSize:] } - msg = msg + fmt.Sprintf("\nThe profits of the recent %d periods: [%s], and the holding period: %d", + msg = msg + fmt.Sprintf("\nThe profits of the recent %d periods: [%s], and the holding period: %d.", s.MaxWindowSize, utils.JoinFloatSlicePercentage([]float64(profits), " "), position.GetHoldingPeriod())