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.
70 lines
1.6 KiB
70 lines
1.6 KiB
package okx |
|
|
|
import ( |
|
"sig-pub/pkg/config" |
|
"sig-pub/pkg/types" |
|
) |
|
|
|
var subscribeCandles = map[types.Interval]string{ |
|
// "3M", "1M", "1W", "1D", "2D", "3D", "5D", |
|
// "12H", "6H", "4H", "2H", "1H", |
|
// "30m", "15m", "5m", "3m", "1m", |
|
// "1s", |
|
types.Interval1s: "1s", |
|
types.Interval1m: "1m", |
|
types.Interval3m: "3m", |
|
types.Interval5m: "5m", |
|
types.Interval15m: "15m", |
|
types.Interval30m: "30m", |
|
types.Interval1h: "1H", |
|
types.Interval2h: "2H", |
|
types.Interval4h: "4H", |
|
types.Interval6h: "6H", |
|
types.Interval12h: "12H", |
|
types.Interval1d: "1D", |
|
types.Interval2d: "2D", |
|
types.Interval3d: "3D", |
|
types.Interval5d: "5D", |
|
types.Interval1w: "1W", |
|
types.Interval1mo: "1M", |
|
types.Interval3mo: "3M", |
|
} |
|
|
|
// 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...) |
|
}
|
|
|