Documentation
¶
Index ¶
- Variables
- type Account
- type ApiError
- type Asset
- type Authenticate
- type Balance
- type Book
- type BookEvent
- type BookListener
- type Candle
- type CandleEvent
- type CandleOnly
- type CandleParams
- type CandlesListener
- type Channel
- type Closer
- type DebugPrinter
- type DefaultDebugPrinter
- type DepositAsset
- type DepositHistory
- type DepositHistoryParams
- type DepositStatus
- type Fee
- type Fill
- type FillEvent
- type FillListener
- type HttpOption
- type Interval
- type Listener
- func NewBookListener(options ...WebSocketOption) Listener[BookEvent]
- func NewFillListener(apiKey, apiSecret string, options ...WebSocketOption) Listener[FillEvent]
- func NewOrderListener(apiKey, apiSecret string, options ...WebSocketOption) Listener[OrderEvent]
- func NewTicker24hListener(options ...WebSocketOption) Listener[Ticker24hEvent]
- func NewTickerListener(options ...WebSocketOption) Listener[TickerEvent]
- func NewTradesListener(options ...WebSocketOption) Listener[TradeEvent]
- type ListenerEvent
- type Market
- type MarketStatus
- type Order
- type OrderEvent
- type OrderFill
- type OrderListener
- type OrderNew
- type OrderParams
- type OrderStatus
- type OrderTriggerRef
- type OrderTriggerType
- type OrderType
- type OrderUpdate
- type Page
- type Params
- type PrivateAPI
- type PublicAPI
- type SelfTradePrevention
- type Side
- type Subscribed
- type Subscriber
- type Subscription
- type Ticker
- type Ticker24h
- type Ticker24hData
- type Ticker24hEvent
- type Ticker24hListener
- type TickerBook
- type TickerEvent
- type TickerListener
- type TickerPrice
- type TimeInForce
- type Trade
- type TradeEvent
- type TradeHistoric
- type TradeParams
- type TradesListener
- type Unsubscribed
- type Unsubscriber
- type WebSocket
- type WebSocketError
- type WebSocketEvent
- type WebSocketEventData
- type WebSocketOption
- type WithDrawalResponse
- type Withdrawal
- type WithdrawalHistory
- type WithdrawalHistoryParams
- type WithdrawalHistoryStatus
- type WithdrawalStatus
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DepositStatusTrading = depositStatus.Add(DepositStatus{"OK"}) DepositStatusHalted = depositStatus.Add(DepositStatus{"MAINTENANCE"}) DepositStatusAuction = depositStatus.Add(DepositStatus{"DELISTED"}) )
View Source
var ( WithdrawalStatusTrading = withdrawalStatus.Add(WithdrawalStatus{"OK"}) WithdrawalStatusHalted = withdrawalStatus.Add(WithdrawalStatus{"MAINTENANCE"}) WithdrawalStatusAuction = withdrawalStatus.Add(WithdrawalStatus{"DELISTED"}) )
View Source
var ( ErrHeaderNoValue = func(h string) error { return fmt.Errorf("header: %s didn't contain a value", h) } ErrNOKResponse = func(code int, b []byte) error { return fmt.Errorf("did not get OK response, code=%d, body=%s", code, string(b)) } )
View Source
var ( ErrNoSubscriptions = errors.New("no subscriptions yet, start listening first") ErrNoAuth = errors.New("received auth event from server, but was not authenticated") )
View Source
var ( MarketStatusTrading = marketStatus.Add(MarketStatus{"trading"}) MarketStatusHalted = marketStatus.Add(MarketStatus{"halted"}) MarketStatusAuction = marketStatus.Add(MarketStatus{"auction"}) )
View Source
var ( OrderStatusNew = orderStatus.Add(OrderStatus{"new"}) OrderStatusAwaitingTrigger = orderStatus.Add(OrderStatus{"awaitingTrigger"}) OrderStatusCanceled = orderStatus.Add(OrderStatus{"canceled"}) OrderStatusCanceledAuction = orderStatus.Add(OrderStatus{"canceledAuction"}) OrderStatusCanceledStp = orderStatus.Add(OrderStatus{"canceledSelfTradePrevention"}) OrderStatusCanceledIoc = orderStatus.Add(OrderStatus{"canceledIOC"}) OrderStatusCanceledFok = orderStatus.Add(OrderStatus{"canceledFOK"}) OrderStatusCanceledMp = orderStatus.Add(OrderStatus{"canceledMarketProtection"}) OrderStatusCanceledPo = orderStatus.Add(OrderStatus{"canceledPostOnly"}) OrderStatusFilled = orderStatus.Add(OrderStatus{"filled"}) OrderStatusPartiallyFilled = orderStatus.Add(OrderStatus{"partiallyFilled"}) OrderStatusExpired = orderStatus.Add(OrderStatus{"expired"}) OrderStatusRejected = orderStatus.Add(OrderStatus{"rejected"}) )
View Source
var ( OrderTypeMarket = orderType.Add(OrderType{"market"}) OrderTypeLimit = orderType.Add(OrderType{"limit"}) OrderTypeStopLoss = orderType.Add(OrderType{"stopLoss"}) OrderTypeStopLossLimit = orderType.Add(OrderType{"stopLossLimit"}) OrderTypeTakeProfit = orderType.Add(OrderType{"takeProfit"}) OrderTypeTakeProfitLimit = orderType.Add(OrderType{"takeProfitLimit"}) )
View Source
var ( OrderTriggerTypeDefault = OrderTriggerTypePrice OrderTriggerTypePrice = orderTriggerType.Add(OrderTriggerType{"price"}) )
View Source
var ( OrderTriggerRefLastTrade = orderTriggerRef.Add(OrderTriggerRef{"lastTrade"}) OrderTriggerRefBestBid = orderTriggerRef.Add(OrderTriggerRef{"bestBid"}) OrderTriggerRefBestAsk = orderTriggerRef.Add(OrderTriggerRef{"bestAsk"}) OrderTriggerRefMidPrice = orderTriggerRef.Add(OrderTriggerRef{"midPrice"}) )
View Source
var ( TimeInForceDefault = TimeInForceGtc TimeInForceGtc = timeInForce.Add(TimeInForce{"GTC"}) TimeInForceIoc = timeInForce.Add(TimeInForce{"IOC"}) TimeInForceFok = timeInForce.Add(TimeInForce{"FOK"}) )
View Source
var ( SelfTradePreventionDefault = SelfTradePreventionDac SelfTradePreventionDac = selfTradePrevention.Add(SelfTradePrevention{"decrementAndCancel"}) SelfTradePreventionCo = selfTradePrevention.Add(SelfTradePrevention{"cancelOldest"}) SelfTradePreventionCn = selfTradePrevention.Add(SelfTradePrevention{"cancelNewest"}) SelfTradePreventionCb = selfTradePrevention.Add(SelfTradePrevention{"cancelBoth"}) )
View Source
var ( SideBuy = side.Add(Side{"buy"}) SideSell = side.Add(Side{"sell"}) )
View Source
var ( ChannelAccount = channel.Add(Channel{"account"}) ChannelBook = channel.Add(Channel{"book"}) ChannelCandles = channel.Add(Channel{"candles"}) ChannelTrades = channel.Add(Channel{"trades"}) ChannelTicker = channel.Add(Channel{"ticker"}) ChannelTicker24h = channel.Add(Channel{"ticker24h"}) )
View Source
var ( Interval1m = interval.Add(Interval{"1m"}) Interval5m = interval.Add(Interval{"5m"}) Interval15m = interval.Add(Interval{"15m"}) Interval30m = interval.Add(Interval{"30m"}) Interval1h = interval.Add(Interval{"1h"}) Interval2h = interval.Add(Interval{"2h"}) Interval4h = interval.Add(Interval{"4h"}) Interval6h = interval.Add(Interval{"6h"}) Interval8h = interval.Add(Interval{"8h"}) )
View Source
var ( EventSubscribed = webSocketEvent.Add(WebSocketEvent{"subscribed"}) EventUnsubscribed = webSocketEvent.Add(WebSocketEvent{"unsubscribed"}) EventCandle = webSocketEvent.Add(WebSocketEvent{"candle"}) EventTicker = webSocketEvent.Add(WebSocketEvent{"ticker"}) EventTicker24h = webSocketEvent.Add(WebSocketEvent{"ticker24h"}) EventTrade = webSocketEvent.Add(WebSocketEvent{"trade"}) EventBook = webSocketEvent.Add(WebSocketEvent{"book"}) EventAuthenticate = webSocketEvent.Add(WebSocketEvent{"authenticate"}) EventOrder = webSocketEvent.Add(WebSocketEvent{"order"}) EventFill = webSocketEvent.Add(WebSocketEvent{"fill"}) )
View Source
var ( WithdrawalHistoryStatusAp = withDrawalHistoryStatus.Add(WithdrawalHistoryStatus{"awaiting_processing"}) WithdrawalHistoryStatusAec = withDrawalHistoryStatus.Add(WithdrawalHistoryStatus{"awaiting_email_confirmation"}) WithdrawalHistoryStatusAbi = withDrawalHistoryStatus.Add(WithdrawalHistoryStatus{"awaiting_bitvavo_inspection"}) WithdrawalHistoryStatusApproved = withDrawalHistoryStatus.Add(WithdrawalHistoryStatus{"approved"}) WithdrawalHistoryStatusSending = withDrawalHistoryStatus.Add(WithdrawalHistoryStatus{"sending"}) WithdrawalHistoryStatusIm = withDrawalHistoryStatus.Add(WithdrawalHistoryStatus{"in_mempool"}) WithdrawalHistoryStatusProcessed = withDrawalHistoryStatus.Add(WithdrawalHistoryStatus{"processed"}) WithdrawalHistoryStatusCompleted = withDrawalHistoryStatus.Add(WithdrawalHistoryStatus{"completed"}) WithdrawalHistoryStatusCanceled = withDrawalHistoryStatus.Add(WithdrawalHistoryStatus{"canceled"}) )
View Source
var ErrExpectedCandleLenght = func(exp, act int) error { return fmt.Errorf("expected length '%d' for candle, but was: %d", exp, act) }
View Source
var ErrNotEventType = errors.New("not an event type")
View Source
var ErrUnexpectedType = func(v any) error { return fmt.Errorf("unexpected type '%s'", v) }
Functions ¶
This section is empty.
Types ¶
type ApiError ¶
type ApiError = WebSocketError
ApiError Complete list of errorCodes: https://docs.bitvavo.com/#tag/Error-messages
type Asset ¶
type Asset struct {
// Short version of the asset name used in market names.
Symbol string `json:"symbol"`
// The full name of the asset.
Name string `json:"name"`
// The precision used for specifying amounts.
Decimals int64 `json:"decimals"`
// Fixed fee for depositing this asset.
DepositFee string `json:"depositFee"`
// The minimum amount of network confirmations required before this asset is credited to your account.
DepositConfirmations int64 `json:"depositConfirmations"`
// The current deposit status.
DepositStatus DepositStatus `json:"depositStatus"`
// Fixed fee for withdrawing this asset.
WithdrawalFee string `json:"withdrawalFee"`
// The minimum amount for which a withdrawal can be made.
WithdrawalMinAmount string `json:"withdrawalMinAmount"`
// The current withdrawal status.
WithdrawalStatus WithdrawalStatus `json:"withdrawalStatus"`
// Supported networks.
Networks []string `json:"networks"`
// Shows the reason if withdrawalStatus or depositStatus is not OK.
Message string `json:"message"`
}
func (*Asset) UnmarshalJSON ¶
type Authenticate ¶
type Authenticate struct {
// Whether the user is successfully authenticated.
Authenticated bool `json:"authenticated"`
}
type Book ¶
type Book struct {
// The market which was requested in the subscription.
Market string `json:"market"`
// Integer which is increased by one for every update to the book. Useful for synchronizing. Resets to zero after restarting the matching engine.
Nonce int64 `json:"nonce"`
// Slice with all bids in the format [price, size], where a size of 0 means orders are no longer present at that price level,
// otherwise the returned size is the new total size on that price level.
Bids []Page `json:"bids"`
// Slice with all asks in the format [price, size], where a size of 0 means orders are no longer present at that price level,
// otherwise the returned size is the new total size on that price level.
Asks []Page `json:"asks"`
}
func (*Book) UnmarshalJSON ¶
type BookEvent ¶
type BookEvent ListenerEvent[Book]
type BookListener ¶
type BookListener listener[BookEvent]
func (*BookListener) Close ¶
func (l *BookListener) Close() error
func (*BookListener) Subscribe ¶
func (l *BookListener) Subscribe(markets []string) (<-chan BookEvent, error)
func (*BookListener) Unsubscribe ¶
func (l *BookListener) Unsubscribe(markets []string) error
type Candle ¶
type Candle struct {
Interval Interval `json:"interval"`
Market string `json:"market"`
Timestamp int64 `json:"timestamp"`
Open string `json:"open"`
High string `json:"high"`
Low string `json:"low"`
Close string `json:"close"`
Volume string `json:"volume"`
}
func (*Candle) UnmarshalJSON ¶
type CandleEvent ¶
type CandleEvent ListenerEvent[Candle]
type CandleOnly ¶
type CandleOnly struct {
Timestamp int64 `json:"timestamp"`
Open string `json:"open"`
High string `json:"high"`
Low string `json:"low"`
Close string `json:"close"`
Volume string `json:"volume"`
}
func (*CandleOnly) UnmarshalJSON ¶
func (c *CandleOnly) UnmarshalJSON(bytes []byte) error
type CandleParams ¶
type CandleParams struct {
// Return the limit most recent candlesticks only.
// Default: 1440
Limit uint64 `json:"limit"`
// Return limit candlesticks for trades made after start.
Start time.Time `json:"start"`
// Return limit candlesticks for trades made before end.
End time.Time `json:"end"`
}
func (*CandleParams) Params ¶
func (c *CandleParams) Params() url.Values
type CandlesListener ¶
type CandlesListener listener[CandleEvent]
func NewCandlesListener ¶
func NewCandlesListener(options ...WebSocketOption) *CandlesListener
func (*CandlesListener) Close ¶
func (l *CandlesListener) Close() error
Close everything, graceful shutdown.
func (*CandlesListener) Subscribe ¶
func (l *CandlesListener) Subscribe(markets []string, intervals []Interval) (<-chan CandleEvent, error)
Subscribe to markets with interval.
func (*CandlesListener) Unsubscribe ¶
func (l *CandlesListener) Unsubscribe(markets []string, intervals []Interval) error
Unsubscribe from markets with intervals.
type DebugPrinter ¶
type DebugPrinter interface {
Println(value ...any)
}
type DefaultDebugPrinter ¶
type DefaultDebugPrinter struct{}
func NewDefaultDebugPrinter ¶
func NewDefaultDebugPrinter() *DefaultDebugPrinter
func (*DefaultDebugPrinter) Println ¶
func (l *DefaultDebugPrinter) Println(value ...any)
type DepositAsset ¶
type DepositAsset struct {
// The address to which cryptocurrencies can be sent to increase the account balance.
//
// NOTICE: for digital deposits
Address string `json:"address"`
// If a paymentid is supplied, attaching this to your deposit is required. This is mostly called a note, memo or tag.
//
// NOTICE: for digital deposits
PaymentId string `json:"paymentid"`
// IBAN number to wire your deposit to.
//
// NOTICE: for fiat deposits
IBAN string `json:"iban"`
// Optional code sometimes necessary for international transfers.
//
// NOTICE: for fiat deposits
BIC string `json:"bic"`
// Description which must be used for the deposit.
//
// NOTICE: for fiat deposits
Description string `json:"description"`
}
type DepositHistory ¶
type DepositHistory struct {
// The time your deposit of symbol was received by Bitvavo.
Timestamp int64 `json:"timestamp"`
// The short name of the base currency you deposited with Bitvavo. For example, BTC for Bitcoin or EUR for euro.
Symbol string `json:"symbol"`
// The quantity of symbol you deposited with Bitvavo.
Amount string `json:"amount"`
// The identifier for the account you sent amount of symbol from. For example, NL89BANK0123456789 or a digital address (e.g: 14qViLJfdGaP4EeHnDyJbEGQysnCpwk3gd).
Address string `json:"address"`
// The identifier for this deposit. If you did not set an ID when you made this deposit, this parameter is not included in the response.
//
// NOTICE: digital currency only
PaymentId string `json:"paymentId"`
// The ID for this transaction on the blockchain.
//
// NOTICE: digital currency only
TxId string `json:"txId"`
// The transaction fee you paid to deposit amount of symbol on Bitvavo.
Fee string `json:"fee"`
// The current state of this deposit. Possible values are:
// completed - amount of symbol has been added to your balance on Bitvavo.
// canceled - this deposit could not be completed.
//
// NOTICE: fiat currency only
Status string `json:"status"`
}
func (*DepositHistory) UnmarshalJSON ¶
func (d *DepositHistory) UnmarshalJSON(bytes []byte) error
type DepositHistoryParams ¶
type DepositHistoryParams struct {
// When no symbol is specified, all deposits will be returned.
Symbol string `json:"symbol"`
// Return the limit most recent assets only.
// Default: 500
Limit uint64 `json:"limit"`
// Return orders after start time.
Start time.Time `json:"start"`
// Return orders before end time.
End time.Time `json:"end"`
}
func (*DepositHistoryParams) Params ¶
func (d *DepositHistoryParams) Params() url.Values
type DepositStatus ¶
type Fill ¶
type Fill struct {
// The id of the returned fill
FillId string `json:"fillId"`
// The market in which the order was placed.
Market string `json:"market"`
// The id of the order on which has been filled
OrderId string `json:"orderId"`
// The current timestamp in milliseconds since 1 Jan 1970
Timestamp int64 `json:"timestamp"`
// The amount in base currency for which the trade has been made
Amount string `json:"amount"`
// The side for the taker
Side Side `json:"side"`
// The price in quote currency for which the trade has been made
Price string `json:"price"`
// True for takers, false for makers
Taker bool `json:"taker"`
// The amount of fee that has been paid. Value is negative for rebates. Only available if settled is true
Fee string `json:"fee"`
// Currency in which the fee has been paid. Only available if settled is true
FeeCurrency string `json:"feeCurrency"`
// True when the fee has been deducted and the bought/sold currency is available for further trading.
// Fills are settled almost instantly.
Settled bool `json:"settled"`
}
func (*Fill) UnmarshalJSON ¶
type FillEvent ¶
type FillEvent ListenerEvent[Fill]
type FillListener ¶
type FillListener authListener[FillEvent]
func (*FillListener) Close ¶
func (l *FillListener) Close() error
func (*FillListener) Subscribe ¶
func (l *FillListener) Subscribe(markets []string) (<-chan FillEvent, error)
func (*FillListener) Unsubscribe ¶
func (l *FillListener) Unsubscribe(markets []string) error
type HttpOption ¶
type HttpOption func(*httpClient)
func WithDebugPrinter ¶
func WithDebugPrinter(printer DebugPrinter) HttpOption
func WithDefaultDebugPrinter ¶
func WithDefaultDebugPrinter() HttpOption
func WithHttpClient ¶
func WithHttpClient(client *http.Client) HttpOption
func WithWindowTime ¶
func WithWindowTime(windowTimeMs uint16) HttpOption
type Listener ¶
type Listener[T any] interface { Subscriber[T] Unsubscriber Closer }
func NewBookListener ¶
func NewBookListener(options ...WebSocketOption) Listener[BookEvent]
func NewFillListener ¶
func NewFillListener(apiKey, apiSecret string, options ...WebSocketOption) Listener[FillEvent]
func NewOrderListener ¶
func NewOrderListener(apiKey, apiSecret string, options ...WebSocketOption) Listener[OrderEvent]
func NewTicker24hListener ¶
func NewTicker24hListener(options ...WebSocketOption) Listener[Ticker24hEvent]
func NewTickerListener ¶
func NewTickerListener(options ...WebSocketOption) Listener[TickerEvent]
func NewTradesListener ¶
func NewTradesListener(options ...WebSocketOption) Listener[TradeEvent]
type ListenerEvent ¶
type Market ¶
type Market struct {
// The market itself
Market string `json:"market"`
// The status of the market
Status MarketStatus `json:"status"`
// Base currency, found on the left side of the dash in market.
Base string `json:"base"`
// Quote currency, found on the right side of the dash in market.
Quote string `json:"quote"`
// Price precision determines how many significant digits are allowed. The rationale behind this is that for higher amounts, smaller price increments are less relevant.
// Examples of valid prices for precision 5 are: 100010, 11313, 7500.10, 7500.20, 500.12, 0.0012345.
// Examples of precision 6 are: 11313.1, 7500.11, 7500.25, 500.123, 0.00123456.
PricePrecision int64 `json:"pricePrecision"`
// The minimum amount in quote currency (amountQuote or amount * price) for valid orders.
MinOrderInBaseAsset string `json:"minOrderInBaseAsset"`
// The minimum amount in base currency for valid orders.
MinOrderInQuoteAsset string `json:"minOrderInQuoteAsset"`
// The maximum amount in quote currency (amountQuote or amount * price) for valid orders.
MaxOrderInBaseAsset string `json:"maxOrderInBaseAsset"`
// The maximum amount in base currency for valid orders.
MaxOrderInQuoteAsset string `json:"maxOrderInQuoteAsset"`
// Allowed order types for this market.
OrderTypes []OrderType `json:"orderTypes"`
}
func (*Market) UnmarshalJSON ¶
type MarketStatus ¶
type Order ¶
type Order struct {
// The order id of the returned order.
OrderId string `json:"orderId"`
// The market in which the order was placed.
Market string `json:"market"`
// Is a timestamp in milliseconds since 1 Jan 1970.
Created int64 `json:"created"`
// Is a timestamp in milliseconds since 1 Jan 1970.
Updated int64 `json:"updated"`
// The current status of the order.
Status OrderStatus `json:"status"`
// Side
Side Side `json:"side"`
// OrderType
OrderType OrderType `json:"orderType"`
// Original amount.
Amount string `json:"amount"`
// Amount remaining (lower than 'amount' after fills).
AmountRemaining string `json:"amountRemaining"`
// The price of the order.
Price string `json:"price"`
// Amount of 'onHoldCurrency' that is reserved for this order. This is released when orders are canceled.
OnHold string `json:"onHold"`
// The currency placed on hold is the quote currency for sell orders and base currency for buy orders.
OnHoldCurrency string `json:"onHoldCurrency"`
// Only for stop orders: The current price used in the trigger. This is based on the triggerAmount and triggerType.
TriggerPrice string `json:"triggerPrice"`
// Only for stop orders: The value used for the triggerType to determine the triggerPrice.
TriggerAmount string `json:"triggerAmount"`
// Only for stop orders.
TriggerType OrderTriggerType `json:"triggerType"`
// Only for stop orders: The reference price used for stop orders.
TriggerReference OrderTriggerRef `json:"triggerReference"`
// Only for limit orders: Determines how long orders remain active.
// Possible values: Good-Til-Canceled (GTC), Immediate-Or-Cancel (IOC), Fill-Or-Kill (FOK).
// GTC orders will remain on the order book until they are filled or canceled.
// IOC orders will fill against existing orders, but will cancel any remaining amount after that.
// FOK orders will fill against existing orders in its entirety, or will be canceled (if the entire order cannot be filled).
//
TimeInForce TimeInForce `json:"timeInForce"`
// Default: false
PostOnly bool `json:"postOnly"`
// Self trading is not allowed on Bitvavo. Multiple options are available to prevent this from happening.
// The default ‘decrementAndCancel’ decrements both orders by the amount that would have been filled, which in turn cancels the smallest of the two orders.
// ‘cancelOldest’ will cancel the entire older order and places the new order.
// ‘cancelNewest’ will cancel the order that is submitted.
// ‘cancelBoth’ will cancel both the current and the old order.
//
// Default: "decrementAndCancel"
SelfTradePrevention SelfTradePrevention `json:"selfTradePrevention"`
// Whether this order is visible on the order book.
Visible bool `json:"visible"`
// The fills for this order
Fills []OrderFill `json:"fills"`
// How much of this order is filled
FilledAmount string `json:"filledAmount"`
// How much of this order is filled in quote currency
FilledAmountQuote string `json:"filledAmountQuote"`
// The currency in which the fee is paid (e.g: EUR)
FeeCurrency string `json:"feeCurrency"`
// How much fee is paid
FeePaid string `json:"feePaid"`
}
func (*Order) UnmarshalJSON ¶
type OrderEvent ¶
type OrderEvent ListenerEvent[Order]
type OrderListener ¶
type OrderListener authListener[OrderEvent]
func (*OrderListener) Close ¶
func (l *OrderListener) Close() error
func (*OrderListener) Subscribe ¶
func (l *OrderListener) Subscribe(markets []string) (<-chan OrderEvent, error)
func (*OrderListener) Unsubscribe ¶
func (l *OrderListener) Unsubscribe(markets []string) error
type OrderNew ¶
type OrderNew struct {
// The market in which the order should be placed (e.g: ETH-EUR)
Market string `json:"market"`
// When placing a buy order the base currency will be bought for the quote currency. When placing a sell order the base currency will be sold for the quote currency.
Side Side `json:"side"`
// For limit orders, amount and price are required. For market orders either amount or amountQuote is required.
OrderType OrderType `json:"orderType"`
// Specifies the amount of the base asset that will be bought/sold.
Amount string `json:"amount,omitempty"`
// Only for limit orders: Specifies the amount in quote currency that is paid/received for each unit of base currency.
Price string `json:"price,omitempty"`
// Only for market orders: If amountQuote is specified, [amountQuote] of the quote currency will be bought/sold for the best price available.
AmountQuote string `json:"amountQuote,omitempty"`
// Only for stop orders: Specifies the amount that is used with the triggerType.
// Combine this parameter with triggerType and triggerReference to create the desired trigger.
TriggerAmount string `json:"triggerAmount,omitempty"`
// Only for stop orders: Only allows price for now. A triggerAmount of 4000 and a triggerType of price will generate a triggerPrice of 4000.
// Combine this parameter with triggerAmount and triggerReference to create the desired trigger.
TriggerType OrderTriggerType `json:"triggerType,omitempty"`
// Only for stop orders: Use this to determine which parameter will trigger the order.
// Combine this parameter with triggerAmount and triggerType to create the desired trigger.
TriggerReference OrderTriggerRef `json:"triggerReference,omitempty"`
// Only for limit orders: Determines how long orders remain active.
// Possible values: Good-Til-Canceled (GTC), Immediate-Or-Cancel (IOC), Fill-Or-Kill (FOK).
// GTC orders will remain on the order book until they are filled or canceled.
// IOC orders will fill against existing orders, but will cancel any remaining amount after that.
// FOK orders will fill against existing orders in its entirety, or will be canceled (if the entire order cannot be filled).
//
// Default: "GTC"
TimeInForce TimeInForce `json:"timeInForce,omitempty"`
// Self trading is not allowed on Bitvavo. Multiple options are available to prevent this from happening.
// The default ‘decrementAndCancel’ decrements both orders by the amount that would have been filled, which in turn cancels the smallest of the two orders.
// ‘cancelOldest’ will cancel the entire older order and places the new order.
// ‘cancelNewest’ will cancel the order that is submitted.
// ‘cancelBoth’ will cancel both the current and the old order.
//
// Default: "decrementAndCancel"
SelfTradePrevention SelfTradePrevention `json:"selfTradePrevention,omitempty"`
// Only for limit orders: When postOnly is set to true, the order will not fill against existing orders.
// This is useful if you want to ensure you pay the maker fee. If the order would fill against existing orders, the entire order will be canceled.
//
// Default: false
PostOnly bool `json:"postOnly,omitempty"`
// Only for market orders: In order to protect clients from filling market orders with undesirable prices,
// the remainder of market orders will be canceled once the next fill price is 10% worse than the best fill price (best bid/ask at first match).
// If you wish to disable this protection, set this value to ‘true’.
//
// Default: false
DisableMarketProtection bool `json:"disableMarketProtection,omitempty"`
// If this is set to 'true', all order information is returned.
// Set this to 'false' when only an acknowledgement of success or failure is required, this is faster.
//
// Default: true
ResponseRequired bool `json:"responseRequired,omitempty"`
}
func (OrderNew) MarshalJSON ¶
type OrderParams ¶
type OrderParams struct {
// Return the limit most recent orders only.
// Default: 500
Limit uint64 `json:"limit"`
// Return orders after start time.
Start time.Time `json:"start"`
// Return orders before end time.
End time.Time `json:"end"`
// Filter used to limit the returned results.
// All orders after this order ID are returned (i.e. showing those later in time).
OrderIdFrom string `json:"orderIdFrom"`
// Filter used to limit the returned results.
// All orders up to this order ID are returned (i.e. showing those earlier in time).
OrderIdTo string `json:"orderIdTo"`
}
func (*OrderParams) Params ¶
func (o *OrderParams) Params() url.Values
type OrderStatus ¶
type OrderTriggerRef ¶
type OrderTriggerType ¶
type OrderUpdate ¶
type OrderUpdate struct {
// The market for which an order should be updated
Market string `json:"market"`
// The id of the order which should be updated
OrderId string `json:"orderId"`
// Updates amount to this value (and also changes amountRemaining accordingly).
Amount string `json:"amount,omitempty"`
// Only for market orders: If amountQuote is specified, [amountQuote] of the quote currency will be bought/sold for the best price available.
AmountQuote string `json:"amountQuote,omitempty"`
// Updates amountRemaining to this value (and also changes amount accordingly).
AmountRemaining string `json:"amountRemaining,omitempty"`
// Specifies the amount in quote currency that is paid/received for each unit of base currency.
Price string `json:"price,omitempty"`
// Only for stop orders: Specifies the amount that is used with the triggerType.
// Combine this parameter with triggerType and triggerReference to create the desired trigger.
TriggerAmount string `json:"triggerAmount,omitempty"`
// Only for limit orders: Determines how long orders remain active.
// Possible values: Good-Til-Canceled (GTC), Immediate-Or-Cancel (IOC), Fill-Or-Kill (FOK).
// GTC orders will remain on the order book until they are filled or canceled.
// IOC orders will fill against existing orders, but will cancel any remaining amount after that.
// FOK orders will fill against existing orders in its entirety, or will be canceled (if the entire order cannot be filled).
//
// Default: "GTC"
TimeInForce TimeInForce `json:"timeInForce,omitempty"`
// Self trading is not allowed on Bitvavo. Multiple options are available to prevent this from happening.
// The default ‘decrementAndCancel’ decrements both orders by the amount that would have been filled, which in turn cancels the smallest of the two orders.
// ‘cancelOldest’ will cancel the entire older order and places the new order.
// ‘cancelNewest’ will cancel the order that is submitted.
// ‘cancelBoth’ will cancel both the current and the old order.
//
// Default: "decrementAndCancel"
SelfTradePrevention SelfTradePrevention `json:"selfTradePrevention,omitempty"`
// Only for limit orders: When postOnly is set to true, the order will not fill against existing orders.
// This is useful if you want to ensure you pay the maker fee. If the order would fill against existing orders, the entire order will be canceled.
//
// Default: false
PostOnly bool `json:"postOnly,omitempty"`
// If this is set to 'true', all order information is returned.
// Set this to 'false' when only an acknowledgement of success or failure is required, this is faster.
//
// Default: true
ResponseRequired bool `json:"responseRequired,omitempty"`
}
func (OrderUpdate) MarshalJSON ¶
func (o OrderUpdate) MarshalJSON() ([]byte, error)
type PrivateAPI ¶
type PrivateAPI interface {
PublicAPI
// GetBalance returns the balance on the account.
// Optionally provide the symbol to filter for in uppercase (e.g: ETH)
GetBalance(ctx context.Context, symbol ...string) ([]Balance, error)
// GetAccount returns trading volume and fees for account.
GetAccount(ctx context.Context) (Account, error)
// GetTradesHistoric returns historic trades for your account for market (e.g: ETH-EUR)
//
// Optionally provide extra params (see: TradeParams)
GetTradesHistoric(ctx context.Context, market string, params ...Params) ([]TradeHistoric, error)
// GetOrders returns data for multiple orders at once for market (e.g: ETH-EUR)
//
// Optionally provide extra params (see: OrderParams)
GetOrders(ctx context.Context, market string, params ...Params) ([]Order, error)
// GetOrdersOpen returns all open orders for market (e.g: ETH-EUR) or all open orders
// if no market is given.
GetOrdersOpen(ctx context.Context, market ...string) ([]Order, error)
// GetOrder returns the order by market and ID
GetOrder(ctx context.Context, market string, orderId string) (Order, error)
// CancelOrders cancels multiple orders at once.
// Either for an entire market (e.g: ETH-EUR) or for the entire account if you
// omit the market.
//
// It returns a slice of orderId's of which are canceled
CancelOrders(ctx context.Context, market ...string) ([]string, error)
// CancelOrder cancels a single order by ID for the specific market (e.g: ETH-EUR)
//
// It returns the canceled orderId if it was canceled
CancelOrder(ctx context.Context, market string, orderId string) (string, error)
// NewOrder places a new order on the exchange.
//
// It returns the new order if it was successfully created
NewOrder(ctx context.Context, market string, side Side, orderType OrderType, order OrderNew) (Order, error)
// UpdateOrder updates an existing order on the exchange.
//
// It returns the updated order if it was successfully updated
UpdateOrder(ctx context.Context, market string, orderId string, order OrderUpdate) (Order, error)
// GetDepositAsset returns deposit address (with paymentid for some assets)
// or bank account information to increase your balance for a specific symbol (e.g: ETH)
GetDepositAsset(ctx context.Context, symbol string) (DepositAsset, error)
// GetDepositHistory returns the deposit history of the account.
//
// Optionally provide extra params (see: DepositHistoryParams)
GetDepositHistory(ctx context.Context, params ...Params) ([]DepositHistory, error)
// GetWithdrawalHistory returns the withdrawal history of the account.
//
// Optionally provide extra params (see: WithdrawalHistoryParams)
GetWithdrawalHistory(ctx context.Context, params ...Params) ([]WithdrawalHistory, error)
// Withdraw requests a withdrawal to an external cryptocurrency address or verified bank account.
// Please note that 2FA and address confirmation by e-mail are disabled for API withdrawals.
Withdraw(ctx context.Context, symbol string, amount string, address string, withdrawal Withdrawal) (WithDrawalResponse, error)
}
func NewPrivateHTTPClient ¶
func NewPrivateHTTPClient(apiKey, apiSecret string, options ...HttpOption) PrivateAPI
type PublicAPI ¶
type PublicAPI interface {
// GetRateLimit returns the remaining rate limit.
//
// Default value: -1
GetRateLimit() int64
// GetRateLimitResetAt returns the time (local time) when the counter resets.
GetRateLimitResetAt() time.Time
// GetTime returns the current server time in milliseconds since 1 Jan 1970
GetTime(ctx context.Context) (int64, error)
// GetMarkets returns the available markets with their status (trading,halted,auction) and
// available order types.
GetMarkets(ctx context.Context) ([]Market, error)
// GetMarket returns the available markets with their status (trading,halted,auction) and
// available order types for a single market (e.g: ETH-EUR)
GetMarket(ctx context.Context, market string) (Market, error)
// GetAssets returns information on the supported assets
GetAssets(ctx context.Context) ([]Asset, error)
// GetAsset returns information on the supported asset by symbol (e.g: ETH).
GetAsset(ctx context.Context, symbol string) (Asset, error)
// GetOrderBook returns a book with bids and asks for market.
// That is, the buy and sell orders made by all Bitvavo users in a specific market (e.g: ETH-EUR).
// The orders in the return parameters are sorted by price
//
// Optionally provide the depth (single value) to return the top depth orders only.
GetOrderBook(ctx context.Context, market string, depth ...uint64) (Book, error)
// GetTrades returns the list of all trades made by all Bitvavo users for market (e.g: ETH-EUR).
// That is, the trades that have been executed in the past.
//
// Optionally provide extra params (see: TradeParams)
GetTrades(ctx context.Context, market string, params ...Params) ([]Trade, error)
// GetCandles returns the Open, High, Low, Close, Volume (OHLCV) data you use to create candlestick charts
// for market with interval time between each candlestick (e.g: market=ETH-EUR interval=5m)
//
// Optionally provide extra params (see: CandleParams)
GetCandles(ctx context.Context, market string, interval Interval, params ...Params) ([]CandleOnly, error)
// GetTickerPrices returns price of the latest trades on Bitvavo for all markets.
GetTickerPrices(ctx context.Context) ([]TickerPrice, error)
// GetTickerPrice returns price of the latest trades on Bitvavo for a single market (e.g: ETH-EUR).
GetTickerPrice(ctx context.Context, market string) (TickerPrice, error)
// GetTickerBooks returns the highest buy and the lowest sell prices currently available for
// all markets in the Bitvavo order book.
GetTickerBooks(ctx context.Context) ([]TickerBook, error)
// GetTickerBook returns the highest buy and the lowest sell prices currently
// available for a single market (e.g: ETH-EUR) in the Bitvavo order book.
GetTickerBook(ctx context.Context, market string) (TickerBook, error)
// GetTickers24h returns high, low, open, last, and volume information for trades and orders for all markets over the previous 24 hours.
GetTickers24h(ctx context.Context) ([]Ticker24hData, error)
// GetTicker24h returns high, low, open, last, and volume information for trades and orders for a single market over the previous 24 hours.
GetTicker24h(ctx context.Context, market string) (Ticker24hData, error)
}
func NewPublicHTTPClient ¶
func NewPublicHTTPClient(options ...HttpOption) PublicAPI
type SelfTradePrevention ¶
type Subscribed ¶
type Subscribed struct {
// Currently active subscriptions that the broker knows of.
Subscriptions map[Channel][]string
// Currently active subscriptions with an interval that the broker knows of.
SubscriptionsInterval map[Channel]map[Interval][]string
}
func (*Subscribed) UnmarshalJSON ¶
func (s *Subscribed) UnmarshalJSON(bytes []byte) error
type Subscriber ¶
type Subscription ¶
func NewSubscription ¶
func NewSubscription(channel Channel, markets []string, intervals ...Interval) Subscription
type Ticker ¶
type Ticker struct {
// The market which was requested in the subscription.
Market string `json:"market"`
// The price of the best (highest) bid offer available, only sent when either bestBid or bestBidSize has changed.
BestBid string `json:"bestBid"`
// The size of the best (highest) bid offer available, only sent when either bestBid or bestBidSize has changed.
BestBidSize string `json:"bestBidSize"`
// The price of the best (lowest) ask offer available, only sent when either bestAsk or bestAskSize has changed.
BestAsk string `json:"bestAsk"`
// The size of the best (lowest) ask offer available, only sent when either bestAsk or bestAskSize has changed.
BestAskSize string `json:"bestAskSize"`
// The last price for which a trade has occurred, only sent when lastPrice has changed.
LastPrice string `json:"lastPrice"`
}
type Ticker24h ¶
type Ticker24h struct {
Data []Ticker24hData `json:"data"`
}
type Ticker24hData ¶
type Ticker24hData struct {
// The market which was requested in the subscription.
Market string `json:"market"`
// The open price of the 24-hour period.
Open string `json:"open"`
// The highest price for which a trade occurred in the 24-hour period.
High string `json:"high"`
// The lowest price for which a trade occurred in the 24-hour period.
Low string `json:"low"`
// The last price for which a trade occurred in the 24-hour period.
Last string `json:"last"`
// The total volume of the 24-hour period in base currency.
Volume string `json:"volume"`
// The total volume of the 24-hour period in quote currency.
VolumeQuote string `json:"volumeQuote"`
// The best (highest) bid offer at the current moment.
Bid string `json:"bid"`
// The size of the best (highest) bid offer.
BidSize string `json:"bidSize"`
// The best (lowest) ask offer at the current moment.
Ask string `json:"ask"`
// The size of the best (lowest) ask offer.
AskSize string `json:"askSize"`
// Timestamp in unix milliseconds.
Timestamp int64 `json:"timestamp"`
// Start timestamp in unix milliseconds.
StartTimestamp int64 `json:"startTimestamp"`
// Open timestamp in unix milliseconds.
OpenTimestamp int64 `json:"openTimestamp"`
// Close timestamp in unix milliseconds.
CloseTimestamp int64 `json:"closeTimestamp"`
}
func (*Ticker24hData) UnmarshalJSON ¶
func (t *Ticker24hData) UnmarshalJSON(bytes []byte) error
type Ticker24hEvent ¶
type Ticker24hEvent ListenerEvent[Ticker24hData]
type Ticker24hListener ¶
type Ticker24hListener listener[Ticker24hEvent]
func (*Ticker24hListener) Close ¶
func (l *Ticker24hListener) Close() error
func (*Ticker24hListener) Subscribe ¶
func (l *Ticker24hListener) Subscribe(markets []string) (<-chan Ticker24hEvent, error)
func (*Ticker24hListener) Unsubscribe ¶
func (l *Ticker24hListener) Unsubscribe(markets []string) error
type TickerBook ¶
type TickerBook struct {
// The market you requested the current best orders for.
Market string `json:"market"`
// The highest buy order in quote currency for market currently available on Bitvavo.
Bid string `json:"bid"`
// The amount of base currency for bid in the order.
BidSize string `json:"bidSize"`
// The lowest sell order in quote currency for market currently available on Bitvavo.
Ask string `json:"ask"`
// The amount of base currency for ask in the order.
AskSize string `json:"askSize"`
}
type TickerEvent ¶
type TickerEvent ListenerEvent[Ticker]
type TickerListener ¶
type TickerListener listener[TickerEvent]
func (*TickerListener) Close ¶
func (l *TickerListener) Close() error
func (*TickerListener) Subscribe ¶
func (l *TickerListener) Subscribe(markets []string) (<-chan TickerEvent, error)
func (*TickerListener) Unsubscribe ¶
func (l *TickerListener) Unsubscribe(markets []string) error
type TickerPrice ¶
type TimeInForce ¶
type Trade ¶
type Trade struct {
// The trade ID of the returned trade (UUID).
Id string `json:"id"`
// The market which was requested in the subscription.
Market string `json:"market"`
// The amount in base currency for which the trade has been made.
Amount string `json:"amount"`
// The price in quote currency for which the trade has been made.
Price string `json:"price"`
// The side for the taker.
Side Side `json:"side"`
// Timestamp in unix milliseconds.
Timestamp int64 `json:"timestamp"`
}
func (*Trade) UnmarshalJSON ¶
type TradeEvent ¶
type TradeEvent ListenerEvent[Trade]
type TradeHistoric ¶
type TradeHistoric Fill
type TradeParams ¶
type TradeParams struct {
// Return the limit most recent trades only.
// Default: 500
Limit uint64 `json:"limit"`
// Return limit trades executed after start.
Start time.Time `json:"start"`
// Return limit trades executed before end.
End time.Time `json:"end"`
// Return limit trades executed after tradeIdFrom was made.
TradeIdFrom string `json:"tradeIdFrom"`
// Return limit trades executed before tradeIdTo was made.
TradeIdTo string `json:"tradeIdTo"`
}
func (*TradeParams) Params ¶
func (t *TradeParams) Params() url.Values
type TradesListener ¶
type TradesListener listener[TradeEvent]
func (*TradesListener) Close ¶
func (l *TradesListener) Close() error
func (*TradesListener) Subscribe ¶
func (l *TradesListener) Subscribe(markets []string) (<-chan TradeEvent, error)
func (*TradesListener) Unsubscribe ¶
func (l *TradesListener) Unsubscribe(markets []string) error
type Unsubscribed ¶
type Unsubscribed = Subscribed
type Unsubscriber ¶
type WebSocket ¶
type WebSocket struct {
// contains filtered or unexported fields
}
func NewWebSocket ¶
func NewWebSocket( ctx context.Context, messageFunc func(WebSocketEventData, error), reconnectFunc func(), options ...WebSocketOption, ) (*WebSocket, error)
func (*WebSocket) Authenticate ¶
func (*WebSocket) Subscribe ¶
func (w *WebSocket) Subscribe(subscriptions []Subscription) error
func (*WebSocket) Unsubscribe ¶
func (w *WebSocket) Unsubscribe(subscriptions []Subscription) error
type WebSocketError ¶
type WebSocketError struct {
Code int `json:"errorCode"`
Message string `json:"error"`
Action string `json:"action"`
}
WebSocketError Complete list of errorCodes: https://docs.bitvavo.com/#tag/Error-messages
func (*WebSocketError) Error ¶
func (b *WebSocketError) Error() string
type WebSocketEvent ¶
type WebSocketEventData ¶
type WebSocketEventData struct {
Event WebSocketEvent
Reader io.Reader
}
func (*WebSocketEventData) Decode ¶
func (d *WebSocketEventData) Decode(v any) error
func (*WebSocketEventData) UnmarshalJSON ¶
func (d *WebSocketEventData) UnmarshalJSON(b []byte) error
type WebSocketOption ¶
type WebSocketOption func(*WebSocket)
func WithWebSocketDebugPrinter ¶
func WithWebSocketDebugPrinter(printer DebugPrinter) WebSocketOption
func WithWebSocketDefaultDebugPrinter ¶
func WithWebSocketDefaultDebugPrinter() WebSocketOption
func WithWebSocketHttpClient ¶
func WithWebSocketHttpClient(client *http.Client) WebSocketOption
type WithDrawalResponse ¶
type Withdrawal ¶
type Withdrawal struct {
// The short name of the asset. For example, BTC for Bitcoin.
Symbol string `json:"symbol"`
// Total amount that has been deducted from your balance.
Amount string `json:"amount"`
// Wallet address or IBAN.
// For digital assets: please double check this address. Funds sent can not be recovered.
Address string `json:"address"`
// For digital assets only. Payment IDs are used to identify transactions to merchants and exchanges with a single address. This is mostly called a note, memo or tag. Should be set when withdrawing straight to another exchange or merchants that require payment id's.
PaymentId string `json:"paymentId,omitempty"`
// For digital assets only.
// Should be set to true if the withdrawal must be sent to another Bitvavo user internally.
// No transaction will be broadcast to the blockchain and no fees will be applied.
// This operation fails if the wallet does not belong to a Bitvavo user.
Internal bool `json:"internal,omitempty"`
// If set to true, the fee will be added on top of the requested amount,
// otherwise the fee is part of the requested amount and subtracted from the withdrawal.
AddWithdrawalFee bool `json:"addWithdrawalFee,omitempty"`
}
type WithdrawalHistory ¶
type WithdrawalHistory struct {
// The time your withdrawal of symbol was received by Bitvavo.
Timestamp int64 `json:"timestamp"`
// The short name of the asset. For example, BTC for Bitcoin.
Symbol string `json:"symbol"`
// Amount that has been withdrawn.
Amount string `json:"amount"`
// Address that has been used for this withdrawal.
Address string `json:"address"`
// Payment ID used for this withdrawal. This is mostly called a note, memo or tag. Will not be returned if it was not used.
PaymentId string `json:"paymentId"`
// The transaction ID, which can be found on the blockchain, for this specific withdrawal.
TxId string `json:"txId"`
// The fee which has been paid to withdraw this currency.
Fee string `json:"fee"`
// The status of the withdrawal.
Status WithdrawalHistoryStatus `json:"status"`
}
func (*WithdrawalHistory) UnmarshalJSON ¶
func (w *WithdrawalHistory) UnmarshalJSON(bytes []byte) error
type WithdrawalHistoryParams ¶
type WithdrawalHistoryParams struct {
// When no symbol is specified, all withdrawal will be returned.
Symbol string `json:"symbol"`
// Return the limit most recent assets only.
// Default: 500
Limit uint64 `json:"limit"`
// Return orders after start time.
Start time.Time `json:"start"`
// Return orders before end time.
End time.Time `json:"end"`
}
func (*WithdrawalHistoryParams) Params ¶
func (w *WithdrawalHistoryParams) Params() url.Values
type WithdrawalHistoryStatus ¶
type WithdrawalStatus ¶
Source Files
¶
- account.go
- asset.go
- authenticate.go
- balance.go
- book.go
- book_listener.go
- candle.go
- candles_listener.go
- debug_printer.go
- deposit.go
- error.go
- fill.go
- fill_listener.go
- http.go
- http_client.go
- listener.go
- market.go
- order.go
- order_listener.go
- side.go
- subscribed.go
- subscription.go
- ticker.go
- ticker24h.go
- ticker24h_listener.go
- ticker_listener.go
- tickerbook.go
- tickerprice.go
- trade.go
- trades_listener.go
- websocket.go
- withdrawal.go
Click to show internal directories.
Click to hide internal directories.