master

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2020 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

连续更新的数据

Index

Constants

View Source
const (
	MSG_OP_ERROR          = "err"
	MSG_OP_PING           = "ping"
	MSG_OP_PONG           = "pong"
	MSG_OP_SUB            = "sub"  // 订阅数据
	MSG_OP_PUSH           = "push" // 给Master推送的消息类型
	MSG_OP_UNSUB          = "unsub"
	MSG_OP_REQ            = "req"
	MSG_OP_REQ_LOGIN      = "login"
	MSG_OP_REQ_CHECKLOGIN = "check_login"
	MSG_OP_REQ_GETSYMBOLS = "get_symbols"

	// 买卖订单类
	MSG_OP_REQ_BUYOPEN   = "buyopen"   // 买入开多
	MSG_OP_REQ_SELLCLOSE = "sellclose" // 卖出平多

	MSG_OP_REQ_SELLOPEN = "sellopen" // 买入平空
	MSG_OP_REQ_BUYCLOSE = "buyclose" // 卖出开空
)

消息类型的常量

View Source
const (
	MSG_ACTION_TRADE  = "trade"  // 成交数据
	MSG_ACTION_KLINE  = "kline"  // K线数据
	MSG_ACTION_DEPTH  = "depth"  // 深度数据
	MSG_ACTION_ORDER  = "order"  // 订单数据
	MSG_ACTION_ASSETS = "assets" // 资产数据
)

消息动作的常量

Variables

View Source
var PkgName = "[Master数据源]" // 包名称

Functions

This section is empty.

Types

type BaseAction

type BaseAction struct {
	global.Config
	ThisDataSource global.DataSource
}

基础接口实现类型

func (this *BaseAction) DepthRealTimeLink(kp global.RealTimeDataParam, rsData chan global.DepthRealTimeData)

DepthRealTimeLink 创建长链接持续提供Depth数据(数据类型为:Kline,Trade,Depth)

参数: kp 只能传入一个数据源(当前的数据源),多个币种可同时返回数据
参数: rsDataChan 返回数据的接收管道,当有数据返回时会给该管道输出数据

func (*BaseAction) GetKlineBarSlice

func (this *BaseAction) GetKlineBarSlice(di global.DataIndex, sTime, eTime global.Timestamp) (kbs global.KlineBarSlice, err error)

GetKlineBarSlice 获取K线数据列表 (Kline,Trade,Depth)

参数: di 数据索引
参数: sTime 更新的开始时间
参数: eTime 更新的截止时间
返回值: kbs 返回KlineBar指针的Slice

func (*BaseAction) GetSymbolList

func (this *BaseAction) GetSymbolList(dsID global.DataSourceID) (ss []global.Symbol, err error)

获取数据源提供的所有交易对列表

func (*BaseAction) GetTradeSlice

func (this *BaseAction) GetTradeSlice(di global.DataIndex, sTime, eTime global.Timestamp) (kbs global.KlineBarSlice, err error)

GetTradeSlice 获取K线数据列表 (Kline,Trade,Depth)

参数: di 数据索引
参数: sTime 更新的开始时间
参数: eTime 更新的截止时间
返回值: kbs 返回KlineBar指针的Slice

func (*BaseAction) KlineRealTimeLine

func (this *BaseAction) KlineRealTimeLine(kp global.RealTimeDataParam, rsData chan global.KlineRealTimeData)

KlineRealTimeLine 创建长链接持续提供Kline数据(数据类型为:Kline,Trade,Depth)

参数: kp 只能传入一个数据源(当前的数据源),多个币种可同时返回数据
参数: rsDataChan 返回数据的接收管道,当有数据返回时会给该管道输出数据

func (*BaseAction) SetConfig

func (this *BaseAction) SetConfig(conf global.Config)

设置每个数据源的配置信息

func (this *BaseAction) TradeRealTimeLink(kp global.RealTimeDataParam, rsData chan global.TradeRealTimeData)

TradeRealTimeLink 创建长链接持续提供Trade数据(数据类型为:Kline,Trade,Depth)

参数: kp 只能传入一个数据源(当前的数据源),多个币种可同时返回数据
参数: rsDataChan 返回数据的接收管道,当有数据返回时会给该管道输出数据

func (*BaseAction) UpdataKlineFileCache

func (this *BaseAction) UpdataKlineFileCache(uParam global.UpdataFileCacheParam, sTime, eTime global.Timestamp, upStatus chan bool)

UpdataKlineFileCache 更新K线数据的文件缓存 (Kline,Trade,Depth)

参数: di 数据索引
参数: sTime 更新的开始时间
参数: eTime 更新的截止时间
返回值: kbs 返回KlineBar指针的Slice

func (*BaseAction) UpdataTradeFileCache

func (this *BaseAction) UpdataTradeFileCache(uParam global.UpdataFileCacheParam, sTime, eTime global.Timestamp) (err error)

UpdataKlineFileCache 更新K线数据的文件缓存 (Kline,Trade,Depth)

参数: di 数据索引
参数: sTime 更新的开始时间
参数: eTime 更新的截止时间
返回值: kbs 返回KlineBar指针的Slice

type LoadPastData

type LoadPastData struct {
	*BaseAction
	sync.Mutex
	// contains filtered or unexported fields
}

func NewLoadPastData

func NewLoadPastData(ba *BaseAction, di global.DataIndex, sTime, eTime global.Timestamp, upStatus chan bool) (lpd *LoadPastData, err error)

func (*LoadPastData) CloseWs

func (this *LoadPastData) CloseWs()

CloseWs 主动关闭连接

func (*LoadPastData) ReConnect

func (this *LoadPastData) ReConnect()

Reconnect 断开重连

func (*LoadPastData) SendMsg

func (this *LoadPastData) SendMsg(msg *Msg)

给Master发送数据,队列的形式,防止WS并发写

type Msg

type Msg struct {
	Op       string      `json:"op"`       // 操作项,大的方向是要干什么,例如 订阅(sub),获取数据(get)...
	Platform string      `json:"platform"` // 平台,可以是事件总线(master),也可以是某个交易所,例如:火币全球(huobipro),币安(binance),OKEX(okex)...
	Symbol   string      `json:"symbol"`   // 交易对符号,例如:btc_usdt,eth_usdt,ht_usdt,bnb_usdt
	Action   string      `json:"action"`   // 动作,也就是干什么,例如: trade(成交数据),kline(K线数据),depth(深度数据),order(订单数据)
	Param    url.Values  `json:"param"`    // 具体参数,例如 limit=123&stime=180020209920&etime=1902312312312
	Data     interface{} `json:"data"`     // 具体的数据
}

消息类型

func (*Msg) ToAssets

func (this *Msg) ToAssets() (aData *global.AssetsData)

把Msg消息中的Data转换成AssetsData(资产类型的数据)

func (*Msg) ToDepth

func (this *Msg) ToDepth() (dData *global.DepthData)

把Msg消息中的Data转换成 DepthData(深度类型的数据)

func (*Msg) ToKlineBarSlice

func (this *Msg) ToKlineBarSlice() (kbs []global.KlineBar, err error)

把Msg消息中的Data转换成 klineBarList (K线棒列表类型的数据),返回的是按照ID从小到大排序

func (*Msg) ToOrder

func (this *Msg) ToOrder() (oData *global.OrderData)

把Msg消息中的Data转换成OrderData(订单类型的数据)

func (*Msg) ToTradeInfoSlice

func (this *Msg) ToTradeInfoSlice() (tdList []global.TradeInfo, err error)

把Msg消息中的Data转换成 TradeData(交易类型的数据)

Directories

Path Synopsis
历史数据更新
历史数据更新

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL