diff --git a/broker.go b/broker.go index cc5f7c1..d76aecf 100644 --- a/broker.go +++ b/broker.go @@ -15,9 +15,9 @@ type Broker interface { GetOrderBook(symbol string, depth int) (result OrderBook, err error) // 设置合约类型 - // pair: 交易对,如: BTC-USD(OKEX) BTC(HBDM) + // currencyPair: 交易对,如: BTC-USD(OKEX) BTC(HBDM) // contractType: W1,W2,Q1,Q2 - SetContractType(pair string, contractType string) (err error) + SetContractType(currencyPair string, contractType string) (err error) // 获取当前设置的合约ID GetContractID() (symbol string, err error) diff --git a/brokers/bitmex-broker/broker.go b/brokers/bitmex-broker/broker.go index 0cd4eb4..8d6b31b 100644 --- a/brokers/bitmex-broker/broker.go +++ b/brokers/bitmex-broker/broker.go @@ -10,6 +10,7 @@ import ( // BitMEXBroker the BitMEX broker type BitMEXBroker struct { client *bitmex.BitMEX + symbol string } func (b *BitMEXBroker) GetName() (name string) { @@ -54,12 +55,13 @@ func (b *BitMEXBroker) GetOrderBook(symbol string, depth int) (result OrderBook, return } -func (b *BitMEXBroker) SetContractType(pair string, contractType string) (err error) { +func (b *BitMEXBroker) SetContractType(currencyPair string, contractType string) (err error) { + b.symbol = currencyPair return } func (b *BitMEXBroker) GetContractID() (symbol string, err error) { - return + return b.symbol, nil } func (b *BitMEXBroker) SetLeverRate(value float64) (err error) { diff --git a/brokers/bitmex-sim-broker/broker.go b/brokers/bitmex-sim-broker/broker.go index 85bbd6a..c4ce600 100644 --- a/brokers/bitmex-sim-broker/broker.go +++ b/brokers/bitmex-sim-broker/broker.go @@ -32,6 +32,8 @@ type BitMEXSimBroker struct { openOrders map[string]*Order // Open orders historyOrders map[string]*Order // History orders positions map[string]*Position // Position key: symbol + + symbol string } func (b *BitMEXSimBroker) GetName() (name string) { @@ -68,12 +70,13 @@ func (b *BitMEXSimBroker) GetOrderBook(symbol string, depth int) (result OrderBo return } -func (b *BitMEXSimBroker) SetContractType(pair string, contractType string) (err error) { +func (b *BitMEXSimBroker) SetContractType(currencyPair string, contractType string) (err error) { + b.symbol = currencyPair return } func (b *BitMEXSimBroker) GetContractID() (symbol string, err error) { - return + return b.symbol, nil } func (b *BitMEXSimBroker) SetLeverRate(value float64) (err error) { diff --git a/brokers/bybit-broker/broker.go b/brokers/bybit-broker/broker.go index 0fc00f7..8de3ff0 100644 --- a/brokers/bybit-broker/broker.go +++ b/brokers/bybit-broker/broker.go @@ -11,6 +11,7 @@ import ( // BybitBroker the Bybit broker type BybitBroker struct { client *rest.ByBit + symbol string } func (b *BybitBroker) GetName() (name string) { @@ -59,12 +60,13 @@ func (b *BybitBroker) GetOrderBook(symbol string, depth int) (result OrderBook, return } -func (b *BybitBroker) SetContractType(pair string, contractType string) (err error) { +func (b *BybitBroker) SetContractType(currencyPair string, contractType string) (err error) { + b.symbol = currencyPair return } func (b *BybitBroker) GetContractID() (symbol string, err error) { - return + return b.symbol, nil } func (b *BybitBroker) SetLeverRate(value float64) (err error) { diff --git a/brokers/deribit-broker/broker.go b/brokers/deribit-broker/broker.go index f303ce8..4feda6b 100644 --- a/brokers/deribit-broker/broker.go +++ b/brokers/deribit-broker/broker.go @@ -98,7 +98,7 @@ func (b *DiribitBroker) GetOrderBook(symbol string, depth int) (result OrderBook return } -func (b *DiribitBroker) SetContractType(pair string, contractType string) (err error) { +func (b *DiribitBroker) SetContractType(currencyPair string, contractType string) (err error) { return }