api

package
v1.1.6-0...-625da48 Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommaOmitEmpty string = "," + OmitEmpty
	OmitEmpty      string = "omitempty"
	ZeroString     string = ""
)

Variables

This section is empty.

Functions

func FormURL

func FormURL(s string) string

func MakeRequests

func MakeRequests(
	chantype models.ChannelType, symbols TrivialMap) []models.WSRequest

func MapToMarketData

func MapToMarketData(event interface{}) (map[string]*models.Market, error)

func PrepareQueryParams

func PrepareQueryParams(params interface{}) (map[string]string, error)

func PtrBool

func PtrBool(b bool) *bool

func PtrDecimal

func PtrDecimal(d decimal.Decimal) *decimal.Decimal

func PtrDuration

func PtrDuration(d time.Duration) *time.Duration

func PtrFloat64

func PtrFloat64(f float64) *float64

func PtrInt

func PtrInt(i int) *int

func PtrInt64

func PtrInt64(i int64) *int64

func PtrString

func PtrString(s string) *string

Types

type Account

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

func (*Account) ChangeAccountLeverage

func (a *Account) ChangeAccountLeverage(leverage float64) (result string, err error)

func (*Account) GetAccountInformation

func (a *Account) GetAccountInformation(result *models.AccountInformation) (err error)

func (*Account) GetPositions

func (a *Account) GetPositions() ([]*models.Position, error)

type Client

type Client struct {
	SubAccount *string
	Logger     *clog.Logger
	Buf        *bytes.Buffer
	Account
	Convert
	Fills
	Funding
	Futures
	LeveragedTokens
	Markets
	Options
	Orders
	SpotMargin
	Staking
	SubAccounts
	Wallet
	Stream
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Client

func (*Client) Delete

func (c *Client) Delete(params interface{}, url string) ([]byte, error)

func (*Client) Get

func (c *Client) Get(params interface{}, url string, auth bool) ([]byte, error)

func (*Client) GetResponse

func (c *Client) GetResponse(
	params interface{}, url string, method string, auth ...bool) ([]byte, error)

func (*Client) GetServerTime

func (c *Client) GetServerTime() (*time.Time, error)

func (*Client) Post

func (c *Client) Post(params interface{}, url string) ([]byte, error)

func (*Client) SetServerTimeDiff

func (c *Client) SetServerTimeDiff() error

type Convert

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

func (*Convert) AcceptQuote

func (c *Convert) AcceptQuote(id int64) error

func (*Convert) GetQuoteStatus

func (c *Convert) GetQuoteStatus(id int64) (*models.ConvertQuoteStatus, error)

func (*Convert) RequestQuote

func (c *Convert) RequestQuote(from, to string, size decimal.Decimal) (id int64, err error)

type Fills

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

func (*Fills) GetFills

func (f *Fills) GetFills(params *models.FillParams) ([]*models.Fill, error)

type Funding

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

func (*Funding) GetFundingPayments

func (f *Funding) GetFundingPayments(
	future *string,
	start, end *int64) ([]*models.FundingPayment, error)

type Futures

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

func (*Futures) GetExpiredFutures

func (f *Futures) GetExpiredFutures() ([]*models.FutureExpired, error)

func (*Futures) GetFundingRates

func (f *Futures) GetFundingRates() ([]*models.FundingRates, error)

func (*Futures) GetFutureByName

func (f *Futures) GetFutureByName(name string, future *models.Future) (err error)

func (*Futures) GetFutureStats

func (f *Futures) GetFutureStats(future string, stats *models.FutureStats) (err error)

func (*Futures) GetFutures

func (f *Futures) GetFutures() ([]*models.Future, error)

func (*Futures) GetHistoricalIndex

func (f *Futures) GetHistoricalIndex(
	indexName string,
	params *models.HistoricalIndexParams) ([]*models.HistoricalIndex, error)

func (*Futures) GetIndexWeights

func (f *Futures) GetIndexWeights(index string) (*map[string]float64, error)

type LeveragedTokens

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

func (*LeveragedTokens) GetLeveragedTokenBalances

func (l *LeveragedTokens) GetLeveragedTokenBalances() (
	[]*models.LeveragedTokenBalance, error)

func (*LeveragedTokens) GetTokenInfo

func (l *LeveragedTokens) GetTokenInfo(token string) (*models.TokenInfo, error)

func (*LeveragedTokens) ListLeveragedTokenCreationRequests

func (l *LeveragedTokens) ListLeveragedTokenCreationRequests() (
	[]*models.LeveragedTokenCreationRequest, error)

func (*LeveragedTokens) ListLeveragedTokenRedemptionRequests

func (l *LeveragedTokens) ListLeveragedTokenRedemptionRequests() (
	[]*models.LeveragedTokenRedemptionRequest, error)

func (*LeveragedTokens) ListLeveragedTokens

func (l *LeveragedTokens) ListLeveragedTokens() ([]*models.LeveragedToken, error)

func (*LeveragedTokens) RequestLeveragedTokenCreation

func (l *LeveragedTokens) RequestLeveragedTokenCreation(
	token string, size decimal.Decimal,
) (*models.LeveragedTokenCreation, error)

func (*LeveragedTokens) RequestLeveragedTokenRedemption

func (l *LeveragedTokens) RequestLeveragedTokenRedemption(
	token string, size decimal.Decimal,
) (*models.LeveragedTokenRedemption, error)

type Markets

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

func (*Markets) GetHistoricalPrices

func (m *Markets) GetHistoricalPrices(
	market string,
	params *models.GetHistoricalPricesParams,
) ([]*models.HistoricalPrice, error)

func (*Markets) GetMarketByName

func (m *Markets) GetMarketByName(name string, market *models.Market) (err error)

func (*Markets) GetMarkets

func (m *Markets) GetMarkets() ([]*models.Market, error)

func (*Markets) GetOrderBook

func (m *Markets) GetOrderBook(market string, depth *int, ob *models.OrderBook) (err error)

func (*Markets) GetTrades

func (m *Markets) GetTrades(
	market string, params *models.GetTradesParams) ([]*models.Trade, error)

type Option

type Option func(c *Client)

func SetSubAccount

func SetSubAccount(nickname string) Option

func WithAuth

func WithAuth(key, secret string) Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

type Options

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

func (*Options) AcceptQuote

func (o *Options) AcceptQuote(id int64) (*models.UserOptionQuote, error)

func (*Options) CancelQuote

func (o *Options) CancelQuote(id int64) (*models.UserOptionQuote, error)

func (*Options) CancelQuoteRequest

func (o *Options) CancelQuoteRequest(id int64) (*models.CancelQuoteRequest, error)

func (*Options) CreateQuote

func (o *Options) CreateQuote(
	id int64, price decimal.Decimal,
) (*models.UserOptionQuote, error)

func (*Options) CreateQuoteRequest

func (o *Options) CreateQuoteRequest(
	params *models.OptionQuoteRequestParams,
) (*models.CreateQuoteRequest, error)

func (*Options) Get24hOptionVolume

func (o *Options) Get24hOptionVolume() (*models.OptionsVolume, error)

func (*Options) GetAccountOptionsInfo

func (o *Options) GetAccountOptionsInfo() (*models.AccountOptionsInfo, error)

func (*Options) GetHistoricalOpenInterest

func (o *Options) GetHistoricalOpenInterest(
	params *models.NumberTimeLimit,
) ([]*models.OptionsHistoricalOpenInterest, error)

func (*Options) GetOptionsFills

func (o *Options) GetOptionsFills(
	params *models.NumberTimeLimit,
) ([]*models.OptionFill, error)

func (*Options) GetOptionsHistoricalVolumes

func (o *Options) GetOptionsHistoricalVolumes(
	params *models.NumberTimeLimit,
) ([]*models.OptionsHistoricalVolumes, error)

func (*Options) GetOptionsOpenInterest

func (o *Options) GetOptionsOpenInterest() (openInterest decimal.Decimal, err error)

func (*Options) GetOptionsPositions

func (o *Options) GetOptionsPositions() ([]*models.OptionPosition, error)

func (*Options) GetPublicOptionsTrades

func (o *Options) GetPublicOptionsTrades(
	params *models.NumberTimeLimit,
) ([]*models.PublicOptionTrade, error)

func (*Options) GetQuotesForUserQuoteRequest

func (o *Options) GetQuotesForUserQuoteRequest(
	id int64,
) ([]*models.QuotesForOptionQuoteRequest, error)

func (*Options) GetUserQuotes

func (o *Options) GetUserQuotes() ([]*models.UserOptionQuote, error)

func (*Options) ListQuoteRequests

func (o *Options) ListQuoteRequests() ([]*models.OptionQuoteRequest, error)

func (*Options) ListUserQuoteRequests

func (o *Options) ListUserQuoteRequests() ([]*models.OptionQuoteRequest, error)

type Orders

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

func (*Orders) CancelAllOrders

func (o *Orders) CancelAllOrders(
	params *models.CancelAllParams) (result string, err error)

func (*Orders) CancelOrder

func (o *Orders) CancelOrder(orderID int64) (result string, err error)

func (*Orders) CancelOrderByClientID

func (o *Orders) CancelOrderByClientID(clientID int64) (result string, err error)

func (*Orders) CancelTriggerOrder

func (o *Orders) CancelTriggerOrder(orderID int64) (result string, err error)

func (*Orders) GetOpenOrders

func (o *Orders) GetOpenOrders(market *string) ([]*models.Order, error)

func (*Orders) GetOpenTriggerOrders

func (o *Orders) GetOpenTriggerOrders(
	market, triggerType *string) ([]*models.TriggerOrder, error)

func (*Orders) GetOrderStatus

func (o *Orders) GetOrderStatus(orderID int64, order *models.Order) (err error)

func (*Orders) GetOrderStatusByClientID

func (o *Orders) GetOrderStatusByClientID(clientID int64, order *models.Order) (err error)

func (*Orders) GetOrdersHistory

func (o *Orders) GetOrdersHistory(
	params *models.OrdersHistoryParams) ([]*models.Order, error)

func (*Orders) GetTriggerOrderTriggers

func (o *Orders) GetTriggerOrderTriggers(orderID int64) ([]*models.Trigger, error)

func (*Orders) GetTriggerOrdersHistory

func (o *Orders) GetTriggerOrdersHistory(
	params *models.TriggerOrdersHistoryParams) ([]*models.TriggerOrder, error)

func (*Orders) ModifyOrder

func (o *Orders) ModifyOrder(
	orderID int64,
	params *models.ModifyOrderParams,
	order *models.Order) (err error)

func (*Orders) ModifyOrderByClientID

func (o *Orders) ModifyOrderByClientID(
	clientID int64, params *models.ModifyOrderParams, order *models.Order,
) (err error)

func (*Orders) ModifyTriggerOrder

func (o *Orders) ModifyTriggerOrder(
	orderID int64,
	params *models.ModifyTriggerOrderParams,
	order *models.TriggerOrder) (err error)

func (*Orders) PlaceOrder

func (o *Orders) PlaceOrder(params *models.OrderParams, order *models.Order) (err error)

func (*Orders) PlaceTriggerOrder

func (o *Orders) PlaceTriggerOrder(
	params *models.TriggerOrderParams, order *models.TriggerOrder) (err error)

type Request

type Request struct {
	Auth       bool
	Method     string
	URL        string
	SubAccount *string
	Headers    map[string]string
	Params     map[string]string
	Body       []byte
}

type Response

type Response struct {
	Success bool            `json:"success"`
	Result  json.RawMessage `json:"result"`
	Error   string          `json:"error,omitempty"`
}

type SpotMargin

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

func (*SpotMargin) GetBorrowHistory

func (s *SpotMargin) GetBorrowHistory() ([]*models.BorrowHistory, error)

func (*SpotMargin) GetBorrowRates

func (s *SpotMargin) GetBorrowRates() ([]*models.BorrowRate, error)

func (*SpotMargin) GetBorrowSummary

func (s *SpotMargin) GetBorrowSummary() ([]*models.BorrowedAmount, error)

func (*SpotMargin) GetLendingHistory

func (s *SpotMargin) GetLendingHistory() ([]*models.LendingHistory, error)

func (*SpotMargin) GetLendingInfo

func (s *SpotMargin) GetLendingInfo() ([]*models.LendingInfo, error)

func (*SpotMargin) GetLendingOffers

func (s *SpotMargin) GetLendingOffers() ([]*models.LendingOffer, error)

func (*SpotMargin) GetLendingRates

func (s *SpotMargin) GetLendingRates() ([]*models.LendingRate, error)

func (*SpotMargin) GetMarketInfo

func (s *SpotMargin) GetMarketInfo(market string) (*models.SpotMarginMarketInfo, error)

func (*SpotMargin) SubmitLendingOffer

func (s *SpotMargin) SubmitLendingOffer(
	coin string, size decimal.Decimal, rate float64,
) (result string, err error)

type Staking

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

func (*Staking) CancelUnstakeRequest

func (s *Staking) CancelUnstakeRequest(id int64) (result string, err error)

func (*Staking) GetStakeBalances

func (s *Staking) GetStakeBalances() ([]*models.StakeBalance, error)

func (*Staking) GetStakes

func (s *Staking) GetStakes() ([]*models.Stake, error)

func (*Staking) GetStakingRewards

func (s *Staking) GetStakingRewards() ([]*models.StakingReward, error)

func (*Staking) GetUnstakeRequests

func (s *Staking) GetUnstakeRequests() ([]*models.UnstakeRequest, error)

func (*Staking) RequestStake

func (s *Staking) RequestStake(coin string, size decimal.Decimal) (*models.Stake, error)

func (*Staking) RequestUnstake

func (s *Staking) RequestUnstake(
	coin string, size decimal.Decimal,
) (*models.UnstakeRequest, error)

type Stream

type Stream struct {
	WsSub *WsSub
	// contains filtered or unexported fields
}

func NewStream

func NewStream(client *Client) *Stream

func (*Stream) Authorize

func (s *Stream) Authorize() (err error)

func (*Stream) Connect

func (s *Stream) Connect(requests ...models.WSRequest) (err error)

func (*Stream) CreateNewConnection

func (s *Stream) CreateNewConnection() (err error)

func (*Stream) GetAuthRequest

func (s *Stream) GetAuthRequest() (*models.WSRequestAuthorize, error)

func (*Stream) GetEventResponse

func (s *Stream) GetEventResponse(ctx context.Context, msg *models.WsResponse) (err error)

func (*Stream) IsLoggedIn

func (s *Stream) IsLoggedIn() bool

func (*Stream) Reconnect

func (s *Stream) Reconnect(ctx context.Context) (err error)

func (*Stream) SendToChannel

func (s *Stream) SendToChannel(ct models.ChannelType, response interface{})

func (*Stream) Serve

func (s *Stream) Serve(ctx context.Context) (err error)

func (*Stream) SetReconnectionCount

func (s *Stream) SetReconnectionCount(count int)

func (*Stream) SetReconnectionInterval

func (s *Stream) SetReconnectionInterval(interval time.Duration)

func (*Stream) Subscribe

func (s *Stream) Subscribe() (err error)

func (*Stream) SubscribeToFills

func (s *Stream) SubscribeToFills(ctx context.Context) (chan *models.FillResponse, error)

func (*Stream) SubscribeToMarkets

func (s *Stream) SubscribeToMarkets(ctx context.Context) (chan *models.Market, error)

func (*Stream) SubscribeToOrderBooks

func (s *Stream) SubscribeToOrderBooks(
	ctx context.Context, symbols ...string) (chan *models.OrderBookResponse, error)

func (*Stream) SubscribeToOrders

func (s *Stream) SubscribeToOrders(
	ctx context.Context, symbols ...string) (chan *models.OrdersResponse, error)

func (*Stream) SubscribeToTickers

func (s *Stream) SubscribeToTickers(
	ctx context.Context, symbols ...string) (chan *models.TickerResponse, error)

func (*Stream) SubscribeToTrades

func (s *Stream) SubscribeToTrades(
	ctx context.Context, symbols ...string) (chan *models.TradeResponse, error)

func (*Stream) WSConn

func (s *Stream) WSConn() *websocket.Conn

type SubAccounts

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

func (*SubAccounts) ChangeSubaccount

func (s *SubAccounts) ChangeSubaccount(nickname, newNickname string) (result string, err error)

func (*SubAccounts) CreateSubaccount

func (s *SubAccounts) CreateSubaccount(nickname string) (*models.SubAccount, error)

func (*SubAccounts) DeleteSubaccount

func (s *SubAccounts) DeleteSubaccount(nickname string) (result string, err error)

func (*SubAccounts) GetSubaccountBalances

func (s *SubAccounts) GetSubaccountBalances(nickname string) ([]*models.Balance, error)

func (*SubAccounts) GetSubaccounts

func (s *SubAccounts) GetSubaccounts() ([]*models.SubAccount, error)

func (*SubAccounts) Transfer

func (s *SubAccounts) Transfer(payload *models.TransferPayload) (*models.TransferResponse, error)

type TrivialMap

type TrivialMap map[string]struct{}

type Wallet

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

func (*Wallet) CreateSavedAddresses

func (w *Wallet) CreateSavedAddresses(
	params *models.SavedAddressParams,
) ([]*models.SavedAddress, error)

func (*Wallet) DeleteSavedAddress

func (w *Wallet) DeleteSavedAddress(address int64) (result string, err error)

func (*Wallet) GetAirdrops

func (w *Wallet) GetAirdrops(params *models.AirDropParams) ([]*models.AirDrop, error)

func (*Wallet) GetBalances

func (w *Wallet) GetBalances() ([]*models.Balance, error)

func (*Wallet) GetBalancesAllAccts

func (w *Wallet) GetBalancesAllAccts() (map[string][]*models.Balance, error)

func (*Wallet) GetCoins

func (w *Wallet) GetCoins() ([]*models.Coin, error)

func (*Wallet) GetDepositAddress

func (w *Wallet) GetDepositAddress(
	coin string, method *models.DepositMethod,
) (address, tag string, err error)

func (*Wallet) GetDepositHistory

func (w *Wallet) GetDepositHistory(pars *models.DepositHistoryParams) ([]*models.Deposit, error)

func (*Wallet) GetSavedAddresses

func (w *Wallet) GetSavedAddresses(coin *string) ([]*models.SavedAddress, error)

func (*Wallet) GetWithdrawalHistory

func (w *Wallet) GetWithdrawalHistory(
	params *models.WithdrawalHistoryParams,
) ([]*models.Withdrawal, error)

func (*Wallet) RequestWithdrawal

func (w *Wallet) RequestWithdrawal(
	params *models.RequestWithdrawalParams,
	withdrawal *models.Withdrawal,
) (err error)

type WsSub

type WsSub struct {
	ChannelTypes map[models.ChannelType]TrivialMap
	Requests     []models.WSRequest
}

func NewWsSub

func NewWsSub() *WsSub

func (*WsSub) AppendRequests

func (ws *WsSub) AppendRequests(ct models.ChannelType, symbols ...string)

Jump to

Keyboard shortcuts

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