Documentation ¶
Index ¶
- Constants
- Variables
- func CancelAllUnfinishedOrders(api API, symbol Symbol) int
- func FlateUnCompress(data []byte) ([]byte, error)
- func FloatToString(v float64, n int) string
- func FloatToStringForEx(v float64) string
- func FmtBalance(balance float64, usdt float64, usdtFrozen float64, currency float64, ...) string
- func FmtBalanceExt(balance float64, usdt float64, usdtFrozen float64, fmex float64, ...) string
- func FmtOrder(symbol string, price float64, amount float64, state string, ...) string
- func FmtPaxMemoryStates(curBuyPrice float64, curSellPrice float64, lastBuyPrice float64, ...) string
- func FmtTicker(ticker *Ticker) string
- func GetParamHmacMD5Sign(secret, params string) (string, error)
- func GetParamHmacSHA1Sign(secret, params string) (string, error)
- func GetParamHmacSHA256Base64Sign(secret, params string) (string, error)
- func GetParamHmacSHA256Sign(secret, params string) (string, error)
- func GetParamHmacSHA512Base64Sign(hmac_key string, hmac_data string) string
- func GetParamHmacSHA512Sign(secret, params string) (string, error)
- func GetParamHmacSha384Sign(secret, params string) (string, error)
- func GetParamMD5Sign(secret, params string) (string, error)
- func GetSHA(text string) (string, error)
- func GzipUnCompress(data []byte) ([]byte, error)
- func HttpDelete(client *http.Client, reqUrl string, postData url.Values, ...) ([]byte, error)
- func HttpGet(client *http.Client, reqUrl string) (map[string]interface{}, error)
- func HttpGet2(client *http.Client, reqUrl string, headers map[string]string) (map[string]interface{}, error)
- func HttpGet3(client *http.Client, reqUrl string, headers map[string]string) ([]interface{}, error)
- func HttpGet4(client *http.Client, reqUrl string, headers map[string]string, ...) error
- func HttpGet5(client *http.Client, reqUrl string, headers map[string]string) ([]byte, error)
- func HttpPost(client *http.Client, reqUrl string, postData map[string]string, ...) ([]byte, error)
- func HttpPost2(client *http.Client, reqUrl string, postData url.Values) ([]byte, error)
- func HttpPost3(client *http.Client, reqUrl string, postData url.Values, ...) ([]byte, error)
- func HttpPost4(client *http.Client, reqUrl string, postData string, headers map[string]string) ([]byte, error)
- func NewHttpRequest(client *http.Client, reqType string, reqUrl string, postData string, ...) ([]byte, error)
- func Retry(retry int, delay time.Duration, method interface{}, params ...interface{}) interface{}
- func ToFloat64(v interface{}) float64
- func ToInt(v interface{}) int
- func ToInt64(v interface{}) int64
- func ToUint64(v interface{}) uint64
- func ValuesToJson(v url.Values) ([]byte, error)
- type API
- type Account
- type ApiError
- type Currency
- type Depth
- type DepthRecord
- type DepthRecords
- type Kline
- type NewOrder
- type Order
- type OrderState
- type OrderType
- type SubAccount
- type Symbol
- type Ticker
- type Trade
- type TradeSide
- type WsBuilder
- func (b *WsBuilder) Build() *WsConn
- func (b *WsBuilder) Dump() *WsBuilder
- func (b *WsBuilder) ErrorHandleFunc(f func(err error)) *WsBuilder
- func (b *WsBuilder) Heartbeat(data []byte, t time.Duration) *WsBuilder
- func (b *WsBuilder) Heartbeat2(heartbeat func() interface{}, t time.Duration) *WsBuilder
- func (b *WsBuilder) ProtoHandleFunc(f func([]byte) error) *WsBuilder
- func (b *WsBuilder) ProxyUrl(proxyUrl string) *WsBuilder
- func (b *WsBuilder) ReconnectIntervalTime(t time.Duration) *WsBuilder
- func (b *WsBuilder) ReqHeader(key, value string) *WsBuilder
- func (b *WsBuilder) UnCompressFunc(f func([]byte) ([]byte, error)) *WsBuilder
- func (b *WsBuilder) WsUrl(wsUrl string) *WsBuilder
- type WsConfig
- type WsConn
- func (ws *WsConn) CloseWs()
- func (ws *WsConn) HeartbeatTimer()
- func (ws *WsConn) NewWs() *WsConn
- func (ws *WsConn) ReConnect()
- func (ws *WsConn) ReConnectTimer()
- func (ws *WsConn) ReceiveMessage()
- func (ws *WsConn) SendJsonMessage(v interface{}) error
- func (ws *WsConn) SendTextMessage(data []byte) error
- func (ws *WsConn) Subscribe(subEvent interface{}) error
- func (ws *WsConn) UpdateActiveTime()
Constants ¶
View Source
const ( BUY = 1 + iota SELL )
View Source
const ( LIMIT = 1 + iota MARKET FOK IOC POST_ONLY )
View Source
const ( SUBMITTED = iota PARTIAL_FILLED PARTIAL_CANCELED FILLED CANCELED PENDING_CANCEL )
View Source
const ( KLINE_PERIOD_1MIN = 1 + iota KLINE_PERIOD_3MIN KLINE_PERIOD_5MIN KLINE_PERIOD_15MIN KLINE_PERIOD_30MIN KLINE_PERIOD_60MIN KLINE_PERIOD_1H KLINE_PERIOD_2H KLINE_PERIOD_4H KLINE_PERIOD_6H KLINE_PERIOD_8H KLINE_PERIOD_12H KLINE_PERIOD_1DAY KLINE_PERIOD_3DAY KLINE_PERIOD_1WEEK KLINE_PERIOD_1MONTH KLINE_PERIOD_1YEAR )
View Source
const ( FCOIN = "fcoin.com" FCOIN_PRO = "fcoin.pro" )
Variables ¶
View Source
var ( API_ERR = ApiError{ErrCode: "EX_ERR_0000", ErrMsg: "unknown error"} HTTP_ERR_CODE = ApiError{ErrCode: "HTTP_ERR_0001", ErrMsg: "http request error"} EX_ERR_API_LIMIT = ApiError{ErrCode: "EX_ERR_1000", ErrMsg: "api limited"} EX_ERR_SIGN = ApiError{ErrCode: "EX_ERR_0001", ErrMsg: "signature error"} EX_ERR_NOT_FIND_SECRETKEY = ApiError{ErrCode: "EX_ERR_0002", ErrMsg: "not find secretkey"} EX_ERR_NOT_FIND_APIKEY = ApiError{ErrCode: "EX_ERR_0003", ErrMsg: "not find apikey"} EX_ERR_INSUFFICIENT_BALANCE = ApiError{ErrCode: "EX_ERR_0004", ErrMsg: "Insufficient Balance"} EX_ERR_PLACE_ORDER_FAIL = ApiError{ErrCode: "EX_ERR_0005", ErrMsg: "place order failure"} EX_ERR_CANCEL_ORDER_FAIL = ApiError{ErrCode: "EX_ERR_0006", ErrMsg: "cancel order failure"} EX_ERR_INVALID_SYMBOL = ApiError{ErrCode: "EX_ERR_0007", ErrMsg: "invalid symbol"} EX_ERR_NOT_FIND_ORDER = ApiError{ErrCode: "EX_ERR_0008", ErrMsg: "not find order"} EX_ERR_SYMBOL_ERR = ApiError{ErrCode: "EX_ERR_0009", ErrMsg: "symbol error"} )
View Source
var ( UNKNOWN = Currency{"UNKNOWN", ""} USDT = Currency{"USDT", ""} PAX = Currency{"PAX", ""} TUSD = Currency{"TUSD", ""} USDC = Currency{"USDC", ""} GUSD = Currency{"GUSD", ""} BTC = Currency{"BTC", ""} BCH = Currency{"BCH", ""} BSV = Currency{"BSV", ""} ETH = Currency{"ETH", ""} ETC = Currency{"ETC", ""} LTC = Currency{"LTC", ""} EOS = Currency{"EOS", ""} XRP = Currency{"XRP", ""} FT = Currency{"FT", "FCoin Token"} FMEX = Currency{"FMEX", "FCoin Contract Token"} PAX_USDT = Symbol{PAX, USDT} TUSD_USDT = Symbol{TUSD, USDT} USDC_USDT = Symbol{USDC, USDT} GUSD_USDT = Symbol{GUSD, USDT} BTC_USDT = Symbol{BTC, USDT} BCH_USDT = Symbol{BCH, USDT} BSV_USDT = Symbol{BSV, USDT} ETH_USDT = Symbol{ETH, USDT} ETC_USDT = Symbol{ETC, USDT} LTC_USDT = Symbol{LTC, USDT} EOS_USDT = Symbol{EOS, USDT} XRP_USDT = Symbol{XRP, USDT} FT_USDT = Symbol{FT, USDT} FMEX_USDT = Symbol{FMEX, USDT} UNKNOWN_SYMBOL = Symbol{UNKNOWN, UNKNOWN} )
Functions ¶
func FlateUnCompress ¶
func FloatToString ¶
func FloatToStringForEx ¶
func FmtBalance ¶
func FmtBalanceExt ¶
func FmtPaxMemoryStates ¶
func GetParamHmacMD5Sign ¶
func GetParamHmacSHA1Sign ¶
func GetParamHmacSHA256Sign ¶
func GetParamHmacSHA512Sign ¶
func GetParamHmacSha384Sign ¶
func GetParamMD5Sign ¶
func GzipUnCompress ¶
func HttpDelete ¶
func NewHttpRequest ¶
Types ¶
type API ¶
type API interface { GetExchangeName() string GetAccount() (*Account, error) GetSubAccount(currency Currency) (*SubAccount, error) LimitBuy(amount, price string, symbol Symbol) (*NewOrder, error) LimitSell(amount, price string, symbol Symbol) (*NewOrder, error) MarketBuy(amount, price string, symbol Symbol) (*NewOrder, error) MarketSell(amount, price string, symbol Symbol) (*NewOrder, error) GetActiveOrders(symbol Symbol) ([]NewOrder, error) CancelOrder(orderId string, symbol Symbol) (bool, error) GetOrder(orderId string, symbol Symbol) (*NewOrder, error) GetOrderHistorys(symbol Symbol, currentPage, pageSize int) ([]NewOrder, error) GetTicker(symbol Symbol) (*Ticker, error) GetDepth(size int, symbol Symbol) (*Depth, error) GetKlines(symbol Symbol) ([]Kline, error) IsOrderable(symbol Symbol) (bool, error) GetTrades(symbol Symbol, since int64) ([]Trade, error) }
type Account ¶
type Account struct { Exchange string Asset float64 //总资产 NetAsset float64 //净资产 SubAccounts map[Currency]SubAccount }
type Currency ¶
func NewCurrency ¶
type Depth ¶
type Depth struct { Symbol string UTime time.Time AskList DepthRecords //Descending order BidList DepthRecords //Descending order }
type DepthRecord ¶
type DepthRecords ¶
type DepthRecords []DepthRecord
func (DepthRecords) Len ¶
func (dr DepthRecords) Len() int
func (DepthRecords) Less ¶
func (dr DepthRecords) Less(i, j int) bool
func (DepthRecords) Swap ¶
func (dr DepthRecords) Swap(i, j int)
type OrderState ¶
type OrderState int
func (OrderState) String ¶
func (state OrderState) String() string
type SubAccount ¶
type Symbol ¶
func NewSymbol2 ¶
type Ticker ¶
type Ticker struct { Symbol string `json:"symbol"` Last float64 `json:"last,string"` //最新成交价 LastVol float64 `json:"last_vol,string"` //最近一笔成交的成交量 Buy float64 `json:"buy,string"` //最大买一价 BuyVol float64 `json:"buy_vol,string"` //最大买一量 Sell float64 `json:"sell,string"` //最小卖一价 SellVol float64 `json:"sell_vol,string"` //最小卖一量 High float64 `json:"high,string"` //24小时内最高价 Low float64 `json:"low,string"` //24小时内最低价 BaseVol float64 `json:"base_vol,string"` //24小时内基准货币成交量 }
type WsBuilder ¶
type WsBuilder struct {
// contains filtered or unexported fields
}
func NewWsBuilder ¶
func NewWsBuilder() *WsBuilder
func (*WsBuilder) ErrorHandleFunc ¶
func (*WsBuilder) Heartbeat2 ¶
func (*WsBuilder) ProtoHandleFunc ¶
func (*WsBuilder) ReconnectIntervalTime ¶
func (*WsBuilder) UnCompressFunc ¶
type WsConfig ¶
type WsConfig struct { WsUrl string ProxyUrl string ReqHeaders map[string][]string //连接的时候加入的头部信息 HeartbeatIntervalTime time.Duration HeartbeatData []byte //心跳数据 HeartbeatFunc func() interface{} //心跳数据2 ReconnectIntervalTime time.Duration //定时重连时间间隔 ProtoHandleFunc func([]byte) error //协议处理函数 UnCompressFunc func([]byte) ([]byte, error) //解压函数 ErrorHandleFunc func(err error) IsDump bool }
type WsConn ¶
type WsConn struct { *websocket.Conn sync.Mutex WsConfig // contains filtered or unexported fields }
func (*WsConn) HeartbeatTimer ¶
func (ws *WsConn) HeartbeatTimer()
func (*WsConn) ReConnectTimer ¶
func (ws *WsConn) ReConnectTimer()
func (*WsConn) ReceiveMessage ¶
func (ws *WsConn) ReceiveMessage()
func (*WsConn) SendJsonMessage ¶
func (*WsConn) SendTextMessage ¶
func (*WsConn) UpdateActiveTime ¶
func (ws *WsConn) UpdateActiveTime()
Click to show internal directories.
Click to hide internal directories.