portfolio

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserDataEventTypeFutureOrderTradeUpdate UserDataEventType = "ORDER_TRADE_UPDATE"
	UserDataEventTypeMarginOrderTradeUpdate UserDataEventType = "executionReport"

	FutureSubtypeUM FutureSubtype = "UM"
	FutureSubtypeCM FutureSubtype = "CM"
)

Variables

View Source
var (
	// WebsocketTimeout is an interval for sending ping/pong messages if WebsocketKeepalive is enabled
	WebsocketTimeout = time.Second * 60
	// WebsocketKeepalive enables sending ping/pong messages to check the connection stability
	WebsocketKeepalive = false
)

Functions

func WsUserDataServe

func WsUserDataServe(listenKey string, handler WsUserDataHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsUserDataServe serve user data handler with listen key

Types

type Account

type Account struct {
	UniMMR                   string `json:"uniMMR"`
	AccountEquity            string `json:"accountEquity"`
	ActualEquity             string `json:"actualEquity"`
	AccountInitialMargin     string `json:"accountInitialMargin"`
	AccountMaintMargin       string `json:"accountMaintMargin"`
	AccountStatus            string `json:"accountStatus"`
	VirtualMaxWithdrawAmount string `json:"virtualMaxWithdrawAmount"`
	TotalAvailableBalance    string `json:"totalAvailableBalance"`
	TotalMarginOpenLoss      string `json:"totalMarginOpenLoss"`
	UpdateTime               int64  `json:"updateTime"`
}

type AutoCollectionService

type AutoCollectionService struct {
	// contains filtered or unexported fields
}

func (*AutoCollectionService) Do

type Balance

type Balance struct {
	Asset               string `json:"asset"`
	TotalWalletBalance  string `json:"totalWalletBalance"`
	CrossMarginAsset    string `json:"crossMarginAsset"`
	CrossMarginBorrowed string `json:"crossMarginBorrowed"`
	CrossMarginFree     string `json:"crossMarginFree"`
	CrossMarginInterest string `json:"crossMarginInterest"`
	CrossMarginLocked   string `json:"crossMarginLocked"`
	UmWalletBalance     string `json:"umWalletBalance"`
	UmUnrealizedPNL     string `json:"umUnrealizedPNL"`
	CmWalletBalance     string `json:"cmWalletBalance"`
	CmUnrealizedPNL     string `json:"cmUnrealizedPNL"`
	NegativeBalance     string `json:"negativeBalance"`
	UpdateTime          int64  `json:"updateTime"`
}

Balance define user balance of your account

type CancelOpenOrdersServiceCM

type CancelOpenOrdersServiceCM struct {
	Ds *delivery.CancelAllOpenOrdersService
}

func (*CancelOpenOrdersServiceCM) Do

type CancelOpenOrdersServiceMargin

type CancelOpenOrdersServiceMargin struct {
	Ms *binance.CancelMarginOpenOrdersService
}

Cancel open orders

func (*CancelOpenOrdersServiceMargin) Do

func (s *CancelOpenOrdersServiceMargin) Do(
	ctx context.Context,
	opts ...binance.RequestOption,
) (*binance.CancelOpenOrdersResponse, error)

type CancelOpenOrdersServiceUM

type CancelOpenOrdersServiceUM struct {
	Fs *futures.CancelAllOpenOrdersService
}

func (*CancelOpenOrdersServiceUM) Do

type CancelOrderServiceCM

type CancelOrderServiceCM struct {
	Ds *delivery.CancelOrderService
}

func (*CancelOrderServiceCM) Do

type CancelOrderServiceMargin

type CancelOrderServiceMargin struct {
	Ms *binance.CancelMarginOrderService
}

Cancel order

func (*CancelOrderServiceMargin) Do

func (s *CancelOrderServiceMargin) Do(
	ctx context.Context,
	opts ...binance.RequestOption,
) (*binance.CancelMarginOrderResponse, error)

type CancelOrderServiceUM

type CancelOrderServiceUM struct {
	Fs *futures.CancelOrderService
}

func (*CancelOrderServiceUM) Do

type ChangeLeverageServiceCM

type ChangeLeverageServiceCM struct {
	// contains filtered or unexported fields
}

func (*ChangeLeverageServiceCM) Do

func (*ChangeLeverageServiceCM) Leverage

func (s *ChangeLeverageServiceCM) Leverage(leverage int) *ChangeLeverageServiceCM

func (*ChangeLeverageServiceCM) Symbol

type ChangeLeverageServiceUM

type ChangeLeverageServiceUM struct {
	// contains filtered or unexported fields
}

func (*ChangeLeverageServiceUM) Do

func (*ChangeLeverageServiceUM) Leverage

func (s *ChangeLeverageServiceUM) Leverage(leverage int) *ChangeLeverageServiceUM

func (*ChangeLeverageServiceUM) Symbol

type ChangePositionModeServiceCM

type ChangePositionModeServiceCM struct {
	// contains filtered or unexported fields
}

func (*ChangePositionModeServiceCM) Do

func (*ChangePositionModeServiceCM) DualSide

type ChangePositionModeServiceUM

type ChangePositionModeServiceUM struct {
	// contains filtered or unexported fields
}

func (*ChangePositionModeServiceUM) Do

func (*ChangePositionModeServiceUM) DualSide

type Client

type Client struct {
	APIKey     string
	SecretKey  string
	BaseURL    string
	HTTPClient *http.Client
	Debug      bool
	Logger     *log.Logger
	TimeOffset int64
	// contains filtered or unexported fields
}

Client define API client

func NewClient

func NewClient(apiKey, secretKey string) *Client

NewClient initialize an API client instance with API key and secret key. You should always call this function before using this SDK. Services will be created by the form client.NewXXXService().

func (*Client) NewAutoCollectionService

func (c *Client) NewAutoCollectionService() *AutoCollectionService

func (*Client) NewCancelOpenOrdersServiceCM

func (c *Client) NewCancelOpenOrdersServiceCM() *CancelOpenOrdersServiceCM

func (*Client) NewCancelOpenOrdersServiceMargin

func (c *Client) NewCancelOpenOrdersServiceMargin() *CancelOpenOrdersServiceMargin

Cancel open orders

func (*Client) NewCancelOpenOrdersServiceUM

func (c *Client) NewCancelOpenOrdersServiceUM() *CancelOpenOrdersServiceUM

func (*Client) NewCancelOrderServiceCM

func (c *Client) NewCancelOrderServiceCM() *CancelOrderServiceCM

func (*Client) NewCancelOrderServiceMargin

func (c *Client) NewCancelOrderServiceMargin() *CancelOrderServiceMargin

Cancel order

func (*Client) NewCancelOrderServiceUM

func (c *Client) NewCancelOrderServiceUM() *CancelOrderServiceUM

func (*Client) NewChangeLeverageServiceCM

func (c *Client) NewChangeLeverageServiceCM() *ChangeLeverageServiceCM

Change leverage

func (*Client) NewChangeLeverageServiceUM

func (c *Client) NewChangeLeverageServiceUM() *ChangeLeverageServiceUM

func (*Client) NewChangePositionModeServiceCM

func (c *Client) NewChangePositionModeServiceCM() *ChangePositionModeServiceCM

func (*Client) NewChangePositionModeServiceUM

func (c *Client) NewChangePositionModeServiceUM() *ChangePositionModeServiceUM

Change position mode

func (*Client) NewCreateOrderServiceCM

func (c *Client) NewCreateOrderServiceCM() *CreateOrderServiceCM

func (*Client) NewCreateOrderServiceMargin

func (c *Client) NewCreateOrderServiceMargin() *CreateOrderServiceMargin

Create order

func (*Client) NewCreateOrderServiceUM

func (c *Client) NewCreateOrderServiceUM() *CreateOrderServiceUM

func (*Client) NewFutureRepayService

func (c *Client) NewFutureRepayService() *FutureRepayService

Repay

func (*Client) NewGetAccountService

func (c *Client) NewGetAccountService() *GetAccountService

Get account

func (*Client) NewGetBalanceService

func (c *Client) NewGetBalanceService() *GetBalanceService

Get balance

func (*Client) NewGetCommissionRateService

func (c *Client) NewGetCommissionRateService() *GetCommissionRateService

Get commission rate

func (*Client) NewGetOrderServiceCM

func (c *Client) NewGetOrderServiceCM() *GetOrderServiceCM

func (*Client) NewGetOrderServiceMargin

func (c *Client) NewGetOrderServiceMargin() *GetOrderServiceMargin

Get order

func (*Client) NewGetOrderServiceUM

func (c *Client) NewGetOrderServiceUM() *GetOrderServiceUM

func (*Client) NewGetPositionModeServiceCM

func (c *Client) NewGetPositionModeServiceCM() *GetPositionModeServiceCM

func (*Client) NewGetPositionModeServiceUM

func (c *Client) NewGetPositionModeServiceUM() *GetPositionModeServiceUM

func (*Client) NewGetPositionRiskServiceCM

func (c *Client) NewGetPositionRiskServiceCM() *GetPositionRiskServiceCM

Get position risk

func (*Client) NewGetPositionRiskServiceUM

func (c *Client) NewGetPositionRiskServiceUM() *GetPositionRiskServiceUM

func (*Client) NewKeepaliveUserStreamService

func (c *Client) NewKeepaliveUserStreamService() *KeepaliveUserStreamService

Keepalive

func (*Client) NewListOpenOrdersServiceCM

func (c *Client) NewListOpenOrdersServiceCM() *ListOpenOrdersServiceCM

func (*Client) NewListOpenOrdersServiceMargin

func (c *Client) NewListOpenOrdersServiceMargin() *ListOpenOrdersServiceMargin

List open orders

func (*Client) NewListOpenOrdersServiceUM

func (c *Client) NewListOpenOrdersServiceUM() *ListOpenOrdersServiceUM

func (*Client) NewStartUserStreamService

func (c *Client) NewStartUserStreamService() *StartUserStreamService

User stream

type CreateOrderServiceCM

type CreateOrderServiceCM struct {
	Ds *delivery.CreateOrderService
}

func (*CreateOrderServiceCM) Do

type CreateOrderServiceMargin

type CreateOrderServiceMargin struct {
	Ms *binance.CreateMarginOrderService
}

func (*CreateOrderServiceMargin) Do

func (s *CreateOrderServiceMargin) Do(
	ctx context.Context,
	opts ...binance.RequestOption,
) (*binance.CreateOrderResponse, error)

type CreateOrderServiceUM

type CreateOrderServiceUM struct {
	Fs *futures.CreateOrderService
}

func (*CreateOrderServiceUM) Do

type ErrHandler

type ErrHandler func(err error)

ErrHandler handles errors

type FutureRepayService

type FutureRepayService struct {
	// contains filtered or unexported fields
}

func (*FutureRepayService) Do

type FutureSubtype

type FutureSubtype string

type GetAccountService

type GetAccountService struct {
	// contains filtered or unexported fields
}

func (*GetAccountService) Do

func (s *GetAccountService) Do(ctx context.Context, opts ...RequestOption) (*Account, error)

type GetBalanceService

type GetBalanceService struct {
	// contains filtered or unexported fields
}

GetBalanceService get account balance

func (*GetBalanceService) Do

func (s *GetBalanceService) Do(ctx context.Context, opts ...RequestOption) ([]*Balance, error)

Do send request

type GetCommissionRateService

type GetCommissionRateService struct {
	// contains filtered or unexported fields
}

func (*GetCommissionRateService) Do

func (*GetCommissionRateService) Symbol

type GetOrderServiceCM

type GetOrderServiceCM struct {
	Ds *delivery.GetOrderService
}

func (*GetOrderServiceCM) Do

type GetOrderServiceMargin

type GetOrderServiceMargin struct {
	Ms *binance.GetMarginOrderService
}

Get order

func (*GetOrderServiceMargin) Do

func (s *GetOrderServiceMargin) Do(
	ctx context.Context,
	opts ...binance.RequestOption,
) (*binance.Order, error)

type GetOrderServiceUM

type GetOrderServiceUM struct {
	Fs *futures.GetOrderService
}

func (*GetOrderServiceUM) Do

type GetPositionModeServiceCM

type GetPositionModeServiceCM struct {
	// contains filtered or unexported fields
}

func (*GetPositionModeServiceCM) Do

type GetPositionModeServiceUM

type GetPositionModeServiceUM struct {
	// contains filtered or unexported fields
}

func (*GetPositionModeServiceUM) Do

type GetPositionRiskServiceCM

type GetPositionRiskServiceCM struct {
	// contains filtered or unexported fields
}

func (*GetPositionRiskServiceCM) Do

type GetPositionRiskServiceUM

type GetPositionRiskServiceUM struct {
	// contains filtered or unexported fields
}

func (*GetPositionRiskServiceUM) Do

type KeepaliveUserStreamService

type KeepaliveUserStreamService struct {
	// contains filtered or unexported fields
}

KeepaliveUserStreamService update listen key

func (*KeepaliveUserStreamService) Do

func (s *KeepaliveUserStreamService) Do(ctx context.Context, opts ...RequestOption) (err error)

Do send request

func (*KeepaliveUserStreamService) ListenKey

ListenKey set listen key

type ListOpenOrdersServiceCM

type ListOpenOrdersServiceCM struct {
	Ds *delivery.ListOpenOrdersService
}

func (*ListOpenOrdersServiceCM) Do

type ListOpenOrdersServiceMargin

type ListOpenOrdersServiceMargin struct {
	Ms *binance.ListMarginOpenOrdersService
}

List open orders

func (*ListOpenOrdersServiceMargin) Do

func (s *ListOpenOrdersServiceMargin) Do(
	ctx context.Context,
	opts ...binance.RequestOption,
) ([]*binance.Order, error)

type ListOpenOrdersServiceUM

type ListOpenOrdersServiceUM struct {
	Fs *futures.ListOpenOrdersService
}

func (*ListOpenOrdersServiceUM) Do

type RequestOption

type RequestOption func(*request)

RequestOption define option type for request

func WithHeader

func WithHeader(key, value string, replace bool) RequestOption

WithHeader set or add a header value to the request

func WithHeaders

func WithHeaders(header http.Header) RequestOption

WithHeaders set or replace the headers of the request

func WithRecvWindow

func WithRecvWindow(recvWindow int64) RequestOption

WithRecvWindow set recvWindow param for the request

type StartUserStreamService

type StartUserStreamService struct {
	// contains filtered or unexported fields
}

StartUserStreamService create listen key for user stream service

func (*StartUserStreamService) Do

func (s *StartUserStreamService) Do(ctx context.Context, opts ...RequestOption) (listenKey string, err error)

Do send request

type UserDataEventType

type UserDataEventType string

type WsConfig

type WsConfig struct {
	Endpoint string
}

WsConfig webservice configuration

type WsHandler

type WsHandler func(message []byte)

WsHandler handle raw websocket message

type WsOrderTradeUpdate

type WsOrderTradeUpdate struct {
	Margin *binance.WsOrderUpdate
	CM     *delivery.WsOrderTradeUpdate
	UM     *futures.WsOrderTradeUpdate
}

type WsUserDataEvent

type WsUserDataEvent struct {
	Event            UserDataEventType `json:"e"`
	FutureSubtype    FutureSubtype     `json:"fs"`
	Time             int64             `json:"E"`
	TransactionTime  int64             `json:"T"`
	OrderTradeUpdate WsOrderTradeUpdate
}

WsUserDataEvent define user data event

type WsUserDataHandler

type WsUserDataHandler func(event *WsUserDataEvent)

WsUserDataHandler handle WsUserDataEvent

Jump to

Keyboard shortcuts

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