Documentation ¶
Index ¶
- Constants
- Variables
- func ErrorIs(err error, code int64) bool
- func StepSizeFormat(val decimal.Decimal, stepSize string) string
- type Client
- func (c *Client) Buy(ctx context.Context, coin, stableCoin string) (OrderResult, error)
- func (c *Client) GetBalance(ctx context.Context, coins ...string) (map[string]decimal.Decimal, error)
- func (c *Client) GetBalanceValue(ctx context.Context, altCoins []string) (map[string]decimal.Decimal, error)
- func (c *Client) GetCoinsPrice(ctx context.Context, coins, altCoins []string) (map[string]CoinPrice, error)
- func (c *Client) GetFee(ctx context.Context, symbol string) (decimal.Decimal, error)
- func (c *Client) GetJumpFeeMultiplier(ctx context.Context, fromCoin, toCoin, bridge string) (decimal.Decimal, error)
- func (c *Client) GetSymbolInfos(ctx context.Context, symbol string) (binance.Symbol, error)
- func (c *Client) GetSymbolPrice(ctx context.Context, symbol string) (decimal.Decimal, error)
- func (c *Client) GetSymbolPriceAtTime(ctx context.Context, coin, altCoin string, date time.Time) (CoinPrice, error)
- func (c *Client) IsTradeInProgress() bool
- func (c *Client) LogBalances(ctx context.Context)
- func (c *Client) RefreshFees(ctx context.Context)
- func (c *Client) RefreshSymbolInfos(ctx context.Context) (map[string]binance.Symbol, error)
- func (c *Client) Sell(ctx context.Context, coin, stableCoin string) (OrderResult, error)
- func (c *Client) Trade(ctx context.Context, coin, stableCoin string, side binance.SideType) (OrderResult, error)
- func (c *Client) TradeLock() (func(), error)
- func (c *Client) WaitForOrderCompletion(ctx context.Context, symbol string, orderId int64) (OrderResult, error)
- type CoinPrice
- type CoinPriceGroupByAlt
- type OrderResult
- type SymbolBlackListGetter
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 ¶
Types ¶
type Client ¶
type Client struct { Logger *log.Logger ConfigFile *configfile.ConfigFile EventBus *eventbus.Bus SymbolBlackList SymbolBlackListGetter // contains filtered or unexported fields }
func NewClient ¶
func NewClient(l *log.Logger, cf *configfile.ConfigFile, eb *eventbus.Bus, sbg SymbolBlackListGetter) *Client
func (*Client) GetBalance ¶
func (*Client) GetBalanceValue ¶
func (*Client) GetCoinsPrice ¶
func (*Client) GetJumpFeeMultiplier ¶
func (*Client) GetSymbolInfos ¶
func (*Client) GetSymbolPrice ¶
func (*Client) GetSymbolPriceAtTime ¶
func (*Client) IsTradeInProgress ¶
func (*Client) LogBalances ¶
func (*Client) RefreshFees ¶
func (*Client) RefreshSymbolInfos ¶
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 ¶
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 ¶
type CoinPriceGroupByAlt ¶
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 ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.