You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
45 lines
1.0 KiB
package okx |
|
|
|
import ( |
|
"sig-pub/pkg/config" |
|
"sig-pub/pkg/types" |
|
) |
|
|
|
// kline |
|
type OkxExchange struct { |
|
conf config.OkxExchange |
|
channelCandle *ChannelCandle // K线频道 |
|
} |
|
|
|
func NewOkxExchange(conf config.OkxExchange) *OkxExchange { |
|
return &OkxExchange{ |
|
conf: conf, |
|
} |
|
} |
|
|
|
func (okx *OkxExchange) Init() (err error) { |
|
// TODO 多个 ChannelCandle 实例 OkxAggregate |
|
okx.channelCandle = NewChannelCandle("candle-0", okx.conf.HttpProxy) |
|
if err = okx.channelCandle.Init(); err != nil { |
|
return |
|
} |
|
return |
|
} |
|
|
|
func (okx *OkxExchange) ExhcangeType() types.Exchange { |
|
return types.ExchangeOKX |
|
} |
|
|
|
func (okx *OkxExchange) ConsumerKline() <-chan *types.ChannelKline { |
|
return okx.channelCandle.Consumer() |
|
} |
|
|
|
// 订阅产品k线行情 |
|
func (okx *OkxExchange) SubscribeKline(instIds ...string) (err error) { |
|
return okx.channelCandle.Subscribe(instIds...) |
|
} |
|
|
|
// 取消订阅产品k线行情 |
|
func (okx *OkxExchange) UnsubscribeKline(instIds ...string) (err error) { |
|
return okx.channelCandle.Unsubscribe(instIds...) |
|
}
|
|
|