common

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SideTypeBuy  SideType = "buy"
	SideTypeSell SideType = "sell"

	RequestMethodGET  RequestMethod = "GET"
	RequestMethodPOST RequestMethod = "POST"

	SpotInstType    InstType = "SPOT"    // 币币
	MarginInstType  InstType = "MARGIN"  // 币币杠杆
	SwapInstType    InstType = "SWAP"    // 永续合约
	FuturesInstType InstType = "FUTURES" // 交割合约
	OptionInstType  InstType = "OPTION"  // 期权
	AnyInstType     InstType = "ANY"     // 全部

	Isolated TdMode = "isolated" // 逐仓
	Cross    TdMode = "cross"    // 全仓
	Cash     TdMode = "cash"     // 现金

	Market          OrderType = "market"            // 市价单
	Limit           OrderType = "limit"             // 限价单
	PostOnl         OrderType = "post_onl"          // 只做maker单
	Fok             OrderType = "fok"               // 全部成交或立即取消
	Ioc             OrderType = "ioc"               // 立即成交并取消剩余
	OptimalLimitIoc OrderType = "optimal_limit_ioc" // 市价委托立即成交并取消剩余(仅适用交割、永续)

	Net   PosSide = "net"   // 在单向持仓模式下,默认 net
	Long  PosSide = "long"  // 在双向持仓模式下必填,仅适用于交割/永续 多
	Short PosSide = "short" // 在双向持仓模式下必填,仅适用于交割/永续 空

	OrderOp      Operate = "order"        // 创建订单
	BatchOrderOp Operate = "batch-orders" // 批量创建订单
)

Variables

This section is empty.

Functions

func EpochTime

func EpochTime() string

EpochTime Get a epoch time eg: 1521221737

func HmacSha256Base64Signer

func HmacSha256Base64Signer(message string, secretKey string) (string, error)

HmacSha256Base64Signer signing a message using: hmac sha256 + base64 eg:

message = Pre_hash function comment
secretKey = E65791902180E9EF4510DB6A77F6EBAE

return signed string = TO6uwdqz+31SIPkd4I+9NiZGmVH74dXi+Fd5X0EzzSQ=

func IsoTime

func IsoTime() string

IsoTime Get a iso time eg: 2018-03-16T18:02:48.284Z

func NewJSON

func NewJSON(data []byte) (j *simplejson.Json, err error)

func PreHashString

func PreHashString(timestamp string, method RequestMethod, requestPath string, body string) string

PreHashString the pre hash string eg:

timestamp = 2018-03-08T10:59:25.789Z
method  = POST
request_path = /orders?before=2&limit=30
body = {"product_id":"BTC-USD-0309","order_id":"377454671037440"}

return pre hash string = 2018-03-08T10:59:25.789ZPOST/orders?before=2&limit=30{"product_id":"BTC-USD-0309","order_id":"377454671037440"}

Types

type BaseURL

type BaseURL string

BaseURL url

type InstType added in v0.1.1

type InstType string

InstType 产品类型

type Operate added in v0.1.1

type Operate string

Operate 业务操作

type OrderType added in v0.1.1

type OrderType string

OrderType 订单类型

type PosSide added in v0.1.1

type PosSide string

PosSide 持仓方向

type PriceLevel

type PriceLevel struct {
	Price    string
	Quantity string
	Pending  string
}

PriceLevel 价格信息

func (*PriceLevel) Parse

func (p *PriceLevel) Parse() (float64, float64, float64, error)

Parse 转换

type RequestMethod

type RequestMethod string

RequestMethod 请求方式

type SideType

type SideType string

SideType 交易方向

type TdMode added in v0.1.1

type TdMode string

TdMode 交易模式

Jump to

Keyboard shortcuts

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