切换到实盘环境
- HL: WS/REST 从 testnet 切换到 mainnet - BG: 删除 paptrading header(实盘 key 不以 bg_ 前缀区分) - config: 调整交易参数 - scanner: 更新跟踪币种列表
This commit is contained in:
@@ -19,7 +19,6 @@ type BitgetTrade struct {
|
||||
APISecret string
|
||||
Passphrase string
|
||||
client *http.Client
|
||||
paperMode bool
|
||||
}
|
||||
|
||||
func NewBitgetTrade(apiKey, apiSecret, passphrase string) *BitgetTrade {
|
||||
@@ -28,7 +27,6 @@ func NewBitgetTrade(apiKey, apiSecret, passphrase string) *BitgetTrade {
|
||||
APISecret: apiSecret,
|
||||
Passphrase: passphrase,
|
||||
client: &http.Client{Timeout: 10 * time.Second},
|
||||
paperMode: strings.HasPrefix(apiKey, "bg_"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +58,6 @@ func (b *BitgetTrade) PlaceMarketOrder(side, symbol, size, tradeSide string) (st
|
||||
req.Header.Set("ACCESS-SIGN", sign)
|
||||
req.Header.Set("ACCESS-TIMESTAMP", ts)
|
||||
req.Header.Set("ACCESS-PASSPHRASE", b.Passphrase)
|
||||
if b.paperMode {
|
||||
req.Header.Set("paptrading", "1")
|
||||
}
|
||||
|
||||
resp, err := b.client.Do(req)
|
||||
if err != nil {
|
||||
@@ -101,9 +96,6 @@ func (b *BitgetTrade) GetTradeFee(symbol, orderID string) (feeUSD float64, err e
|
||||
req.Header.Set("ACCESS-SIGN", sign)
|
||||
req.Header.Set("ACCESS-TIMESTAMP", ts)
|
||||
req.Header.Set("ACCESS-PASSPHRASE", b.Passphrase)
|
||||
if b.paperMode {
|
||||
req.Header.Set("paptrading", "1")
|
||||
}
|
||||
|
||||
resp, err := b.client.Do(req)
|
||||
if err != nil {
|
||||
@@ -113,9 +105,11 @@ func (b *BitgetTrade) GetTradeFee(symbol, orderID string) (feeUSD float64, err e
|
||||
respBody, _ := io.ReadAll(resp.Body)
|
||||
|
||||
var raw struct {
|
||||
Code string `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data []json.RawMessage `json:"data"`
|
||||
Code string `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data struct {
|
||||
FillList []json.RawMessage `json:"fillList"`
|
||||
} `json:"data"`
|
||||
}
|
||||
if err := json.Unmarshal(respBody, &raw); err != nil {
|
||||
return 0, fmt.Errorf("parse: %s", string(respBody))
|
||||
@@ -125,7 +119,7 @@ func (b *BitgetTrade) GetTradeFee(symbol, orderID string) (feeUSD float64, err e
|
||||
}
|
||||
|
||||
var totalFee float64
|
||||
for _, item := range raw.Data {
|
||||
for _, item := range raw.Data.FillList {
|
||||
var fill struct {
|
||||
FillFee string `json:"fillFee"`
|
||||
}
|
||||
@@ -158,9 +152,6 @@ func (b *BitgetTrade) GetBalance() (float64, error) {
|
||||
req.Header.Set("ACCESS-SIGN", sign)
|
||||
req.Header.Set("ACCESS-TIMESTAMP", ts)
|
||||
req.Header.Set("ACCESS-PASSPHRASE", b.Passphrase)
|
||||
if b.paperMode {
|
||||
req.Header.Set("paptrading", "1")
|
||||
}
|
||||
|
||||
resp, err := b.client.Do(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -25,7 +25,7 @@ func NewHyperLiquidWS(tracked []string) *HyperLiquidWS {
|
||||
}
|
||||
// Run connects to HyperLiquid WS and streams mid prices.
|
||||
func (h *HyperLiquidWS) Run(updateFn func(coin string, price, bid, ask float64)) error {
|
||||
conn := NewPriceConnector("wss://api.hyperliquid-testnet.xyz/ws", "HyperLiquid", 120*time.Second, 30*time.Second)
|
||||
conn := NewPriceConnector("wss://api.hyperliquid.xyz/ws", "HyperLiquid", 120*time.Second, 30*time.Second)
|
||||
conn.PingInterval = 45 * time.Second
|
||||
|
||||
conn.OnConnect = func() {
|
||||
|
||||
@@ -45,7 +45,7 @@ func NewHyperLiquidTrade(privateKeyHex, mainAddress, apiAddress string) (*HyperL
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
info := hl.NewInfo(ctx, hl.TestnetAPIURL, true, nil, nil, nil)
|
||||
info := hl.NewInfo(ctx, hl.MainnetAPIURL, true, nil, nil, nil)
|
||||
|
||||
return &HyperLiquidTrade{
|
||||
privateKey: privKey,
|
||||
@@ -75,7 +75,7 @@ func (h *HyperLiquidTrade) initExchange() error {
|
||||
return fmt.Errorf("spot meta: %w", err)
|
||||
}
|
||||
|
||||
h.exchange = hl.NewExchange(ctx, h.privateKey, hl.TestnetAPIURL, meta, "", h.mainAddress, spotMeta, nil)
|
||||
h.exchange = hl.NewExchange(ctx, h.privateKey, hl.MainnetAPIURL, meta, "", h.mainAddress, spotMeta, nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user