Documentation ¶
Overview ¶
Package bitfinex is the official client to access to bitfinex.com API
Index ¶
- Constants
- Variables
- type AuthEvent
- type BalanceInfo
- type BalanceUpdate
- type Capabilities
- type Capability
- type Client
- type ConfEvent
- type Credit
- type CreditStatus
- type ErrorEvent
- type ErrorResponse
- type FundingCreditCancel
- type FundingCreditNew
- type FundingCreditSnapshot
- type FundingCreditUpdate
- type FundingInfo
- type FundingLoanCancel
- type FundingLoanNew
- type FundingLoanSnapshot
- type FundingLoanUpdate
- type FundingOfferCancel
- type FundingOfferNew
- type FundingOfferSnapshot
- type FundingOfferUpdate
- type FundingTrade
- type FundingTradeExecution
- type FundingTradeSnapshot
- type FundingTradeUpdate
- type Heartbeat
- type HistoricalCredit
- type HistoricalFundingTradeSnapshot
- type HistoricalLoan
- type HistoricalOffer
- type HistoricalTradeSnapshot
- type InfoEvent
- type Loan
- type LoanStatus
- type MarginInfoBase
- type MarginInfoUpdate
- type Notification
- type Offer
- type OfferStatus
- type Order
- type OrderCancel
- type OrderCancelRequest
- type OrderNew
- type OrderNewRequest
- type OrderService
- type OrderSnapshot
- type OrderStatus
- type OrderType
- type OrderUpdate
- type PlatformService
- type Position
- type PositionCancel
- type PositionNew
- type PositionService
- type PositionSnapshot
- type PositionStatus
- type PositionUpdate
- type PublicSubscriptionRequest
- type Response
- type SubscribeEvent
- type Ticker
- type TickerSnapshot
- type TickerUpdate
- type Trade
- type TradeExecution
- type TradeService
- type TradeSnapshot
- type TradeUpdate
- type UnsubscribeEvent
- type Wallet
- type WalletSnapshot
- type WalletUpdate
Constants ¶
const ( // BaseURL is the v2 REST endpoint. BaseURL = "https://api.bitfinex.com/v2/" // WebSocketURL is the v2 Websocket endpoint. WebSocketURL = "wss://api.bitfinex.com/ws/2" )
const ( OrderTypeMarket = "MARKET" OrderTypeExchangeMarket = "EXCHANGE MARKET" OrderTypeLimit = "LIMIT" OrderTypeExchangeLimit = "EXCHANGE LIMIT" OrderTypeStop = "STOP" OrderTypeExchangeStop = "EXCHANGE STOP" OrderTypeTrailingStop = "TRAILING STOP" OrderTypeExchangeTrailingStop = "EXCHANGE TRAILING STOP" OrderTypeFOK = "FOK" OrderTypeExchangeFOK = "EXCHANGE FOK" OrderTypeStopLimit = "STOP LIMIT" )
const ( BTCUSD = "BTCUSD" LTCUSD = "LTCUSD" LTCBTC = "LTCBTC" ETHUSD = "ETHUSD" ETHBTC = "ETHBTC" ETCUSD = "ETCUSD" ETCBTC = "ETCBTC" BFXUSD = "BFXUSD" BFXBTC = "BFXBTC" ZECUSD = "ZECUSD" ZECBTC = "ZECBTC" XMRUSD = "XMRUSD" XMRBTC = "XMRBTC" RRTUSD = "RRTUSD" RRTBTC = "RRTBTC" XRPUSD = "XRPUSD" XRPBTC = "XRPBTC" EOSETH = "EOSETH" EOSUSD = "EOSUSD" EOSBTC = "EOSBTC" IOTUSD = "IOTUSD" IOTBTC = "IOTBTC" IOTETH = "IOTETH" BCCBTC = "BCCBTC" BCUBTC = "BCUBTC" BCCUSD = "BCCUSD" BCUUSD = "BCUUSD" )
Available pairs
const ( ChanBook = "book" ChanTrades = "trades" ChanTicker = "ticker" ChanCandles = "candles" )
Available channels
const ( FundingPrefix = "f" TradingPrefix = "t" )
Prefixes for available pairs
Variables ¶
var (
ErrNotFound = errors.New("not found")
)
var ErrWSNotConnected = fmt.Errorf("websocket connection not established")
Functions ¶
This section is empty.
Types ¶
type AuthEvent ¶
type AuthEvent struct { Event string `json:"event"` Status string `json:"status"` ChanID int64 `json:"chanId,omitempty"` UserID int64 `json:"userId,omitempty"` SubID string `json:"subId"` AuthID string `json:"auth_id,omitempty"` Message string `json:"msg,omitempty"` Caps Capabilities `json:"caps"` }
type BalanceInfo ¶
type BalanceUpdate ¶
type BalanceUpdate BalanceInfo
type Capabilities ¶
type Capabilities struct { Orders Capability `json:"orders"` Account Capability `json:"account"` Funding Capability `json:"funding"` History Capability `json:"history"` Wallets Capability `json:"wallets"` Withdraw Capability `json:"withdraw"` Positions Capability `json:"positions"` }
type Capability ¶
type Client ¶
type Client struct { // Base URL for API requests. BaseURL *url.URL HTTPClient *http.Client // Auth data APIKey string APISecret string // Services Websocket *bfxWebsocket Orders *OrderService Platform *PlatformService Positions *PositionService Trades *TradeService }
func NewClientWithHTTP ¶
type Credit ¶
type Credit struct { ID int64 Symbol string Side string MTSCreated int64 MTSUpdated int64 Amout float64 Flags interface{} Status CreditStatus Rate float64 Period int64 MTSOpened int64 MTSLastPayout int64 Notify bool Hidden bool Insure bool Renew bool RateReal float64 NoClose bool PositionPair string }
type CreditStatus ¶
type CreditStatus string
const ( CreditStatusActive CreditStatus = "ACTIVE" CreditStatusExecuted CreditStatus = "EXECUTED" CreditStatusPartiallyFilled CreditStatus = "PARTIALLY FILLED" CreditStatusCanceled CreditStatus = "CANCELED" )
type ErrorEvent ¶
type ErrorResponse ¶
type ErrorResponse struct { Response *Response Message string `json:"message"` Code int `json:"code"` }
In case if API will wrong response code ErrorResponse will be returned to caller
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type FundingCreditCancel ¶
type FundingCreditCancel Credit
type FundingCreditNew ¶
type FundingCreditNew Credit
type FundingCreditSnapshot ¶
type FundingCreditSnapshot []Credit
type FundingCreditUpdate ¶
type FundingCreditUpdate Credit
type FundingInfo ¶
type FundingLoanCancel ¶
type FundingLoanCancel Loan
type FundingLoanNew ¶
type FundingLoanNew Loan
type FundingLoanSnapshot ¶
type FundingLoanSnapshot []Loan
type FundingLoanUpdate ¶
type FundingLoanUpdate Loan
type FundingOfferCancel ¶
type FundingOfferCancel Offer
type FundingOfferNew ¶
type FundingOfferNew Offer
type FundingOfferSnapshot ¶
type FundingOfferSnapshot []Offer
type FundingOfferUpdate ¶
type FundingOfferUpdate Offer
type FundingTrade ¶
type FundingTradeExecution ¶
type FundingTradeExecution FundingTrade
type FundingTradeSnapshot ¶
type FundingTradeSnapshot []FundingTrade
type FundingTradeUpdate ¶
type FundingTradeUpdate FundingTrade
type HistoricalCredit ¶
type HistoricalCredit Credit
type HistoricalFundingTradeSnapshot ¶
type HistoricalFundingTradeSnapshot FundingTradeSnapshot
type HistoricalLoan ¶
type HistoricalLoan Loan
type HistoricalOffer ¶
type HistoricalOffer Offer
type HistoricalTradeSnapshot ¶
type HistoricalTradeSnapshot TradeSnapshot
type LoanStatus ¶
type LoanStatus string
const ( LoanStatusActive LoanStatus = "ACTIVE" LoanStatusExecuted LoanStatus = "EXECUTED" LoanStatusPartiallyFilled LoanStatus = "PARTIALLY FILLED" LoanStatusCanceled LoanStatus = "CANCELED" )
type MarginInfoBase ¶
type MarginInfoUpdate ¶
type Notification ¶
type OfferStatus ¶
type OfferStatus string
const ( OfferStatusActive OfferStatus = "ACTIVE" OfferStatusExecuted OfferStatus = "EXECUTED" OfferStatusPartiallyFilled OfferStatus = "PARTIALLY FILLED" OfferStatusCanceled OfferStatus = "CANCELED" )
type Order ¶
type Order struct { ID int64 GID int64 CID int64 Symbol string MTSCreated int64 MTSUpdated int64 Amount float64 AmountOrig float64 Type string TypePrev string Flags int64 Status OrderStatus Price float64 PriceAvg float64 PriceTrailing float64 PriceAuxLimit float64 Notify bool Hidden bool PlacedID int64 }
Order as returned from the bitfinex websocket service.
type OrderCancel ¶
type OrderCancel Order
OrderCancel gets sent out after an Order was cancelled successfully.
type OrderCancelRequest ¶
type OrderCancelRequest struct { ID *int64 `json:"id,omitempty"` CID *int64 `json:"cid,omitempty"` CIDDate *string `json:"cid_date,omitempty"` }
OrderCancelRequest represents an order cancel request. An order can be cancelled using the internal ID or a combination of Client ID (CID) and the daten for the given CID.
func (*OrderCancelRequest) MarshalJSON ¶
func (o *OrderCancelRequest) MarshalJSON() ([]byte, error)
MarshalJSON converts the order cancel object into the format required by the bitfinex websocket service.
type OrderNewRequest ¶
type OrderNewRequest struct { GID int64 `json:"gid"` CID int64 `json:"cid"` Type string `json:"type"` Symbol string `json:"symbol"` Amount float64 `json:"amount,string"` Price float64 `json:"price,string"` PriceTrailing float64 `json:"price_trailing,string,omitempty"` PriceAuxLimit float64 `json:"price_aux_limit,string,omitempty"` Hidden bool `json:"hidden,omitempty"` PostOnly bool `json:"postonly,omitempty"` }
OrderNewRequest represents an order to be posted to the bitfinex websocket service.
func (*OrderNewRequest) MarshalJSON ¶
func (o *OrderNewRequest) MarshalJSON() ([]byte, error)
MarshalJSON converts the order object into the format required by the bitfinex websocket service.
type OrderService ¶
type OrderService struct {
// contains filtered or unexported fields
}
OrderService manages the Order endpoint.
func (*OrderService) All ¶
func (s *OrderService) All(symbol string) (OrderSnapshot, error)
All returns all orders for the authenticated account.
func (*OrderService) History ¶
func (s *OrderService) History(symbol string) (OrderSnapshot, error)
All returns all orders for the authenticated account.
type OrderSnapshot ¶
type OrderSnapshot []Order
OrderSnapshot is a collection of Orders that would usually be sent on inital connection.
type OrderStatus ¶
type OrderStatus string
OrderStatus represents the possible statuses an order can be in.
const ( OrderStatusActive OrderStatus = "ACTIVE" OrderStatusExecuted OrderStatus = "EXECUTED" OrderStatusPartiallyFilled OrderStatus = "PARTIALLY FILLED" OrderStatusCanceled OrderStatus = "CANCELED" )
type OrderType ¶
type OrderType string
OrderType represents the types orders the bitfinex platform can handle.
type OrderUpdate ¶
type OrderUpdate Order
OrderUpdate is an Order that gets sent out after every change to an order.
type PlatformService ¶
type PlatformService struct {
// contains filtered or unexported fields
}
func (*PlatformService) Status ¶
func (p *PlatformService) Status() (bool, error)
Status indicates whether the platform is currently operative or not.
type PositionCancel ¶
type PositionCancel Position
type PositionNew ¶
type PositionNew Position
type PositionService ¶
type PositionService struct {
// contains filtered or unexported fields
}
PositionService manages the Position endpoint.
func (*PositionService) All ¶
func (s *PositionService) All() (PositionSnapshot, error)
All returns all positions for the authenticated account.
type PositionSnapshot ¶
type PositionSnapshot []Position
type PositionStatus ¶
type PositionStatus string
const ( PositionStatusActive PositionStatus = "ACTIVE" PositionStatusClosed PositionStatus = "CLOSED" )
type PositionUpdate ¶
type PositionUpdate Position
type PublicSubscriptionRequest ¶
type PublicSubscriptionRequest struct { Event string `json:"event"` Channel string `json:"channel"` Symbol string `json:"symbol"` Precision string `json:"prec,omitempty"` Frequency string `json:"freq,omitempty"` Key string `json:"key,omitempty"` Len string `json:"len,omitempty"` Pair string `json:"pair,omitempty"` SubID string `json:"subId,omitempty"` }
PublicSubscriptionRequest is used to subscribe to one of the public websocket channels. The `Event` field is automatically set to `subscribe` when using the Subscribe method. The `Channel` field is mandatory. For all other fields please consult the officical documentation here: http://docs.bitfinex.com/v2/reference#ws-public-ticker
type SubscribeEvent ¶
type SubscribeEvent struct { SubID string `json:"subId"` Channel string `json:"channel"` ChanID int64 `json:"chanId"` Symbol string `json:"symbol"` Precision string `json:"prec,omitempty"` Frequency string `json:"freq,omitempty"` Key string `json:"key,omitempty"` Len string `json:"len,omitempty"` Pair string `json:"pair"` }
type TickerSnapshot ¶
type TickerSnapshot []Ticker
type TickerUpdate ¶
type TickerUpdate Ticker
type TradeExecution ¶
type TradeService ¶
type TradeService struct {
// contains filtered or unexported fields
}
TradeService manages the Trade endpoint.
func (*TradeService) All ¶
func (s *TradeService) All(symbol string) (TradeSnapshot, error)
All returns all orders for the authenticated account.
type TradeSnapshot ¶
type TradeSnapshot []Trade
type TradeUpdate ¶
type TradeUpdate Trade
type UnsubscribeEvent ¶
type WalletSnapshot ¶
type WalletSnapshot []Wallet
type WalletUpdate ¶
type WalletUpdate Wallet