api

package
v0.0.0-...-df03107 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WelcomeMsg = iota
	AuthMsg
	SubscribeMsg
	ErrorMsg
	Message
)
View Source
const (
	TypeTrade = iota
	TypeQuote
	TypeOrder
	TypePosition
	TypeDepth
	TypeTick
	TypeKline
	TypeFunding
	TypeLiquidation
)
View Source
const (
	ActionPartial = iota
	ActionInsert
	ActionUpdate
	ActionDelete
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ExchangeAPI

type ExchangeAPI interface {
	Parse(data []byte) (*ParsedData, error)
	HandleMessage(ParsedData)

	GetExchangeName() string
	GetWsAuthHandler() WsAuthSubscribeHandler
	GetWsSubscribeHandler() WsAuthSubscribeHandler
	HistoryAPI
	TradeAPI
}

type HistoryAPI

type HistoryAPI interface {
	GetHistoryFunding(symbol string, start, end time.Time) ([]*model.Funding, error)
	GetHistoryKline(symbol, interval string, start, end time.Time) ([]*model.Kline, error)
}

type MsgData

type MsgData struct {
	Exchange string      `json:"exchange"`
	Type     int         `json:"type"`
	Action   int         `json:"action"`
	Symbol   string      `json:"symbol"`
	Data     interface{} `json:"data"`
}

type ParsedData

type ParsedData struct {
	Type int
	Data map[string]interface{}
}

type StrategyAPI

type StrategyAPI interface {
	// 收到trade data后执行
	AfterReceiveTrade(trade *model.Trade)
	// 收到quote data后执行
	AfterReceiveQuote(quote *model.Quote)

	// 当产生一个新tick数据后执行
	AfterTick(tick *model.Kline)
	// 当对应级别产生一个新k线后执行
	AfterKline(interval time.Duration, kline *model.Kline)
	// 当对应级别k线数据更新后执行
	AfterUpdateKline(interval time.Duration, kline *model.Kline)

	StrategyOrderAPI
	StrategyPositionAPI
	StrategyDepthAPI
}

type StrategyDepthAPI

type StrategyDepthAPI interface {
	// 当插入深度图信息(订单簿)后执行
	AfterInsertDepth(depth *model.DepthRecord)
	// 当更新深度图信息(订单簿)后执行
	AfterUpdateDepth(depth *model.DepthRecord)
	// 当删除深度图信息(订单簿)后执行
	AfterDeleteDepth(depth *model.DepthRecord)
}

type StrategyOrderAPI

type StrategyOrderAPI interface {
	// 当插入新订单后执行
	AfterInsertOrder(order *model.Order)
	// 当更新订单后执行
	AfterUpdateOrder(order *model.Order)
	// 当删除订单后执行
	AfterDeleteOrder(order *model.Order)
}

type StrategyPositionAPI

type StrategyPositionAPI interface {
	// 当插入新订单后执行
	AfterInsertPosition(order *model.Position)
	// 当更新订单后执行
	AfterUpdatePosition(order *model.Position)
	// 当删除订单后执行
	AfterDeletePosition(order *model.Position)
}

type TradeAPI

type TradeAPI interface {
	// 发送买入/卖出指令
	BuyOrSell(ord *TradeOrd) (map[string]interface{}, error)
	// 发送止损/止盈单
	StopOrd(ord *TradeOrd) (map[string]interface{}, error)
	// 调整杠杆
	EditLeverage(symbol string, leverage float64) (map[string]interface{}, error)
}

type TradeOrd

type TradeOrd struct {
	Exchange string  `form:"exchange" json:"exchange" binding:"required" map:"omit"`
	Symbol   string  `form:"symbol" json:"symbol" binding:"required"`
	Side     string  `form:"side" json:"side" binding:"required"`
	OrdType  string  `form:"ordType" json:"ordType" binding:"required"`
	OrderQty float64 `form:"orderQty" json:"orderQty" binding:"required"`
	Price    float64 `form:"price" json:"price" binding:"-" map:"omitempty"`
	StopPx   float64 `form:"stopPx" json:"stopPx" binding:"-" map:"omitempty"`
}

type WsAuthSubscribeHandler

type WsAuthSubscribeHandler interface {
	GetOperateArgs() []string
	Serialize() ([]byte, error)
}

Jump to

Keyboard shortcuts

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