Documentation
¶
Index ¶
- Variables
- func CancelAllUnfinishedFutureOrders(api FutureRestAPI, contractType string, currencyPair cons.CurrencyPair) int
- func CancelAllUnfinishedOrders(api API, currencyPair cons.CurrencyPair) int
- 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(hmacKey string, hmacData 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 RE(retry int, delay time.Duration, method any, params ...any) any
- type API
- type APIConfig
- type Account
- type ApiError
- type BorrowParameter
- type DepositWithdrawHistory
- type Depth
- type DepthRecord
- type DepthRecords
- type FutureAccount
- type FutureKline
- type FutureOrder
- type FuturePosition
- type FutureRestAPI
- type FutureSubAccount
- type FutureTicker
- type FuturesContractInfo
- type FuturesWsApi
- type HistoricalFunding
- type Kline
- type MarginAccount
- type MarginSubAccount
- type OptionalParameter
- func (optional OptionalParameter) GetFloat64(name string) float64
- func (optional OptionalParameter) GetInt(name string) int
- func (optional OptionalParameter) GetInt64(name string) int64
- func (optional OptionalParameter) GetString(name string) string
- func (optional OptionalParameter) GetTime(name string) *time.Time
- func (optional OptionalParameter) Optional(name string, value any) OptionalParameter
- type PoloniexCurrency
- type RepaymentParameter
- type SpotWsApi
- type SubAccount
- type TickSize
- type Ticker
- type TransferParameter
- type WalletApi
- type WithdrawParameter
Constants ¶
This section is empty.
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_CURRENCY_PAIR = ApiError{ErrCode: "EX_ERR_0007", ErrMsg: "invalid currency pair"} 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"} )
Functions ¶
func CancelAllUnfinishedFutureOrders ¶
func CancelAllUnfinishedFutureOrders(api FutureRestAPI, contractType string, currencyPair cons.CurrencyPair) int
*
- call all unfinished future orders
- @return c 成功撤单数量
func CancelAllUnfinishedOrders ¶
func CancelAllUnfinishedOrders(api API, currencyPair cons.CurrencyPair) int
*
- call all unfinished orders
func GetParamHmacMD5Sign ¶
func GetParamHmacSHA1Sign ¶
func GetParamHmacSHA256Sign ¶
func GetParamHmacSHA512Sign ¶
func GetParamHmacSha384Sign ¶
for bitfinex.com
Types ¶
type API ¶
type API interface {
CancelOrder(orderId string, currency cons.CurrencyPair) (bool, error)
// GetOneOrder(orderId string, currency CurrencyPair) (*Order, error)
GetUnfinishedOrders(currency cons.CurrencyPair) ([]q.Order, error)
// GetOrderHistorys(currency CurrencyPair, opt ...OptionalParameter) ([]Order, error)
// GetAccount() (*Account, error)
// GetDepth(size int, currency CurrencyPair) (*Depth, error)
// GetKlineRecords(currency CurrencyPair, period KlinePeriod, size int, optional ...OptionalParameter) ([]Kline, error)
//none-personal but whole exchange center
// GetTicker(currency CurrencyPair) (*Ticker, error)
String() string
OneTicker(d q.D) (q.Bbo, error)
AllTicker(SymPair map[string]q.D) (*sync.Map, error)
PairArray() (map[string]q.D, map[q.D]q.P, error)
Fee() float64
TradeFee() (map[string]q.TradeFee, error)
WithdrawFee() ([]q.NetworkWithdraw, error)
PlaceOrders([3]q.Order) ([3]q.Order, error)
Balances() (*sync.Map, *sync.Map, error)
GetAttr() q.Attr
Test() bool
}
type BorrowParameter ¶
type BorrowParameter struct {
CurrencyPair cons.CurrencyPair
Currency cons.Currency
Amount float64
}
api parameter struct
type DepositWithdrawHistory ¶
type DepositWithdrawHistory struct {
WithdrawalId string `json:"withdrawal_id,omitempty"`
Currency string `json:"currency"`
Txid string `json:"txid"`
Amount float64 `json:"amount,string"`
From string `json:"from,omitempty"`
To string `json:"to"`
Memo string `json:"memo,omitempty"`
Fee string `json:"fee"`
Status int `json:"status,string"`
Timestamp time.Time `json:"timestamp"`
}
type Depth ¶
type Depth struct {
ContractType string `json:"contract_type,omitempty"` //for futures
ContractId string `json:"contract_id,omitempty"` // for futures
Pair cons.CurrencyPair
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 FutureAccount ¶
type FutureAccount struct {
FutureSubAccounts map[cons.Currency]FutureSubAccount
}
type FutureKline ¶
type FutureOrder ¶
type FutureOrder struct {
ClientOid string //自定义ID,GoEx内部自动生成
OrderID2 string //请尽量用这个字段替代OrderID字段
Price float64
Amount float64
AvgPrice float64
DealAmount float64
OrderID int64 //deprecated
OrderTime int64
Status cons.TradeStatus
Currency cons.CurrencyPair
OrderType int //ORDINARY=0 POST_ONLY=1 FOK= 2 IOC= 3
OType int //1:开多 2:开空 3:平多 4: 平空
LeverRate float64 //倍数
Fee float64 //手续费
ContractName string
FinishedTime int64 // finished timestamp
//策略委托单
TriggerPrice float64
AlgoType int //1:限价 2:市场价;触发价格类型,默认是限价;为市场价时,委托价格不必填;
}
type FuturePosition ¶
type FuturePosition struct {
BuyAmount float64
BuyAvailable float64
BuyPriceAvg float64
BuyPriceCost float64
BuyProfitReal float64
BuyProfit float64
CreateDate int64
LeverRate float64
SellAmount float64
SellAvailable float64
SellPriceAvg float64
SellPriceCost float64
SellProfitReal float64
SellProfit float64
Symbol cons.CurrencyPair //btc_usd:比特币,ltc_usd:莱特币
ContractType string
ContractId int64
ForceLiquPrice float64 //预估爆仓价
ShortPnlRatio float64 //空仓收益率
LongPnlRatio float64 //多仓收益率
}
type FutureRestAPI ¶
type FutureRestAPI interface {
/**
*获取交易所名字
*/
String() string
/**
*获取交割预估价
*/
GetFutureEstimatedPrice(currencyPair cons.CurrencyPair) (float64, error)
/**
* 期货行情
* @param currency_pair btc_usd:比特币 ltc_usd :莱特币
* @param contractType 合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度
*/
GetFutureTicker(currencyPair cons.CurrencyPair, contractType string) (*Ticker, error)
/**
* 期货深度
* @param currencyPair btc_usd:比特币 ltc_usd :莱特币
* @param contractType 合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度
* @param size 获取深度档数
* @return
*/
GetFutureDepth(currencyPair cons.CurrencyPair, contractType string, size int) (*Depth, error)
/**
* 期货指数
* @param currencyPair btc_usd:比特币 ltc_usd :莱特币
*/
GetFutureIndex(currencyPair cons.CurrencyPair) (float64, error)
/**
*全仓账户
*@param currency
*/
GetFutureUserinfo(currencyPair ...cons.CurrencyPair) (*FutureAccount, error)
/**
* @deprecated
* 期货下单
* @param currencyPair btc_usd:比特币 ltc_usd :莱特币
* @param contractType 合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度
* @param price 价格
* @param amount 委托数量
* @param openType 1:开多 2:开空 3:平多 4:平空
* @param matchPrice 是否为对手价 0:不是 1:是 ,当取值为1时,price无效
*/
PlaceFutureOrder(currencyPair cons.CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (string, error)
LimitFuturesOrder(currencyPair cons.CurrencyPair, contractType, price, amount string, openType int, opt ...cons.LimitOrderOptionalParameter) (*FutureOrder, error)
//对手价下单
MarketFuturesOrder(currencyPair cons.CurrencyPair, contractType, amount string, openType int) (*FutureOrder, error)
/**
* 取消订单
* @param symbol btc_usd:比特币 ltc_usd :莱特币
* @param contractType 合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度
* @param orderId 订单ID
*/
FutureCancelOrder(currencyPair cons.CurrencyPair, contractType, orderId string) (bool, error)
/**
* 用户持仓查询
* @param symbol btc_usd:比特币 ltc_usd :莱特币
* @param contractType 合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度
* @return
*/
GetFuturePosition(currencyPair cons.CurrencyPair, contractType string) ([]FuturePosition, error)
/**
*获取订单信息
*/
GetFutureOrders(orderIds []string, currencyPair cons.CurrencyPair, contractType string) ([]FutureOrder, error)
/**
*获取单个订单信息
*/
GetFutureOrder(orderId string, currencyPair cons.CurrencyPair, contractType string) (*FutureOrder, error)
/**
*获取未完成订单信息
*/
GetUnfinishFutureOrders(currencyPair cons.CurrencyPair, contractType string) ([]FutureOrder, error)
/**
* 获取个人订单历史,默认获取最近的订单历史列表,返回多少条订单数据,需根据平台接口定义而定
*/
GetFutureOrderHistory(pair cons.CurrencyPair, contractType string, optional ...OptionalParameter) ([]FutureOrder, error)
/**
*获取交易费
*/
GetFee() (float64, error)
/**
*获取交易所的美元人民币汇率
*/
//GetExchangeRate() (float64, error)
/**
*获取每张合约价值
*/
GetContractValue(currencyPair cons.CurrencyPair) (float64, error)
/**
*获取交割时间 星期(0,1,2,3,4,5,6),小时,分,秒
*/
GetDeliveryTime() (int, int, int, int)
/**
* 获取K线数据
*/
GetKlineRecords(contractType string, currency cons.CurrencyPair, period cons.KlinePeriod, size int, optional ...OptionalParameter) ([]FutureKline, error)
/**
* 获取Trade数据
*/
GetTrades(contractType string, currencyPair cons.CurrencyPair, since int64) ([]q.Trade, error)
}
type FutureSubAccount ¶
type FutureTicker ¶
type FuturesContractInfo ¶
type FuturesWsApi ¶
type FuturesWsApi interface {
DepthCallback(func(depth *Depth))
TickerCallback(func(ticker *FutureTicker))
TradeCallback(func(trade *q.Trade, contract string))
//OrderCallback(func(order *FutureOrder))
//PositionCallback(func(position *FuturePosition))
//AccountCallback(func(account *FutureAccount))
SubscribeDepth(pair cons.CurrencyPair, contractType string) error
SubscribeTicker(pair cons.CurrencyPair, contractType string) error
SubscribeTrade(pair cons.CurrencyPair, contractType string) error
}
type HistoricalFunding ¶
type MarginAccount ¶
type MarginSubAccount ¶
type OptionalParameter ¶
func (OptionalParameter) GetFloat64 ¶
func (optional OptionalParameter) GetFloat64(name string) float64
func (OptionalParameter) GetInt ¶
func (optional OptionalParameter) GetInt(name string) int
func (OptionalParameter) GetInt64 ¶
func (optional OptionalParameter) GetInt64(name string) int64
func (OptionalParameter) GetString ¶
func (optional OptionalParameter) GetString(name string) string
func (OptionalParameter) GetTime ¶
func (optional OptionalParameter) GetTime(name string) *time.Time
func (OptionalParameter) Optional ¶
func (optional OptionalParameter) Optional(name string, value any) OptionalParameter
type PoloniexCurrency ¶
type PoloniexCurrency struct {
ID int `json:"id"`
Name string `json:"name"`
HumanType string `json:"humanType"`
CurrencyType string `json:"currencyType"`
TxFee string `json:"txFee"`
MinConf int `json:"minConf"`
DepositAddress string `json:"depositAddress"`
Disabled int `json:"disabled"` //Designates whether (1) or not (0) deposits and withdrawals are disabled.
Frozen int `json:"frozen"` //Designates whether (1) or not (0) trading for this currency is disabled for trading.
Blockchain string `json:"blockchain"`
Delisted int `json:"delisted"`
IsGeofenced int `json:"isGeofenced"`
}
type RepaymentParameter ¶
type RepaymentParameter struct {
BorrowParameter
BorrowId string
}
type SpotWsApi ¶
type SpotWsApi interface {
DepthCallback(func(depth *Depth))
TickerCallback(func(ticker *Ticker))
TradeCallback(func(trade *q.Trade))
BBOCallback(func(bbo *q.Bbo))
//OrderCallback(func(order *Order))
//AccountCallback(func(account *Account))
SubscribeDepth(pair cons.CurrencyPair) error
SubscribeTicker(pair cons.CurrencyPair) error
SubscribeTrade(pair cons.CurrencyPair) error
SubscribeBBO(sm []string) error
}
type SubAccount ¶
type TransferParameter ¶
type WalletApi ¶
type WalletApi interface {
//获取钱包资产
GetAccount() (*Account, error)
//提币
Withdrawal(param WithdrawParameter) (withdrawId string, err error)
//划转资产
Transfer(param TransferParameter) error
//获取提币记录
GetWithDrawHistory(currency *cons.Currency) ([]DepositWithdrawHistory, error)
//获取充值记录
GetDepositHistory(currency *cons.Currency) ([]DepositWithdrawHistory, error)
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.