binance

package
v0.0.0-...-4ca6365 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Handles Binance API endpoints logic

Handles Binance package logic to fetch all data

Handles HTTP requests logic

Handles data calculation logic

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDepositHistory

func GetDepositHistory() (*[]DepositHistory, error)

Get deposit history

func GetTradingHistory

func GetTradingHistory(tradingPairs *TradingPairs) (*[]TradingHistory, error)

Get Binance account trading history

func GetWithdrawHistory

func GetWithdrawHistory() (*[]WithdrawHistory, error)

Get withdraw history

Types

type Binance

type Binance struct {
	TradingPairs    *TradingPairs
	FiatPayments    *FiatPayments
	TradingHistory  *[]TradingHistory
	DustConversion  *DustConversion
	DividendHistory *DividendHistory
	DepositHistory  *[]DepositHistory
	WithdrawHistory *[]WithdrawHistory
}

func New

func New() *Binance

Create a new Binance object

func (*Binance) ProcessBinanceData

func (b *Binance) ProcessBinanceData(verbose bool)

Retrieve all account data from Binance

type Client

type Client struct {
	HTTPClient *http.Client
	BaseURL    string
	APIKey     string
	SecretKey  string
	RetryDelay time.Duration
	MaxRetries int
	MaxHistory int
}

func NewClient

func NewClient() *Client

Create a new Client object

func (*Client) RequestWithRetries

func (c *Client) RequestWithRetries(endpoint string, parameters map[string]string) ([]byte, error)

Retry mechanism for HTTP requests

type DepositHistory

type DepositHistory struct {
	Amount     string `json:"amount"`
	Coin       string `json:"coin"`
	InsertTime int    `json:"insertTime"`
}

type DividendHistory

type DividendHistory struct {
	Rows []struct {
		Amount  string `json:"amount"`
		Asset   string `json:"asset"`
		DivTime int    `json:"divTime"`
	} `json:"rows"`
}

func GetDividendHistory

func GetDividendHistory() (*DividendHistory, error)

Get dividend (staking) rewards history

type DustConversion

type DustConversion struct {
	UserAssetDribblets []struct {
		OperateTime              int    `json:"operateTime"`
		TotalTransferedAmount    string `json:"totalTransferedAmount"`
		UserAssetDribbletDetails []struct {
			FromAsset        string `json:"fromAsset"`
			Amount           string `json:"amount"`
			TransferedAmount string `json:"transferedAmount"`
		} `json:"userAssetDribbletDetails"`
	} `json:"userAssetDribblets"`
}

func GetDustConversionHistory

func GetDustConversionHistory() (*DustConversion, error)

Get dust conversion history

type FiatPayments

type FiatPayments struct {
	Data []struct {
		OrderNo        string `json:"orderNo"`
		SourceAmount   string `json:"sourceAmount"`
		FiatCurrency   string `json:"fiatCurrency"`
		ObtainAmount   string `json:"obtainAmount"`
		CryptoCurrency string `json:"cryptoCurrency"`
		TotalFee       string `json:"totalFee"`
		Price          string `json:"price"`
		Status         string `json:"status"`
		CreateTime     int    `json:"createTime"`
	} `json:"data"`
}

func GetFiatPaymentsHistory

func GetFiatPaymentsHistory() (*FiatPayments, error)

Get Binance account fiat payments history

type Holdings

type Holdings struct {
	Name         string  `json:"name"`
	Quantity     float64 `json:"quantity"`
	CurrentValue float64 `json:"currentValue"`
}

type ServerTime

type ServerTime struct {
	ServerTime int64 `json:"serverTime"`
}

type Stats

type Stats struct {
	TotalInvested float64 `json:"totalInvested"`
	TotalValue    float64 `json:"totalValue"`
	GainValue     float64 `json:"gainValue"`
	TotalAssets   int     `json:"totalAssets"`
}

type TradingHistory

type TradingHistory struct {
	Symbol          string `json:"symbol"`
	BaseAsset       string `json:"baseAsset,omitempty"`
	QuoteAsset      string `json:"quoteAsset,omitempty"`
	ID              int64  `json:"id"`
	Price           string `json:"price"`
	Quantity        string `json:"qty"`
	QuoteQuantity   string `json:"quoteQty"`
	Commission      string `json:"commission"`
	CommissionAsset string `json:"commissionAsset"`
	IsBuyer         bool   `json:"isBuyer"`
	Time            int    `json:"time"`
}

type TradingPairs

type TradingPairs struct {
	Symbols []struct {
		Symbol     string `json:"symbol"`
		BaseAsset  string `json:"baseAsset"`
		QuoteAsset string `json:"quoteAsset"`
	} `json:"symbols"`
}

func GetTradingPairs

func GetTradingPairs() (*TradingPairs, error)

Get trading pairs available on Binance

type Wallet

type Wallet struct {
	Holdings map[string]Holdings `json:"holdings"`
	Stats    Stats               `json:"stats"`
}

func NewWallet

func NewWallet() *Wallet

Create a new Wallet object

func (*Wallet) ProcessWallet

func (w *Wallet) ProcessWallet()

Process Binance fetched data

type WithdrawHistory

type WithdrawHistory struct {
	Amount    string `json:"amount"`
	Coin      string `json:"coin"`
	ApplyTime string `json:"applyTime"`
}

Jump to

Keyboard shortcuts

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