broker

package
v2.2.17 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UseTestnet = false

UseTestnet switch all the API endpoints from production to the testnet

Functions

func FormatTimestamp

func FormatTimestamp(t time.Time) int64

FormatTimestamp formats a time into Unix timestamp in milliseconds, as requested by Binance.

Types

type ChangeApiPermissionRequest

type ChangeApiPermissionRequest struct {
	SubAccountID     string `json:"subaccountId"`
	SubAccountApiKey string `json:"subAccountApiKey"`
	CatTrade         bool   `json:"catTrade"`
	MarginTrade      bool   `json:"marginTrade"`
	FuturesTrade     bool   `json:"futuresTrade"`
}

ChangeApiPermissionRequest is a request struct

type ChangeApiPermissionResponse

type ChangeApiPermissionResponse struct {
	SubAccountID string `json:"subaccountId"`
	ApiKey       string `json:"apiKey"`
	CatTrade     bool   `json:"catTrade"`
	MarginTrade  bool   `json:"marginTrade"`
	FuturesTrade bool   `json:"futuresTrade"`
}

ChangeApiPermissionResponse is a response struct

type ChangeSubAccountCommissionRequest

type ChangeSubAccountCommissionRequest struct {
	SubAccountID          string
	MakerCommission       float32
	TakerCommission       float32
	MarginMakerCommission float32
	MarginTakerCommission float32
}

type ChangeSubAccountCommissionResponse

type ChangeSubAccountCommissionResponse struct {
	SubAccountID          string  `json:"subaccountId"`
	MakerCommission       float32 `json:"makerCommission"`
	TakerCommission       float32 `json:"takerCommission"`
	MarginMakerCommission float32 `json:"marginMakerCommission"`
	TakerMakerCommission  float32 `json:"marginTakerCommission"`
}

ChangeSubAccountCommissionResponse is response struct

type Client

type Client struct {
	HTTPClient *http.Client

	BaseURL    string
	TimeOffset int64
	Logger     *log.Logger
	Debug      bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiKey, secretKey string, writer io.Writer) *Client

NewClient creates new broker client

func (*Client) ChangeSubAccountApiPermission

func (c *Client) ChangeSubAccountApiPermission(ctx context.Context, req ChangeApiPermissionRequest, opts ...RequestOption) (res *ChangeApiPermissionResponse, err error)

ChangeSubAccountApiPermission make request

func (*Client) ChangeSubAccountCommission

func (c *Client) ChangeSubAccountCommission(ctx context.Context, req ChangeSubAccountCommissionRequest, opts ...RequestOption) (res *ChangeSubAccountCommissionResponse, err error)

ChangeSubAccountCommission make request

func (*Client) CreateApiKeyForSub

func (c *Client) CreateApiKeyForSub(ctx context.Context, req CreateApiKeyRequest, opts ...RequestOption) (res *CreateApiKeyResponse, err error)

CreateApiKeyForSub make request

func (*Client) CreateSubAccount

func (c *Client) CreateSubAccount(ctx context.Context, opts ...RequestOption) (res *SubAccount, err error)

CreateSubAccount creates new sub account

func (*Client) DeleteSubApiKey

func (c *Client) DeleteSubApiKey(ctx context.Context, req DeleteSubApiKeyRequest, opts ...RequestOption) error

DeleteSubApiKey deletes sub account api key

func (*Client) EnableFuturesSubAccount

func (c *Client) EnableFuturesSubAccount(ctx context.Context, subAccountId int, opts ...RequestOption) (res *EnableFuturesToSubAccountResponse, err error)

EnableFuturesSubAccount make request

func (*Client) EnableMarginSubAccount

func (c *Client) EnableMarginSubAccount(ctx context.Context, subAccountId int, opts ...RequestOption) (res *EnableFuturesToSubAccountResponse, err error)

EnableMarginSubAccount make request

func (*Client) SubAccountTransfer

func (c *Client) SubAccountTransfer(ctx context.Context, req SubAccountTransferRequest, opts ...RequestOption) (res *SubAccountTransferResponse, err error)

SubAccountTransfer makes request

func (*Client) TransferHistory added in v2.2.8

func (c *Client) TransferHistory(ctx context.Context, req SubAccountTransferHistoryRequest, opts ...RequestOption) (transfers []*Transfer, err error)

TransferHistory makes request

type CreateApiKeyRequest

type CreateApiKeyRequest struct {
	SubAccountID string
	CanTrade     bool
	MarginTrade  bool
	FuturesTrade bool
}

CreateApiKeyRequest is a request struct

type CreateApiKeyResponse

type CreateApiKeyResponse struct {
	SubAccountID string `json:"subaccountId"`
	ApiKey       string `json:"apiKey"`
	SecretKey    string `json:"secretKey"`
	CatTrade     bool   `json:"catTrade"`
	MarginTrade  bool   `json:"marginTrade"`
	FuturesTrade bool   `json:"futuresTrade"`
}

CreateApiKeyResponse is response struct

type DeleteSubApiKeyRequest

type DeleteSubApiKeyRequest struct {
	SubAccountID string
	ApiKey       string
}

DeleteSubApiKeyRequest is a request struct

type EnableFuturesToSubAccountResponse

type EnableFuturesToSubAccountResponse struct {
	SubAccountID  string `json:"subaccountId"`
	EnableFutures bool   `json:"enableFutures"`
	UpdateTime    int64  `json:"updateTime"`
}

EnableFuturesToSubAccountResponse is response struct

type EnableMarginToSubAccountResponse

type EnableMarginToSubAccountResponse struct {
	SubAccountID string `json:"subaccountId"`
	EnableMargin bool   `json:"enableMargin"`
	UpdateTime   int64  `json:"updateTime"`
}

EnableMarginToSubAccountResponse is response struct

type RequestOption

type RequestOption func(*request)

RequestOption define option type for request

func WithRecvWindow

func WithRecvWindow(recvWindow int64) RequestOption

WithRecvWindow set recvWindow param for the request

type SubAccount

type SubAccount struct {
	SubAccountID string `json:"subaccountId"`
	Email        string `json:"email"`
	Tag          string `json:"tag"`
}

SubAccount represent sub account entity

type SubAccountTransferHistoryRequest added in v2.2.8

type SubAccountTransferHistoryRequest struct {
	FromID           string
	ToID             string
	ClientTransferID string
	ShowAllStatus    bool
	StartTime        int64
	EndTime          int64
	Page             int
	Limit            int
}

SubAccountTransferHistoryRequest is a request struct

type SubAccountTransferRequest

type SubAccountTransferRequest struct {
	FromID           string
	ToID             string
	ClientTransferID string
	Asset            string
	Amount           float64
}

SubAccountTransferRequest is a request struct

type SubAccountTransferResponse

type SubAccountTransferResponse struct {
	TxnID        string `json:"txnId"`
	ClientTranID string `json:"clientTranId"`
}

SubAccountTransferResponse is a response struct

type Transfer added in v2.2.8

type Transfer struct {
	FromId       string `json:"fromId"`
	ToId         string `json:"toId"`
	Asset        string `json:"asset"`
	Qty          string `json:"qty"`
	Time         int64  `json:"time"`
	TxnId        string `json:"txnId"`
	ClientTranId string `json:"clientTranId"`
	Status       string `json:"status"`
}

Transfer is a transfer struct

type TransferHistoryResponse added in v2.2.8

type TransferHistoryResponse []*Transfer

TransferHistoryResponse is transfer history response

Jump to

Keyboard shortcuts

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