mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 09:58:22 +08:00
refactor: clean up gate trader configuration
This commit is contained in:
@@ -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
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user