zb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package zb zb rest api package

Index

Constants

View Source
const (
	MarketAPI = "http://api.zb.com/data/v1/"
	TradeAPI  = "https://trade.zb.com/api/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ZB

type ZB struct {
	AccessKey string
	SecretKey string
}

ZB API data

func New

func New(accessKey string, secretKey string) *ZB

New create new Zb API data

func (*ZB) CancelOrder

func (z *ZB) CancelOrder(id string, base string, quote string) error

CancelOrder 取消委托

* id: 委托挂单号 * currency: quote_base

  • btc_cny: 比特币/人民币
  • ltc_cny: 莱特币/人民币
  • eth_cny: 以太币/人民币
  • etc_cny: ETC币/人民币
  • bts_cny: BTS币/人民币

func (*ZB) GetOrder

func (z *ZB) GetOrder(id string, base string, quote string) (*model.ZBOrder, error)

GetOrder 获取委托买单或卖单 id: 委托挂单号

func (*ZB) GetOrderBook

func (z *ZB) GetOrderBook(base string, quote string, size int, merge float64) (*model.OrderBook, error)

GetOrderBook 市场深度

* size: 档位 1-50, 如果有合并深度, 只能返回 5 档深度 * merge:

  • btc_cny: 可选 1, 0.1
  • ltc_cny: 可选 0.5, 0.3, 0.1
  • eth_cny: 可选 0.5, 0.3, 0.1
  • etc_cny: 可选 0.3, 0.1
  • bts_cny: 可选 1, 0.1

func (*ZB) GetOrders

func (z *ZB) GetOrders(tradeType int, base string, quote string, pageIndex int) ([]*model.ZBOrder, error)

GetOrders 获取多个委托买单或卖单, 每次请求返回 10 条记录

func (*ZB) GetOrdersIgnoreTradeType

func (z *ZB) GetOrdersIgnoreTradeType(base string, quote string, pageIndex int, pageSize int) ([]*model.ZBOrder, error)

GetOrdersIgnoreTradeType 与getOrdersNew的区别是取消tradeType字段过滤,可同时获取买单和卖单,每次请求返回pageSize<100条记录

func (*ZB) GetOrdersNew

func (z *ZB) GetOrdersNew(tradeType int, base string, quote string, pageIndex int, pageSize int) ([]*model.ZBOrder, error)

GetOrdersNew (新)获取多个委托买单或卖单,每次请求返回pageSize<100条记录

func (*ZB) GetRecords

func (z *ZB) GetRecords(base string, quote string, typ string, since int, size int) ([]model.Record, error)

GetKline 获取 K 线数据

* currency: quote_base

  • btc_cny: 比特币/人民币
  • ltc_cny: 莱特币/人民币
  • eth_cny: 以太币/人民币
  • etc_cny: ETC币/人民币
  • bts_cny: BTS币/人民币

* typ:

  • 1min: 1 分钟
  • 3min: 3 分钟
  • 5min: 5 分钟
  • 15min: 15 分钟
  • 30min: 30 分钟
  • 1day: 1 日
  • 3day: 3 日
  • 1week: 1 周
  • 1hour: 1 小时
  • 2hour: 2 小时
  • 4hour: 4 小时
  • 6hour: 6小时
  • 12hour: 12 小时

* since: 从这个时间戳之后的 * size: 返回数据的条数限制(默认为 1000, 如果返回数据多于 1000 条, 那么只返回 1000 条)

func (*ZB) GetTicker

func (z *ZB) GetTicker(base string, quote string) (*model.Ticker, error)

GetTicker 行情

func (*ZB) GetTrades

func (z *ZB) GetTrades(base string, quote string, since int) (*model.Trades, error)

GetTrades 获取历史成交

* currency: quote_base

  • btc_cny: 比特币/人民币
  • ltc_cny: 莱特币/人民币
  • eth_cny: 以太币/人民币
  • etc_cny: ETC币/人民币
  • bts_cny: BTS币/人民币

* since: 从指定交易 ID 后 50 条数据

func (*ZB) GetUnfinishedOrdersIgnoreTradeType

func (z *ZB) GetUnfinishedOrdersIgnoreTradeType(base string, quote string, pageIndex int, pageSize int) ([]*model.ZBOrder, error)

GetUnfinishedOrdersIgnoreTradeType 获取未成交或部份成交的买单和卖单,每次请求返回pageSize<=100条记录

func (*ZB) GetUserAddress

func (z *ZB) GetUserAddress(currency string) (string, error)

GetUserAddress 获取用户充值地址

* currency:

  • btc: BTC
  • ltc: LTC
  • eth: 以太币
  • etc: ETC币

func (*ZB) GetWithdrawAddress

func (z *ZB) GetWithdrawAddress(currency string) (string, error)

GetWithdrawAddress 获取用户认证的提现地址

* currency:

  • btc: BTC
  • ltc: LTC
  • eth: 以太币
  • etc: ETC币

func (*ZB) PlaceOrder

func (z *ZB) PlaceOrder(price float64, amount float64, tradeType int, base string, quote string) (string, error)

PlaceOrder 委托下单

* price: 单价(cny 保留小数后 2 位, btc 保留小数后 6 位) * amount: 交易数量(btc, ltc, eth, etc保留小数后 3 位) * tradeType: 交易类型 1/0[buy / sell] * currency: quote_base

  • btc_cny: 比特币/人民币
  • ltc_cny: 莱特币/人民币
  • eth_cny: 以太币/人民币
  • etc_cny: ETC币/人民币
  • bts_cny: BTS币/人民币

return 委托挂单号

func (*ZB) SecretDigest

func (z *ZB) SecretDigest() string

SecretDigest calc secert digest

func (*ZB) Sign

func (z *ZB) Sign(uri string) string

Sign calc sign string

Jump to

Keyboard shortcuts

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