babeltrader_common_go

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 1, 2019 License: MIT Imports: 0 Imported by: 16

Documentation

Index

Constants

View Source
const (
	OrderStatus_Unknown      = 0
	OrderStatus_PartDealed   = 1
	OrderStatus_AllDealed    = 2
	OrderStatus_Canceled     = 3
	OrderStatus_Canceling    = 4
	OrderStatus_PartCanceled = 5
	OrderStatus_Rejected     = 6
)
View Source
const (
	Market_CTP    = "ctp"
	Market_IB     = "ib"
	Market_XTP    = "xtp"
	Market_OKEX   = "okex"
	Market_BITMEX = "bitmex"
)
View Source
const (
	Exchange_SHFE   = "SHFE"
	Exchange_CZCE   = "CZCE"
	Exchange_DCE    = "DCE"
	Exchange_CFFEX  = "CFFEX"
	Exchange_INE    = "INE"
	Exchange_SSE    = "SSE"
	Exchange_SZSE   = "SZSE"
	Exchange_CME    = "CME"
	Exchange_CBOT   = "CBOT"
	Exchange_NYMEX  = "NYMEX"
	Exchange_COMEX  = "COMEX"
	Exchange_CBOE   = "CBOE"
	Exchange_OKEX   = "okex"
	Exchange_Bitmex = "bitmex"
)
View Source
const (
	ProductType_Future = "future"
	ProductType_Option = "option"
	ProductType_Spot   = "spot"
	ProductType_ETF    = "etf"
	ProductType_IPO    = "ipo"
)
View Source
const (
	QuoteInfo1_MarketData = "marketdata"
	QuoteInfo1_Kline      = "kline"
	QuoteInfo1_OrderBook  = "orderbook"
	QuoteInfo1_Level2     = "level2"
	QuoteInfo1_Depth      = "depth"
	QuoteInfo1_DepthL2    = "depthL2"
	QuoteInfo1_Ticker     = "ticker"
)
View Source
const (
	QuoteInfo2_1Hour = "1h"
	QuoteInfo2_1Min  = "1m"
)
View Source
const (
	OrderType_Limit  = "limit"
	OrderType_Market = "market"
	OrderType_Best   = "best"
)
View Source
const (
	OrderFlag1_Speculation = "speculation"
	OrderFlag1_Arbitrage   = "arbitrage"
	OrderFlag1_Hedge       = "hedge"
	OrderFlag1_Marketmaker = "marketmaker"
)
View Source
const (
	OrderAction_Open         = "open"
	OrderAction_Close        = "close"
	OrderAction_CloseToday   = "closetoday"
	OrderAction_CloseHistory = "closehistory"
	OrderAction_ForceClose   = "forceclose"
	OrderAction_Buy          = "buy"
	OrderAction_Sell         = "sell"
	OrderAction_Borrow       = "borrow"
	OrderAction_Lend         = "lend"
)
View Source
const (
	OrderDir_Net   = "net"
	OrderDir_Long  = "long"
	OrderDir_Short = "short"
)
View Source
const (
	AccountType_Normal      = "normal"
	AccountType_Credit      = "credit"
	AccountType_Derivatives = "derivatives"
)
View Source
const (
	OrderBookL2Action_Entrust = "entrust"
	OrderBookL2Action_Trade   = "trade"
)
View Source
const (
	OrderBookL2TradeFlag_Buy    = "buy"
	OrderBookL2TradeFlag_Sell   = "sell"
	OrderBookL2TradeFlag_Cancel = "cancel"
	OrderBookL2TradeFlag_Deal   = "deal"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageHttpHeader

type MessageHttpHeader struct {
	User  string      `json:"user"`
	Token string      `json:"token"`
	Data  interface{} `json:"data"`
}

////////////////////// system ////////////////////////

type MessageLogin

type MessageLogin struct {
	User     string `json:"user"`
	Password string `json:"password"`
}

type MessageOrder

type MessageOrder struct {
	UserId        string  `json:"user_id,omitempty"`
	OrderId       string  `json:"order_id,omitempty"`
	OutsideUserId string  `json:"outside_user_id,omitempty"`
	OutsideId     string  `json:"outside_id,omitempty"`
	ClientOrderId string  `json:"client_order_id,omitempty"`
	Market        string  `json:"market,omitempty"`
	Exchange      string  `json:"exchange,omitempty"`
	ProductType   string  `json:"type,omitempty"`
	Symbol        string  `json:"symbol,omitempty"`
	Contract      string  `json:"contract,omitempty"`
	ContractId    string  `json:"contract_id,omitempty"`
	OrderType     string  `json:"order_type,omitempty"`
	OrderFlag1    string  `json:"order_flag1,omitempty"`
	Dir           string  `json:"dir,omitempty"`
	Price         float64 `json:"price,omitempty"`
	Amount        float64 `json:"amount,omitempty"`
	TotalPrice    float64 `json:"total_price,omitempty"`
	Leverage      float64 `json:"leverage,omitempty"`
	Timestamp     int64   `json:"ts,omitempty"`
}

////////////////////// trade ////////////////////////

order

type MessageOrderDeal

type MessageOrderDeal struct {
	Price      float64      `json:"price,omitempty"`
	Amount     float64      `json:"amount,omitempty"`
	TradingDay string       `json:"trading_day,omitempty"`
	TradeId    string       `json:"trade_id,omitempty"`
	Timestamp  int64        `json:"ts,omitempty"`
	Order      MessageOrder `json:"order,omitempty"`
}

type MessageOrderStatus

type MessageOrderStatus struct {
	Status       int          `json:"status"`
	SubmitStatus int          `json:"submit_status"`
	Amount       float64      `json:"amount"`
	DealedAmount float64      `json:"dealed_amount"`
	AvgPrice     float64      `json:"avg_price"`
	FaceVal      float64      `json:"face_value"`
	Timestamp    int64        `json:"ts,omitempty"`
	Order        MessageOrder `json:"order,omitempty"`
}

type MessageQuery

type MessageQuery struct {
	QueryId             string      `json:"qry_id"`
	CurrencyId          string      `json:"currency_id,omitempty"`
	UserId              string      `json:"user_id,omitempty"`
	OrderId             string      `json:"order_id,omitempty"`
	OutsideUserId       string      `json:"outside_user_id,omitempty"`
	OutsideId           string      `json:"outside_id,omitempty"`
	ClientOrderId       string      `json:"client_order_id,omitempty"`
	TradeId             string      `json:"trade_id,omitempty"`
	PositionSummaryType string      `json:"position_summary_type,omitempty"`
	PositionDetailType  string      `json:"position_detail_type,omitempty"`
	TradeAccountType    string      `json:"trade_account_type,omitempty"`
	ProductType         string      `json:"type,omitempty"`
	Market              string      `json:"market,omitempty"`
	Exchange            string      `json:"exchange,omitempty"`
	Symbol              string      `json:"symbol,omitempty"`
	Contract            string      `json:"contract,omitempty"`
	ContractId          string      `json:"contract_id,omitempty"`
	OrderType           string      `json:"order_type,omitempty"`
	OrderFlag1          string      `json:"order_flag1,omitempty"`
	Dir                 string      `json:"dir,omitempty"`
	Price               float64     `json:"price,omitempty"`
	Amount              float64     `json:"amount,omitempty"`
	TotalPrice          float64     `json:"total_price,omitempty"`
	Timestamp           int64       `json:"ts,omitempty"`
	TradingDay          string      `json:"trading_day,omitempty"`
	Data                interface{} `json:"data,omitempty"`
}

type MessageQuote

type MessageQuote struct {
	Market      string      `json:"market,omitempty"`      // e.g. okex, bitmex, NYMEX, ctp, xtp
	Exchange    string      `json:"exchange,omitempty"`    // e.g. SHFE, SSE, NYMEX, bitmex, okex
	Type        string      `json:"type,omitempty"`        // e.g. spot, future, option
	Symbol      string      `json:"symbol,omitempty"`      // e.g. btc, btc_usd, CL, rb
	Contract    string      `json:"contract,omitempty"`    // e.g. this_week, next_week, quarter, 1810
	ContractId  string      `json:"contract_id,omitempty"` // e.g. 20180928 for coin or repeat Contract for commodity future
	InfoPrimary string      `json:"info1,omitempty"`       // e.g. ticker, depth, kline
	InfoExtra   string      `json:"info2,omitempty"`       // e.g. 1m, 1h, 5
	Data        interface{} `json:"data,omitempty"`        // e.g. MessageQuoteTicker, MessageQuoteDepth
}

common message quote

type MessageQuoteDepth

type MessageQuoteDepth struct {
	Asks      [][]float64 `json:"asks"`
	Bids      [][]float64 `json:"bids"`
	Timestamp int64       `json:"ts"`
}

depth

type MessageQuoteKLine

type MessageQuoteKLine struct {
	Timestamp int64   `json:"ts"`
	Open      float64 `json:"open"`
	High      float64 `json:"high"`
	Low       float64 `json:"low"`
	Close     float64 `json:"close"`
	Vol       float64 `json:"vol"`
}

kline

type MessageQuoteLevel2

type MessageQuoteLevel2 struct {
	Timestamp int64       `json:"ts"`
	Action    string      `json:"action"`
	Data      interface{} `json:"data,omitempty"`
}

level2

type MessageQuoteLevel2Entrust

type MessageQuoteLevel2Entrust struct {
	ChannelNo int64   `json:"channel_no"`
	Seq       int64   `json:"seq"`
	Price     float64 `json:"price"`
	Vol       float64 `json:"vol"`
	BidNo     int64   `json:"bid_no"`
	AskNo     int64   `json:"ask_no"`
	TradeFlag string  `json:"trade_flag"`
}

type MessageQuoteLevel2Trade

type MessageQuoteLevel2Trade struct {
	ChannelNo int64   `json:"channel_no"`
	Seq       int64   `json:"seq"`
	Price     float64 `json:"price"`
	Vol       float64 `json:"vol"`
	Dir       string  `json:"dir"`
	OrderType string  `json:"order_type"`
}

type MessageQuoteMarketData

type MessageQuoteMarketData struct {
	Timestamp       int64       `json:"ts,omitempty"`
	Last            float64     `json:"last,omitempty"`
	Asks            [][]float64 `json:"asks"`
	Bids            [][]float64 `json:"bids"`
	Vol             float64     `json:"vol,omitempty"`
	Turnover        float64     `json:"turnover,omitempty"`
	AvgPrice        float64     `json:"avg_price,omitempty"`
	PreSettlement   float64     `json""pre_settlement,omitempty"`
	PreClose        float64     `json:"pre_close,omitempty"`
	PreOpenInterest float64     `json:"pre_open_interest,omitempty"`
	Settlement      float64     `json:"settlement,omitempty"`
	Close           float64     `json:"close,omitempty"`
	OpenInterest    float64     `json:"open_interest,omitempty"`
	UpperLimit      float64     `json:"upper_limit,omitempty"`
	LowerLimit      float64     `json:"lower_limit,omitempty"`
	Open            float64     `json:"open,omitempty"`
	High            float64     `json:"high,omitempty"`
	Low             float64     `json:"low,omitempty"`
	TradingDay      float64     `json:"trading_day,omitempty"`
	ActionDay       float64     `json:"action_day,omitempty"`
}

////////////////////// quotes ////////////////////////

marketdata

type MessageQuoteOrderBook

type MessageQuoteOrderBook struct {
	Timestamp int64       `json:"ts"`
	Last      float64     `json:"last"`
	Vol       float64     `json:"vol"`
	Asks      [][]float64 `json:"asks"`
	Bids      [][]float64 `json:"bids"`
}

orderbook

type MessageQuoteTicker

type MessageQuoteTicker struct {
	Bid       float64 `json:"bid"`
	Ask       float64 `json:"ask"`
	Last      float64 `json:"last"`
	High      float64 `json:"high"`
	Low       float64 `json:"low"`
	Vol       float64 `json:"vol"`
	Timestamp int64   `json:"ts"`
}

ticker

type MessageReqCommon

type MessageReqCommon struct {
	Message string      `json:"msg"`
	Data    interface{} `json:"data,omitempty"`
}

////////////////////// common ////////////////////////

common request message

type MessageRspCommon

type MessageRspCommon struct {
	Message string      `json:"msg"` // e.g. ticker, depth, order, deal, balances, positions
	ErrId   int64       `json:"error_id"`
	ErrMsg  string      `json:"error_msg,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

common response message

type MessageSubUnsub

type MessageSubUnsub struct {
	Market      string `json:"market,omitempty"`      // e.g. okex, bitmex, NYMEX, ctp, xtp
	Exchange    string `json:"exchange,omitempty"`    // e.g. SHFE, SSE, NYMEX, bitmex, okex
	Type        string `json:"type,omitempty"`        // e.g. spot, future, option
	Symbol      string `json:"symbol,omitempty"`      // e.g. btc, btc_usd, CL, rb
	Contract    string `json:"contract,omitempty"`    // e.g. this_week, next_week, quarter, 1810
	ContractId  string `json:"contract_id,omitempty"` // e.g. 20180928 for coin or repeat Contract for commodity future
	InfoPrimary string `json:"info1,omitempty"`       // e.g. ticker, depth, kline
	InfoExtra   string `json:"info2,omitempty"`       // e.g. 1m, 1h, 5
	Subed       int    `json:"subed,omitempty"`
}

subunsub

Jump to

Keyboard shortcuts

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