binance

package
v0.0.0-...-cbdeaad Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BinanceErrorInvalidSymbol   int64 = -1121
	BinanceErrorInvalidQuantity int64 = -1013
)

Variables

View Source
var DefaultFee = decimal.NewFromFloat(0.998001)
View Source
var ErrNoPriceFoundAtTime = errors.New("no_price_found_at_time")
View Source
var InvalidFeeValue error = errors.New("can't find symbol fee")

Functions

func ErrorIs

func ErrorIs(err error, code int64) bool

func StepSizeFormat

func StepSizeFormat(val decimal.Decimal, stepSize string) string

Types

type Client

type Client struct {
	Logger          *log.Logger
	ConfigFile      *configfile.ConfigFile
	EventBus        *eventbus.Bus
	SymbolBlackList SymbolBlackListGetter
	// contains filtered or unexported fields
}

func (*Client) Buy

func (c *Client) Buy(ctx context.Context, coin, stableCoin string) (OrderResult, error)

func (*Client) GetBalance

func (c *Client) GetBalance(ctx context.Context, coins ...string) (map[string]decimal.Decimal, error)

func (*Client) GetBalanceValue

func (c *Client) GetBalanceValue(ctx context.Context, altCoins []string) (map[string]decimal.Decimal, error)

func (*Client) GetCoinsPrice

func (c *Client) GetCoinsPrice(ctx context.Context, coins, altCoins []string) (map[string]CoinPrice, error)

func (*Client) GetFee

func (c *Client) GetFee(ctx context.Context, symbol string) (decimal.Decimal, error)

func (*Client) GetJumpFeeMultiplier

func (c *Client) GetJumpFeeMultiplier(ctx context.Context, fromCoin, toCoin, bridge string) (decimal.Decimal, error)

func (*Client) GetSymbolInfos

func (c *Client) GetSymbolInfos(ctx context.Context, symbol string) (binance.Symbol, error)

func (*Client) GetSymbolPrice

func (c *Client) GetSymbolPrice(ctx context.Context, symbol string) (decimal.Decimal, error)

func (*Client) GetSymbolPriceAtTime

func (c *Client) GetSymbolPriceAtTime(ctx context.Context, coin, altCoin string, date time.Time) (CoinPrice, error)

func (*Client) IsTradeInProgress

func (c *Client) IsTradeInProgress() bool

func (*Client) LogBalances

func (c *Client) LogBalances(ctx context.Context)

func (*Client) RefreshFees

func (c *Client) RefreshFees(ctx context.Context)

func (*Client) RefreshSymbolInfos

func (c *Client) RefreshSymbolInfos(ctx context.Context) (map[string]binance.Symbol, error)

func (*Client) Sell

func (c *Client) Sell(ctx context.Context, coin, stableCoin string) (OrderResult, error)

func (*Client) Trade

func (c *Client) Trade(ctx context.Context, coin, stableCoin string, side binance.SideType) (OrderResult, error)

Do not call this one directly, use .Buy() or .Sell()

func (*Client) TradeLock

func (c *Client) TradeLock() (func(), error)

return an error if a trade is in progress, otherwise return a release func to call when trade is over.

⚠️ Don't go concurrently too hard on this func, it's not concurrent safe, but that should be ok for our needs

func (*Client) WaitForOrderCompletion

func (c *Client) WaitForOrderCompletion(ctx context.Context, symbol string, orderId int64) (OrderResult, error)

type CoinPrice

type CoinPrice struct {
	Coin      string
	AltCoin   string
	Price     decimal.Decimal
	Timestamp time.Time
}

type CoinPriceGroupByAlt

type CoinPriceGroupByAlt struct {
	Coin   string
	Prices []CoinPrice
}

type OrderResult

type OrderResult struct {
	Order  *binance.Order
	Cancel *binance.CancelOrderResponse
}

func (OrderResult) IsPartiallyExecuted

func (r OrderResult) IsPartiallyExecuted() bool

func (OrderResult) Price

func (r OrderResult) Price() decimal.Decimal

func (OrderResult) Quantity

func (r OrderResult) Quantity() decimal.Decimal

func (OrderResult) Time

func (r OrderResult) Time() time.Time

type SymbolBlackListGetter

type SymbolBlackListGetter interface {
	IsSymbolBlacklisted(symbol string) bool
}

Jump to

Keyboard shortcuts

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