Documentation ¶
Index ¶
- Constants
- type AccountService
- type BalancesService
- type Client
- func (c *Client) Auth(key string, secret string) *Client
- func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)
- func (c *Client) NewAuthenticatedRequest(m string, refUrl string, data map[string]interface{}) (*http.Request, error)
- func (c *Client) NewRequest(method string, refUrl string) (*http.Request, error)
- func (c *Client) SignPayload(payload string) string
- type Credit
- type CreditsService
- type ErrorResponse
- type Lendbook
- type LendbookService
- type Lends
- type MarginInfo
- type MarginInfoService
- type MarginLimit
- type Order
- type OrderBook
- type OrderBookServive
- type OrderService
- type Pairs
- type PairsService
- type Response
- type SubscribeMsg
- type TermData
- type WalletBalance
- type WebSocketService
- func (w *WebSocketService) AddSubscribe(channel string, pair string, c chan []float64)
- func (w *WebSocketService) ClearSubscriptions()
- func (w *WebSocketService) Close()
- func (w *WebSocketService) Connect() error
- func (w *WebSocketService) ConnectPrivate(ch chan TermData)
- func (w *WebSocketService) Subscribe()
Constants ¶
const ( BaseURL = "https://api.bitfinex.com/v1/" WebSocketURL = "wss://api2.bitfinex.com:3000/ws" )
TODO: use var instead of const
const ( ORDER_TYPE_MARKET = "market" ORDER_TYPE_LIMIT = "limit" ORDER_TYPE_STOP = "stop" ORDER_TYPE_TRAILING_STOP = "trailing-stop" ORDER_TYPE_FILL_OR_KILL = "fill-or-kill" ORDER_TYPE_EXCHANGE_MARKET = "exchange market" ORDER_TYPE_EXCHANGE_LIMIT = "exchange limit" ORDER_TYPE_EXCHANGE_STOP = "exchange stop" ORDER_TYPE_EXCHANGE_TRAILING_STOP = "exchange trailing-stop" ORDER_TYPE_EXCHANGE_FILL_OR_KILL = "exchange fill-or-kill" )
const ( // Pairs BTCUSD = "BTCUSD" LTCUSD = "LTCUSD" LTCBTC = "LTCBTC" // Channels CHAN_BOOK = "book" CHAN_TRADE = "trade" CHAN_TICKER = "ticker" )
Pairs available
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
func (*AccountService) Info ¶
func (a *AccountService) Info() (string, error)
TODO return struct GET account_infos
type BalancesService ¶
type BalancesService struct {
// contains filtered or unexported fields
}
type Client ¶
type Client struct { // Base URL for API requests. BaseURL *url.URL // Auth data ApiKey string ApiSecret string // Services Pairs *PairsService Account *AccountService Balances *BalancesService Credits *CreditsService Lendbook *LendbookService MarginInfo *MarginInfoService OrderBook *OrderBookServive Orders *OrderService WebSocket *WebSocketService // contains filtered or unexported fields }
func (*Client) Auth ¶
Auth sets api key and secret for usage is requests that requires authentication
func (*Client) NewAuthenticatedRequest ¶
func (c *Client) NewAuthenticatedRequest(m string, refUrl string, data map[string]interface{}) (*http.Request, error)
NewAuthenticatedRequest creates new http request for authenticated routes
func (*Client) NewRequest ¶
NewRequest create new API request. Relative url can be provided in refUrl.
func (*Client) SignPayload ¶
type CreditsService ¶
type CreditsService struct {
// contains filtered or unexported fields
}
type ErrorResponse ¶
In case if API will wrong response code ErrorResponse will be returned to caller
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type LendbookService ¶
type LendbookService struct {
// contains filtered or unexported fields
}
type MarginInfo ¶
type MarginInfo struct { MarginBalance float64 `json:"margin_balance,string"` TradableBalance float64 `json:"tradable_balance,string"` UnrealizedPl float64 `json:"unrealized_pl,string"` UnrealizedSwap float64 `json:"unrealized_swap,string"` NetValue float64 `json:"net_value,string"` RequiredMargin float64 `json:"required_margin,string"` Leverage float64 `json:"leverage,string"` MarginRequirement float64 `json:"margin_requirement,string"` MarginLimits []MarginLimit `json:"margin_limits,string"` Message string `json:"message"` }
type MarginInfoService ¶
type MarginInfoService struct {
// contains filtered or unexported fields
}
func (*MarginInfoService) All ¶
func (s *MarginInfoService) All() ([]MarginInfo, error)
GET /margin_infos
type MarginLimit ¶
type Order ¶
type Order struct { Id int Symbol string Exchange string Price string AvgExecutionPrice string `json:"avg_execution_price"` Side string Type string Timestamp string IsLive bool `json:"is_live"` IsCanceled bool `json:"is_cancelled"` IsHidden bool `json:"is_hidden"` WasForced bool `json:"was_forced"` OriginalAmount string `json:"original_amount"` RemainingAmount string `json:"remaining_amount"` ExecutedAmount string `json:"executed_amount"` }
type OrderBookServive ¶
type OrderBookServive struct {
// contains filtered or unexported fields
}
type OrderService ¶
type OrderService struct {
// contains filtered or unexported fields
}
func (*OrderService) Create ¶
func (s *OrderService) Create(symbol string, amount float64, price float64, orderType string) (*Order, error)
POST order/new symbol # The name of the symbol (see `/symbols`). price # Price to buy or sell at. May omit if a market order. amount # Order size: how much to buy or sell. Use negative amount to create sell order. side # Either "buy" or "sell". type # Either "market" / "limit" / "stop" / "trailing-stop" / "fill-or-kill" /
"exchange market" / "exchange limit" / "exchange stop" / "exchange trailing-stop" / "exchange fill-or-kill"
type PairsService ¶
type PairsService struct {
// contains filtered or unexported fields
}
type SubscribeMsg ¶
type TermData ¶
type TermData struct { // Data term. E.g: ps, ws, ou, etc... See official documentation for more details. Term string // Data will contain different number of elements for each term. // Examples: // Term: ws, Data: ["exchange","BTC",0.01410829,0] // Term: oc, Data: [0,"BTCUSD",0,-0.01,"","CANCELED",270,0,"2015-10-15T11:26:13Z",0] Data []interface{} Error string }
type WalletBalance ¶
type WebSocketService ¶
type WebSocketService struct {
// contains filtered or unexported fields
}
WebSocketService allow to connect and receive stream data from bitfinex.com ws service.
func NewWebSocketService ¶
func NewWebSocketService(c *Client) *WebSocketService
func (*WebSocketService) AddSubscribe ¶
func (w *WebSocketService) AddSubscribe(channel string, pair string, c chan []float64)
func (*WebSocketService) ClearSubscriptions ¶
func (w *WebSocketService) ClearSubscriptions()
func (*WebSocketService) Connect ¶
func (w *WebSocketService) Connect() error
Connect create new bitfinex websocket connection
func (*WebSocketService) ConnectPrivate ¶
func (w *WebSocketService) ConnectPrivate(ch chan TermData)
func (*WebSocketService) Subscribe ¶
func (w *WebSocketService) Subscribe()
Watch allows to subsribe to channels and watch for new updates. This method supports next channels: book, trade, ticker.