refactor: clean up gate trader configuration

This commit is contained in:
tinkle-community
2026-02-03 12:40:53 +08:00
parent 7b908a3e39
commit a5c4d35074
+7 -6
View File
@@ -37,6 +37,7 @@ type GateTrader struct {
// NewGateTrader creates a new Gate trader instance // NewGateTrader creates a new Gate trader instance
func NewGateTrader(apiKey, secretKey string) *GateTrader { func NewGateTrader(apiKey, secretKey string) *GateTrader {
config := gateapi.NewConfiguration() config := gateapi.NewConfiguration()
config.AddDefaultHeader("X-Gate-Channel-Id", "nofx")
client := gateapi.NewAPIClient(config) client := gateapi.NewAPIClient(config)
ctx := context.WithValue(context.Background(), ctx := context.WithValue(context.Background(),
@@ -550,10 +551,10 @@ func (t *GateTrader) SetStopLoss(symbol string, positionSide string, quantity, s
Close: true, Close: true,
}, },
Trigger: gateapi.FuturesPriceTrigger{ Trigger: gateapi.FuturesPriceTrigger{
StrategyType: 0, // Close position StrategyType: 0, // Close position
PriceType: 0, // Latest price PriceType: 0, // Latest price
Price: fmt.Sprintf("%.8f", stopPrice), Price: fmt.Sprintf("%.8f", stopPrice),
Rule: 1, // Price <= trigger price Rule: 1, // Price <= trigger price
}, },
} }
@@ -601,10 +602,10 @@ func (t *GateTrader) SetTakeProfit(symbol string, positionSide string, quantity,
Close: true, Close: true,
}, },
Trigger: gateapi.FuturesPriceTrigger{ Trigger: gateapi.FuturesPriceTrigger{
StrategyType: 0, // Close position StrategyType: 0, // Close position
PriceType: 0, // Latest price PriceType: 0, // Latest price
Price: fmt.Sprintf("%.8f", takeProfitPrice), Price: fmt.Sprintf("%.8f", takeProfitPrice),
Rule: 2, // Price >= trigger price for long take profit Rule: 2, // Price >= trigger price for long take profit
}, },
} }