Documentation
¶
Index ¶
- Constants
- Variables
- func CloneDefaultTransport() *http.Transport
- func GetParamHmacMD5Sign(secret, params string) (string, error)
- func GetParamHmacSHA256Base64Sign(secret, params string) (string, error)
- func GetParamHmacSHA256Sign(secret, params string) (string, error)
- func GetParamMD5Sign(secret, params string) (string, error)
- func GetSHA(text string) (string, error)
- func ParseProxy(proxyURL string) (res func(*http.Request) (*url.URL, error), err error)
- type AccountInfo
- type AccountInfoBase
- type AccountInfoCoin
- type AccountInfoResult
- type AllTicker
- type Depth
- type GeneralResult
- type KLine
- type LeverAssetsInfo
- type LeverAssetsInfoData
- type LeverAssetsInfoDatas
- type LeverAssetsInfoLever
- type Loan
- type LoanRecord
- type LoanRecordResponse
- type LoansResponse
- type Order
- type OrderMoreV2Response
- type OrderResponse
- type Repayment
- type RepaymentsResponse
- type Ticker
- type TickerData
- type Trade
- type WSDepth
- type WSTicker
- type WSTickerData
- type WSTrade
- type WSTrades
- type ZB
- func (z *ZB) AutoBorrow(marketName string, coin string, amount float64, interestRateOfDay float64, ...) (result GeneralResult, err error)
- func (z *ZB) Borrow(marketName string, coin string, amount float64, interestRateOfDay float64, ...) (result GeneralResult, err error)
- func (z *ZB) CancelOrder(symbol string, id int64, customOrderID string) (result OrderResponse, err error)
- func (z *ZB) DoAllRepay(marketName string) (result GeneralResult, err error)
- func (z *ZB) DoTransferFunds(amount float64, currency string, fromUserName string, toUserName string) (result GeneralResult, err error)
- func (z *ZB) GetAccountInfo() (result AccountInfo, err error)
- func (z *ZB) GetAllTicker() (tickers AllTicker, err error)
- func (z *ZB) GetDepth(symbol string, size int) (depth Depth, err error)
- func (z *ZB) GetKLine(symbol string, _type string, since int64, size int) (kLine KLine, err error)
- func (z *ZB) GetLeverAssetsInfo() (result LeverAssetsInfo, err error)
- func (z *ZB) GetLoanRecords(loanId string, marketName string, status int, pageIndex int, pageSize int) (result []LoanRecord, err error)
- func (z *ZB) GetLoans(coin string, pageIndex int, pageSize int) (result []Loan, err error)
- func (z *ZB) GetOrder(symbol string, id int64, customOrderID string) (result Order, err error)
- func (z *ZB) GetOrders(symbol string, tradeType int, pageIndex int) (result []Order, err error)
- func (z *ZB) GetOrdersIgnoreTradeType(symbol string, pageIndex int, pageSize int) (result []Order, err error)
- func (z *ZB) GetRepayments(loanRecordId string, pageIndex int, pageSize int) (result []Repayment, err error)
- func (z *ZB) GetTicker(symbol string) (ticker Ticker, err error)
- func (z *ZB) GetTrades(symbol string) (trades []Trade, err error)
- func (z *ZB) GetUnfinishedOrdersIgnoreTradeType(symbol string, pageIndex int, pageSize int) (result []Order, err error)
- func (z *ZB) HttpGet(reqUrl string, postData string, headers map[string]string, result interface{}) ([]byte, error)
- func (z *ZB) HttpPost(reqUrl string, postData string, headers map[string]string, result interface{}) ([]byte, error)
- func (z *ZB) NewHttpRequest(method string, reqUrl string, postData string, ...) ([]byte, error)
- func (z *ZB) PlaceOrder(symbol string, price float64, amount float64, tradeType int, acctType int, ...) (result OrderResponse, err error)
- func (z *ZB) PlaceOrderMore(symbol string, tradeParams [][]float64, tradeType int, acctType int) (result OrderMoreV2Response, err error)
- func (z *ZB) Repay(loanRecordId string, repayAmount float64, repayType int) (result GeneralResult, err error)
- func (z *ZB) SetProxy(proxyURL string) (err error)
- type ZBWebsocket
- func (ws *ZBWebsocket) SetDepthCallback(callback func(depth *WSDepth))
- func (ws *ZBWebsocket) SetTickerCallback(callback func(ticker *WSTicker))
- func (ws *ZBWebsocket) SetTradesCallback(callback func(trades *WSTrades))
- func (ws *ZBWebsocket) Subscribe(event string, channel string) (err error)
- func (ws *ZBWebsocket) SubscribeDepth(symbol string) (err error)
- func (ws *ZBWebsocket) SubscribeTicker(symbol string) (err error)
- func (ws *ZBWebsocket) SubscribeTrades(symbol string) (err error)
Constants ¶
const (
OK = 1000
)
Variables ¶
var (
DefaultTransport *http.Transport
)
Functions ¶
func CloneDefaultTransport ¶
func GetParamHmacMD5Sign ¶
func GetParamHmacSHA256Sign ¶
Types ¶
type AccountInfo ¶
type AccountInfoBase ¶
type AccountInfoCoin ¶
type AccountInfoCoin struct {
IsCanWithdraw bool `json:"isCanWithdraw"`
CanLoan bool `json:"canLoan"`
FundsType int `json:"fundstype"`
ShowName string `json:"showName"`
IsCanRecharge bool `json:"isCanRecharge"`
CnName string `json:"cnName"`
EnName string `json:"enName"`
Available float64 `json:"available,string"`
FreeZ float64 `json:"freez,string"`
UnitTag string `json:"unitTag"`
Key string `json:"key"`
UnitDecimal int `json:"unitDecimal"`
}
type AccountInfoResult ¶
type AccountInfoResult struct {
Coins []AccountInfoCoin `json:"coins"`
Version int64 `json:"version"`
Base AccountInfoBase `json:"base"`
}
type AllTicker ¶
type AllTicker map[string]TickerData
type GeneralResult ¶
type LeverAssetsInfo ¶
type LeverAssetsInfo struct {
Code int `json:"code"`
Message LeverAssetsInfoData `json:"message"`
}
type LeverAssetsInfoData ¶
type LeverAssetsInfoData struct {
Des string `json:"des"`
IsSuc bool `json:"isSuc"`
Datas LeverAssetsInfoDatas `json:"datas"`
}
type LeverAssetsInfoDatas ¶
type LeverAssetsInfoDatas struct {
LeverPerm bool `json:"leverPerm"`
Levers []LeverAssetsInfoLever `json:"levers"`
}
type LeverAssetsInfoLever ¶
type LeverAssetsInfoLever struct {
TotalConvertCNY string `json:"totalConvertCNY"`
LoanOutConvertUSD string `json:"loanOutConvertUSD"`
UnwindPrice string `json:"unwindPrice"`
FOverdraft string `json:"fOverdraft"`
FShowName string `json:"fShowName"`
StatusShow string `json:"statusShow"`
RepayLeverShow string `json:"repayLeverShow"`
CCanLoanIn int `json:"cCanLoanIn"`
FLoanIn string `json:"fLoanIn"`
COverdraft string `json:"cOverdraft"`
NetConvertUSD string `json:"netConvertUSD"`
LoanInConvertCNY string `json:"loanInConvertCNY"`
Key string `json:"key"`
FUnitDecimal int `json:"fUnitDecimal"`
RepayLevel int `json:"repayLevel"`
ShowName string `json:"showName"`
LoanInConvertUSD string `json:"loanInConvertUSD"`
Level int `json:"level"`
NetConvertCNY string `json:"netConvertCNY"`
CFreeze string `json:"cFreeze"`
CUnitTag string `json:"cUnitTag"`
CouldTransferOutCoin string `json:"couldTransferOutCoin"`
TotalConvertUSD string `json:"totalConvertUSD"`
CEnName string `json:"cEnName"`
LoanOutConvertCNY string `json:"loanOutConvertCNY"`
FAvailable string `json:"fAvailable"`
FEnName string `json:"fEnName"`
CShowName string `json:"cShowName"`
LeverMultiple string `json:"leverMultiple"`
CouldTransferOutFiat string `json:"couldTransferOutFiat"`
FFreeze string `json:"fFreeze"`
FCanLoanIn float64 `json:"fCanLoanIn"`
CLoanOut string `json:"cLoanOut"`
CUnitDecimal float64 `json:"cUnitDecimal"`
CLoanIn string `json:"cLoanIn"`
CAvailable string `json:"cAvailable"`
FLoanOut string `json:"fLoanOut"`
RepayLock bool `json:"repayLock"`
Status int `json:"status"`
}
type Loan ¶
type Loan struct {
Amount float64 `json:"amount,string"`
Balance float64 `json:"balance,string"`
CoinName string `json:"coinName"` // QC
RepaymentDay int `json:"repaymentDay"`
InterestRateOfDay float64 `json:"interestRateOfDay,string"`
LowestAmount float64 `json:"lowestAmount"`
RateOfDayShow string `json:"rateOfDayShow"` // 0.05 %
}
type LoanRecord ¶
type LoanRecord struct {
CreateTime int64 `json:"createTime"`
StatusShow string `json:"statusShow"`
FreezID string `json:"freezId"`
Tstatus int `json:"tstatus"`
WithoutLxAmount string `json:"withoutLxAmount"`
InvestMark bool `json:"investMark"`
WithoutLxDays int `json:"withoutLxDays"`
HasRepay string `json:"hasRepay"`
Amount string `json:"amount"`
ID int64 `json:"id"`
FwfScale string `json:"fwfScale"`
Rate string `json:"rate"`
MarketName string `json:"marketName"`
HasLx string `json:"hasLx"`
IsIn bool `json:"isIn"`
BalanceAmount string `json:"balanceAmount"`
FundType int `json:"fundType"`
OutUserID int64 `json:"outUserId"`
InUserID int64 `json:"inUserId"`
RepayDate int64 `json:"repayDate"`
ZheLx string `json:"zheLx"`
OutUserFees string `json:"outUserFees"`
DikouLx string `json:"dikouLx"`
SourceType int `json:"sourceType"`
CoinName string `json:"coinName"`
Reward string `json:"reward"`
Status int `json:"status"`
ArrearsLx string `json:"arrearsLx"`
BalanceWithoutLxDays int `json:"balanceWithoutLxDays"`
RiskManage int `json:"riskManage"`
RateAddVal string `json:"rateAddVal"`
OutUserName string `json:"outUserName"`
InUserName string `json:"inUserName"`
InUserLock bool `json:"inUserLock"`
RateForm int `json:"rateForm"`
LoanID int64 `json:"loanId"`
NextRepayDate int64 `json:"nextRepayDate"`
}
type LoanRecordResponse ¶
type LoanRecordResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Result []LoanRecord `json:"result"`
}
type LoansResponse ¶
type Order ¶
type Order struct {
Currency string `json:"currency"`
ID string `json:"id"`
Price float64 `json:"price"`
Status int `json:"status"`
TotalAmount float64 `json:"total_amount"`
TradeAmount float64 `json:"trade_amount"`
TradeDate int64 `json:"trade_date"`
TradeMoney float64 `json:"trade_money"`
Type int `json:"type"`
}
type OrderMoreV2Response ¶
type OrderResponse ¶
type RepaymentsResponse ¶
type Ticker ¶
type Ticker struct {
Date int64 `json:"date,string"` // 1587952260502
Ticker TickerData `json:"ticker"`
}
type TickerData ¶
type WSTicker ¶ added in v1.0.1
type WSTicker struct {
Date int64 `json:"date,string"` // (ms)
Ticker WSTickerData `json:"ticker"`
DataType string `json:"dataType"`
Channel string `json:"channel"`
}
type WSTickerData ¶ added in v1.0.1
type ZB ¶
type ZB struct {
// contains filtered or unexported fields
}
func NewZB ¶
func NewZB(httpClient *http.Client, host string, accessKey string, secretKey string, debugMode bool) *ZB
domain: zb.live/zb.com
func (*ZB) AutoBorrow ¶
func (z *ZB) AutoBorrow(marketName string, coin string, amount float64, interestRateOfDay float64, repaymentDay int, safePwd string) (result GeneralResult, err error)
AutoBorrow 自动借款 amount: 借入金额,小数位数不能超过4,超过系统自动截取前4位 interestRateOfDay: 日利率 [0.05-0.2] 百分比,小数位数不能超过3,超过系统自动截取前3位 repaymentDay: 借款期限 [10/20/30]天 safePwd: 资金安全密码
func (*ZB) Borrow ¶
func (z *ZB) Borrow(marketName string, coin string, amount float64, interestRateOfDay float64, repaymentDay int, isLoop int) (result GeneralResult, err error)
Borrow 借款 amount: 借入金额,小数位数不能超过4,超过系统自动截取前4位 interestRateOfDay: 日利率 [0.05-0.2] 百分比,小数位数不能超过3,超过系统自动截取前3位 repaymentDay: 借款期限 [10/20/30]天 isLoop: 是否自动续借 1/0(到期自动续借/到期自动还款)
func (*ZB) CancelOrder ¶
func (z *ZB) CancelOrder(symbol string, id int64, customOrderID string) (result OrderResponse, err error)
CancelOrder 取消委托
func (*ZB) DoAllRepay ¶
func (z *ZB) DoAllRepay(marketName string) (result GeneralResult, err error)
DoAllRepay 一键还款 marketName: 杠杆市场,示例:btcqc
func (*ZB) DoTransferFunds ¶
func (z *ZB) DoTransferFunds(amount float64, currency string, fromUserName string, toUserName string) (result GeneralResult, err error)
DoTransferFunds 主子账号内部转账 amount: 金额 currency: 币种 fromUserName: 转出方用户名 toUserName: 转入方用户名
func (*ZB) GetAccountInfo ¶
func (z *ZB) GetAccountInfo() (result AccountInfo, err error)
GetAccountInfo 获取用户信息
func (*ZB) GetAllTicker ¶
GetAllTicker 获取allTicker数据
func (*ZB) GetKLine ¶
GetKLine 获取K线 symbol: btc_usdt _type: 1min/3min/5min/15min/30min/1day/3day/1week/1hour/2hour/4hour/6hour/12hour since: 从这个时间戳之后的 (ms) size: 返回数据的条数限制(默认为1000,如果返回数据多于1000条,那么只返回1000条)
func (*ZB) GetLeverAssetsInfo ¶
func (z *ZB) GetLeverAssetsInfo() (result LeverAssetsInfo, err error)
GetLeverAssetsInfo 获取用户杠杆信息
func (*ZB) GetLoanRecords ¶
func (z *ZB) GetLoanRecords(loanId string, marketName string, status int, pageIndex int, pageSize int) (result []LoanRecord, err error)
GetLoanRecords 获取借贷记录 loanId: 理财id(借出就传 借入不用传) marketName: btsqc status: 状态(1还款中 2已还款 3 需要平仓 4 平仓还款 5自动还款中 6自动还款)
func (*ZB) GetOrdersIgnoreTradeType ¶
func (z *ZB) GetOrdersIgnoreTradeType(symbol string, pageIndex int, pageSize int) (result []Order, err error)
GetOrdersIgnoreTradeType 获取委托单忽略类型
func (*ZB) GetRepayments ¶
func (z *ZB) GetRepayments(loanRecordId string, pageIndex int, pageSize int) (result []Repayment, err error)
GetRepayments 获取还款记录 loanRecordId: 借贷记录id
func (*ZB) GetUnfinishedOrdersIgnoreTradeType ¶
func (z *ZB) GetUnfinishedOrdersIgnoreTradeType(symbol string, pageIndex int, pageSize int) (result []Order, err error)
GetUnfinishedOrdersIgnoreTradeType 未成交或部份成交挂单
func (*ZB) NewHttpRequest ¶
func (*ZB) PlaceOrder ¶
func (z *ZB) PlaceOrder(symbol string, price float64, amount float64, tradeType int, acctType int, customOrderID string) (result OrderResponse, err error)
PlaceOrder 委托下单 tradeType: 交易类型1/0[buy/sell] acctType: 杠杆 1/0[杠杆/现货](选填,默认为: 0 现货)
func (*ZB) PlaceOrderMore ¶
func (z *ZB) PlaceOrderMore(symbol string, tradeParams [][]float64, tradeType int, acctType int) (result OrderMoreV2Response, err error)
PlaceOrderMore 批量委托下单 交易参数,数组格式[[价格,数量],[价格,数量]],最多20个 tradeType: 交易类型1/0[buy/sell] acctType: 杠杆 1/0[杠杆/现货](选填,默认为: 0 现货)
type ZBWebsocket ¶ added in v1.0.1
type ZBWebsocket struct {
// contains filtered or unexported fields
}
func NewZBWebsocket ¶ added in v1.0.1
func NewZBWebsocket(host string, accessKey string, secretKey string, debugMode bool) *ZBWebsocket
NewZBWebsocket host: zb.live/zb.com
func (*ZBWebsocket) SetDepthCallback ¶ added in v1.0.1
func (ws *ZBWebsocket) SetDepthCallback(callback func(depth *WSDepth))
func (*ZBWebsocket) SetTickerCallback ¶ added in v1.0.1
func (ws *ZBWebsocket) SetTickerCallback(callback func(ticker *WSTicker))
func (*ZBWebsocket) SetTradesCallback ¶ added in v1.0.1
func (ws *ZBWebsocket) SetTradesCallback(callback func(trades *WSTrades))
func (*ZBWebsocket) Subscribe ¶ added in v1.0.1
func (ws *ZBWebsocket) Subscribe(event string, channel string) (err error)
func (*ZBWebsocket) SubscribeDepth ¶ added in v1.0.1
func (ws *ZBWebsocket) SubscribeDepth(symbol string) (err error)
func (*ZBWebsocket) SubscribeTicker ¶ added in v1.0.1
func (ws *ZBWebsocket) SubscribeTicker(symbol string) (err error)
func (*ZBWebsocket) SubscribeTrades ¶ added in v1.0.1
func (ws *ZBWebsocket) SubscribeTrades(symbol string) (err error)