account

package
v0.1.53 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const FeeRatesEndpoint = "/v5/account/fee-rate"

Variables

View Source
var Endpoints = EndpointsStruct{
	Borrow:           "/v5/account/borrow-history",
	CoinGreek:        "/v5/asset/coin-greeks",
	Collateral:       "/v5/account/set-collateral-switch",
	UpgradeToUnified: "/v5/account/upgrade-to-uta",
	Wallet:           "/v5/account/wallet-balance",
}

Functions

This section is empty.

Types

type AccDetails

type AccDetails struct {
	TotalEquity            string        `json:"totalEquity"`
	AccountIMRate          string        `json:"accountIMRate"`
	TotalMarginBalance     string        `json:"totalMarginBalance"`
	TotalInitialMargin     string        `json:"totalInitialMargin"`
	AccountType            string        `json:"accountType"`
	TotalAvailableBalance  string        `json:"totalAvailableBalance"`
	AccountMMRate          string        `json:"accountMMRate"`
	TotalPerpUPL           string        `json:"totalPerpUPL"`
	TotalWalletBalance     string        `json:"totalWalletBalance"`
	AccountLTV             string        `json:"accountLTV"`
	TotalMaintenanceMargin string        `json:"totalMaintenanceMargin"`
	Coin                   []CoinDetails `json:"coin"`
}

type AccInfo

type AccInfo struct {
	UnifiedMarginStatus int    `json:"unifiedMarginStatus"`
	MarginMode          string `json:"marginMode"`
	DcpStatus           string `json:"dcpStatus"`
	TimeWindow          int    `json:"timeWindow"`
	SmpGroup            int    `json:"smpGroup"`
	IsMasterTrader      bool   `json:"isMasterTrader"`
	UpdatedTime         string `json:"updatedTime"`
}

AccInfo represents the response from the /v5/account/info endpoint.

type Account

type Account interface {
	Wallet() *Wallet
	UpgradeToUnified() *UpgradeToUnified
	Borrow() *Borrow
	Collateral() *CollateralCoin
	CoinGreek() *CoinGreeks
	FeeRates() *FeeRates
	Info() *Info
	TransactionLog() *TransactionLog
	Margin() *Margin
}

func New

func New(client_ *client.Client) Account

type AccountCategory

type AccountCategory int

func (AccountCategory) String

func (a AccountCategory) String() string

type AccountType

type AccountType string
const (
	Unified  AccountType = "UNIFIED"
	Contract AccountType = "CONTRACT"
	Spot     AccountType = "SPOT"
)

type BaseResponse

type BaseResponse struct {
	RetCode    int                    `json:"retCode"`
	RetMsg     string                 `json:"retMsg"`
	Time       int64                  `json:"time"`
	RetExtInfo map[string]interface{} `json:"retExtInfo"`
}

BaseResponse is a generic struct used to parse the common response received from Bybit API

type Borrow

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

func NewBorrow

func NewBorrow(client *client.Client) *Borrow

func (*Borrow) GetHistory

func (b *Borrow) GetHistory(currency string, startTime, endTime, limit int, cursor string) (*BorrowRes, error)

type BorrowItem

type BorrowItem struct {
	CreatedTime               int64  `json:"createdTime"`
	CostExemption             string `json:"costExemption"`
	InterestBearingBorrowSize string `json:"interestBearingBorrowSize"`
	Currency                  string `json:"currency"`
	HourlyBorrowRate          string `json:"hourlyBorrowRate"`
	BorrowCost                string `json:"borrowCost"`
}

type BorrowRes

type BorrowRes struct {
	BaseResponse
	Result struct {
		NextPageCursor string       `json:"nextPageCursor"`
		List           []BorrowItem `json:"list"`
	}
}

type CoinDetails

type CoinDetails struct {
	AvailableToBorrow   string `json:"availableToBorrow"`
	Bonus               string `json:"bonus"`
	AccruedInterest     string `json:"accruedInterest"`
	AvailableToWithdraw string `json:"availableToWithdraw"`
	TotalOrderIM        string `json:"totalOrderIM"`
	Equity              string `json:"equity"`
	TotalPositionMM     string `json:"totalPositionMM"`
	UsdValue            string `json:"usdValue"`
	UnrealisedPnl       string `json:"unrealisedPnl"`
	CollateralSwitch    bool   `json:"collateralSwitch"`
	BorrowAmount        string `json:"borrowAmount"`
	TotalPositionIM     string `json:"totalPositionIM"`
	WalletBalance       string `json:"walletBalance"`
	CumRealisedPnl      string `json:"cumRealisedPnl"`
	Locked              string `json:"locked"`
	MarginCollateral    bool   `json:"marginCollateral"`
	Coin                string `json:"coin"`
}

type CoinGreekItem

type CoinGreekItem struct {
	BaseCoin   string `json:"baseCoin"`
	TotalDelta string `json:"totalDelta"`
	TotalGamma string `json:"totalGamma"`
	TotalVega  string `json:"totalVega"`
	TotalTheta string `json:"totalTheta"`
}

type CoinGreekRes

type CoinGreekRes struct {
	BaseResponse
	Result struct {
		List []CoinGreekItem `json:"list"`
	}
}

type CoinGreeks

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

func NewCoinGreeks

func NewCoinGreeks(client_ *client.Client) *CoinGreeks

func (*CoinGreeks) Get

func (cg *CoinGreeks) Get(coin string) (*CoinGreekRes, error)

type CollateralCoin

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

func NewSetCollateralCoin

func NewSetCollateralCoin(c *client.Client) *CollateralCoin

func (*CollateralCoin) GetInfo

func (s *CollateralCoin) GetInfo(currency string) (*CollateralInfoResponse, error)

func (*CollateralCoin) Set

func (s *CollateralCoin) Set(coin string, collateralSwitch CollateralSwitch) (*CollateralInfoResponse, error)

type CollateralData

type CollateralData struct {
	CollateralSwitch    bool   `json:"collateralSwitch"`
	BorrowAmount        string `json:"borrowAmount"`
	AvailableToBorrow   string `json:"availableToBorrow"`
	FreeBorrowingAmount string `json:"freeBorrowingAmount"`
	Borrowable          bool   `json:"borrowable"`
	Currency            string `json:"currency"`
	MaxBorrowingAmount  string `json:"maxBorrowingAmount"`
	HourlyBorrowRate    string `json:"hourlyBorrowRate"`
	BorrowUsageRate     string `json:"borrowUsageRate"`
	MarginCollateral    bool   `json:"marginCollateral"`
	CollateralRatio     string `json:"collateralRatio"`
}

type CollateralInfoResponse

type CollateralInfoResponse struct {
	BaseResponse
	Result CollateralResult
}

type CollateralResult

type CollateralResult struct {
	List []CollateralData `json:"list"`
}

type CollateralSwitch

type CollateralSwitch string
const (
	ON  CollateralSwitch = "ON"
	OFF CollateralSwitch = "OFF"
)

AccountCategory constants using iota

type EndpointsStruct

type EndpointsStruct struct {
	Borrow           string
	CoinGreek        string
	Collateral       string
	UpgradeToUnified string
	Wallet           string
}

type FeeRate

type FeeRate struct {
	Symbol       string `json:"symbol"`
	TakerFeeRate string `json:"takerFeeRate"`
	MakerFeeRate string `json:"makerFeeRate"`
}

type FeeRates

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

func NewFeeRates

func NewFeeRates(client *client.Client) *FeeRates

func (*FeeRates) GetFeeRate

func (fr *FeeRates) GetFeeRate(category string, symbol, baseCoin string) (*FeeRatesResponse, error)

type FeeRatesResponse

type FeeRatesResponse struct {
	BaseResponse
	Result struct {
		List []FeeRate
	}
}

type Info

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

func NewInfo

func NewInfo(client *client.Client) *Info

func (*Info) Get

func (info *Info) Get() (*AccInfo, error)

Get queries the margin mode configuration of the account.

type LogEntry

type LogEntry struct {
	ID              string `json:"id"`
	Symbol          string `json:"symbol"`
	Category        string `json:"category"`
	Side            string `json:"side"`
	TransactionTime string `json:"transactionTime"`
	Type            string `json:"type"`
	Qty             string `json:"qty"`
	Size            string `json:"size"`
	Currency        string `json:"currency"`
	TradePrice      string `json:"tradePrice"`
	Funding         string `json:"funding"`
	Fee             string `json:"fee"`
	CashFlow        string `json:"cashFlow"`
	Change          string `json:"change"`
	CashBalance     string `json:"cashBalance"`
	FeeRate         string `json:"feeRate"`
	BonusChange     string `json:"bonusChange"`
	TradeID         string `json:"tradeId"`
	OrderID         string `json:"orderId"`
	OrderLinkID     string `json:"orderLinkId"`
}

LogEntry represents a single log entry returned by the API

type LogResponse

type LogResponse struct {
	List           []LogEntry `json:"list"`
	NextPageCursor string     `json:"nextPageCursor"`
}

LogResponse represents the response from the /v5/account/transaction-log endpoint

type MMPParams

type MMPParams struct {
	BaseCoin     string `json:"baseCoin"`
	Window       int    `json:"window"`       // Assuming Window is a number representing milliseconds
	FrozenPeriod int    `json:"frozenPeriod"` // Assuming FrozenPeriod is a number representing milliseconds
	QtyLimit     int    `json:"qtyLimit"`     // Assuming QtyLimit is an integer representing quantity
	DeltaLimit   int    `json:"deltaLimit"`   // Assuming DeltaLimit is an integer representing delta
}

MMPParams represents the parameters needed to set Market Maker Protection.

type MMPResponse

type MMPResponse struct {
	BaseResponse
}

MMPResponse represents the response from setting the Market Maker Protection.

type MMPStateItem

type MMPStateItem struct {
	BaseCoin       string `json:"baseCoin"`
	MMPEnabled     bool   `json:"mmpEnabled"`
	Window         string `json:"window"`
	FrozenPeriod   string `json:"frozenPeriod"`
	QtyLimit       string `json:"qtyLimit"`
	DeltaLimit     string `json:"deltaLimit"`
	MMPFrozenUntil string `json:"mmpFrozenUntil"`
	MMPFrozen      bool   `json:"mmpFrozen"`
}

type MMPStateResponse

type MMPStateResponse struct {
	BaseResponse
	Result struct {
		List []MMPStateItem `json:"result"`
	}
}

type Margin

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

func NewMargin

func NewMargin(client *client.Client) *Margin

func (*Margin) GetMMPState

func (m *Margin) GetMMPState(baseCoin string) (*MMPStateResponse, error)

func (*Margin) ResetMMP

func (m *Margin) ResetMMP(baseCoin string) (*MMPResponse, error)

func (*Margin) SetMMP

func (m *Margin) SetMMP(params *MMPParams) (*MMPResponse, error)

SetMMP sets the Market Maker Protection for the client.

func (*Margin) SetMarginMode

func (m *Margin) SetMarginMode(mode string) (*SetMarginModeResponse, error)

type SetMarginModeResponse

type SetMarginModeResponse struct {
	BaseResponse
	Result struct {
		Reasons []struct {
			ReasonCode string `json:"reasonCode"`
			ReasonMsg  string `json:"reasonMsg"`
		} `json:"reasons"`
	} `json:"result"`
}

type TimeInterval

type TimeInterval int

func (TimeInterval) String

func (ti TimeInterval) String() string

type TransactionLog

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

TransactionLog holds a client instance

func NewTransactionLog

func NewTransactionLog(client_ *client.Client) *TransactionLog

NewTransactionLog initializes a new TransactionLog object with a client instance.

func (*TransactionLog) Get

func (tl *TransactionLog) Get(params map[string]string) (*LogResponse, error)

Get sends a GET request to the /v5/account/transaction-log endpoint to retrieve transaction logs.

type UnifiedUpdateMsg

type UnifiedUpdateMsg struct {
	Msg []string `json:"msg"`
}

type UpgradeToUnified

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

func NewUpgradeToUnifiedRequest

func NewUpgradeToUnifiedRequest(c *client.Client) *UpgradeToUnified

func (*UpgradeToUnified) Upgrade

type UpgradeToUnifiedResponse

type UpgradeToUnifiedResponse struct {
	BaseResponse
	Result struct {
		UnifiedUpdateStatus string           `json:"unifiedUpdateStatus"`
		UnifiedUpdateMsg    UnifiedUpdateMsg `json:"unifiedUpdateMsg"`
	}
}

type Wallet

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

func NewWallet

func NewWallet(client_ *client.Client) *Wallet

func (Wallet) GetAllContractWalletBalance

func (w Wallet) GetAllContractWalletBalance() (*WalletBalance, error)

func (Wallet) GetAllSpotWalletBalance

func (w Wallet) GetAllSpotWalletBalance() (*WalletBalance, error)

func (Wallet) GetAllUnifiedWalletBalance

func (w Wallet) GetAllUnifiedWalletBalance() (*WalletBalance, error)

func (Wallet) GetContractWalletBalance

func (w Wallet) GetContractWalletBalance(coins ...string) (*WalletBalance, error)

func (Wallet) GetSpotWalletBalance

func (w Wallet) GetSpotWalletBalance(coins ...string) (*WalletBalance, error)

func (Wallet) GetUnifiedWalletBalance

func (w Wallet) GetUnifiedWalletBalance(coins ...string) (*WalletBalance, error)

type WalletBalance

type WalletBalance struct {
	BaseResponse
	Result struct {
		List []AccDetails `json:"list"`
	}
}

Jump to

Keyboard shortcuts

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