bitfinex

package module
v0.0.0-...-7eb19ea Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2015 License: MIT Imports: 11 Imported by: 0

README

Testing Private API

To fully test the private API suite requires credentials, which can be passed as 'BITFINEX_API_KEY' and 'BITFINEX_API_SECRET' environment variables. For example:

$ BITFINEX_API_KEY=<API key> BITFINEX_API_SECRET=<key secret> go test -v

Please run tests in verbose mode and inspect the output.

Like the project? Show support.

฿ 1ASutaskUbCNiRxKcjwxA6PaymCZuqgLbL

1ASutaskUbCNiRxKcjwxA6PaymCZuqgLbl

Documentation

Index

Constants

View Source
const (
	// APIURL points to Bitfinex API URL, found at https://www.bitfinex.com/pages/API
	APIURL = "https://api.bitfinex.com/"
	// LEND ...
	LEND = "lend"
	// BORROW ...
	BORROW = "borrow"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	APIKey    string
	APISecret string
}

API structure stores Bitfinex API credentials

func New

func New(key, secret string) (api *API)

New returns a new Bitfinex API instance

func (*API) ActiveCredits

func (api *API) ActiveCredits() (credits Credits, err error)

ActiveCredits return a list of currently lent funds (active credits).

func (*API) ActiveOffers

func (api *API) ActiveOffers() (offers Offers, err error)

ActiveOffers return an array of all your live offers (lending or borrowing).

func (*API) ActiveOrders

func (api *API) ActiveOrders() (orders Orders, err error)

ActiveOrders returns an array of your active orders.

func (*API) CancelActiveOffers

func (api *API) CancelActiveOffers() (err error)

CancelActiveOffers ...

func (*API) CancelActiveOffersByCurrency

func (api *API) CancelActiveOffersByCurrency(currency string) (err error)

CancelActiveOffersByCurrency ...

func (*API) CancelOffer

func (api *API) CancelOffer(id int) (err error)

CancelOffer cancel an offer give its id.

func (*API) CancelOrder

func (api *API) CancelOrder(id int) (err error)

CancelOrder cancel an offer give its id.

func (*API) Lendbook

func (api *API) Lendbook(currency string, limitBids, limitAsks int) (lendbook Lendbook, err error)

Lendbook returns the full lend book.

func (*API) MyTrades

func (api *API) MyTrades(symbol string, timestamp string, limitTrades int) (mytrades MyTrades, err error)

MyTrades returns an array of your past trades for the given symbol.

func (*API) NewOffer

func (api *API) NewOffer(currency string, amount, rate float64, period int, direction string) (offer Offer, err error)

NewOffer submits a new offer. currency (string): The name of the currency. amount (decimal): Offer size: how much to lend or borrow. rate (decimal): Rate to lend or borrow at. In percentage per 365 days. period (integer): Number of days of the loan (in days) direction (string): Either "lend" or "loan".

func (*API) OrderStatus

func (api *API) OrderStatus(id int) (order OrderStatus, err error)

OrderStatus returns the status of an order given its id.

func (*API) Orderbook

func (api *API) Orderbook(symbol string, limitBids, limitAsks, group int) (orderbook Orderbook, err error)

Orderbook returns the full order book.

func (*API) Stats

func (api *API) Stats(symbol string) (stats Stats, err error)

Stats return various statistics about the requested pairs.

func (*API) Ticker

func (api *API) Ticker(symbol string) (ticker Ticker, err error)

Ticker returns innermost bid and asks and information on the most recent trade,

as well as high, low and volume of the last 24 hours.

func (*API) Trades

func (api *API) Trades(symbol string, timestamp string, limitTrades int) (trades Trades, err error)

Trades returns a list of the most recent trades for the given symbol. ... Request ...

timestamp (time): Optional. Only show trades at or after this timestamp.
limit_trades (int): Optional. Limit the number of trades returned. Must be >= 1. Default is 50.

func (*API) WalletBalances

func (api *API) WalletBalances() (wallet WalletBalances, err error)

WalletBalances return your balances.

type Credit

type Credit struct {
	ID        int     `json:"id"`
	Currency  string  `json:"currency"`         // The currency name of the offer.
	Rate      float64 `json:"rate,string"`      // The rate the offer was issued at (in % per 365 days).
	Period    int     `json:"period"`           // The number of days of the offer.
	Amount    float64 `json:"amount,string"`    // How much is the credit for
	Status    string  `json:"status"`           // "Active"
	Timestamp float64 `json:"timestamp,string"` // The timestamp the offer was submitted.

}

Credit ...

type Credits

type Credits []Credit

Credits ...

type ErrorMessage

type ErrorMessage struct {
	Message string `json:"message"` // Returned only on error
}

ErrorMessage ...

type Lendbook

type Lendbook struct {
	Bids []LendbookOffer // bids (array of loan demands)
	Asks []LendbookOffer // asks (array of loan offers)
}

Lendbook ...

type LendbookOffer

type LendbookOffer struct {
	Rate      float64 `json:"rate,string"`      // rate (rate in % per 365 days)
	Amount    float64 `json:"amount,string"`    // amount (decimal)
	Period    int     `json:"period"`           // period (days): minimum period for the loan
	Timestamp float64 `json:"timestamp,string"` // timestamp (time)
	FRRString string  `json:"frr"`              // frr (yes/no): "Yes" if the offer is at Flash Return Rate, "No" if the offer is at fixed rate
	FRR       bool
}

LendbookOffer ...

type MyTrade

type MyTrade struct {
	Price       float64 `json:"price,string"`      // price
	Amount      float64 `json:"amount,string"`     // amount (decimal)
	Timestamp   float64 `json:"timestamp,string"`  // time
	Until       float64 `json:"until,string"`      // until (time): return only trades before or a the time specified here
	Exchange    string  `json:"exchange"`          // exchange
	Type        string  `json:"type"`              // type - "Sell" or "Buy"
	FeeCurrency string  `json:"fee_currency"`      // fee_currency (string) Currency you paid this trade's fee in
	FeeAmount   float64 `json:"fee_amount,string"` // fee_amount (decimal) Amount of fees you paid for this trade
	TID         int     `json:"tid"`               // tid (integer): unique identification number of the trade
	OrderId     int     `json:"order_id"`          // order_id (integer) unique identification number of the parent order of the trade
}

MyTrade ... (NEW)

type MyTrades

type MyTrades []MyTrade

MyTrades ... (NEW)

type Offer

type Offer struct {
	ID              int     `json:"id"`
	Currency        string  `json:"currency"`                // The currency name of the offer.
	Rate            float64 `json:"rate,string"`             // The rate the offer was issued at (in % per 365 days).
	Period          int     `json:"period"`                  // The number of days of the offer.
	Direction       string  `json:"direction"`               // Either "lend" or "loan".Either "lend" or "loan".
	Type            string  `json:"type"`                    // Either "market" / "limit" / "stop" / "trailing-stop".
	Timestamp       float64 `json:"timestamp,string"`        // The timestamp the offer was submitted.
	Live            bool    `json:"is_live,bool"`            // Could the offer still be filled?
	Cacelled        bool    `json:"is_cancelled,bool"`       // Has the offer been cancelled?
	ExecutedAmount  float64 `json:"executed_amount,string"`  // How much of the offer has been executed so far in its history?
	RemainingAmount float64 `json:"remaining_amount,string"` // How much is still remaining to be submitted?
	OriginalAmount  float64 `json:"original_amount,string"`  // What was the offer originally submitted for?
}

Offer ...

type Offers

type Offers []Offer

Offers ...

type OrderStatus

type OrderStatus struct {
	ID                int     `json:"id"`                         // id (int): The order ID
	Symbol            string  `json:"symbol, string"`             // symbol (string): The symbol name the order belongs to.
	Exchange          string  `json:"exchange, string"`           //exchange (string): "bitfinex", "bitstamp".
	Price             float64 `json:"price,string"`               // price (decimal): The price the order was issued at (can be null for market orders).
	AvgExecutionPrice float64 `json:"avg_execution_price,string"` // avg_execution_price (decimal): The average price at which this order as been executed so far. 0 if the order has not been executed at all.
	Side              string  `json:"side, string"`               // side (string): Either "buy" or "sell".
	Type              string  `json:"type, string"`               // type (string): Either "market" / "limit" / "stop" / "trailing-stop".
	Timestamp         float64 `json:"timestamp,string"`           // timestamp (time): The timestamp the order was submitted.
	Live              bool    `json:"is_live,bool"`               // is_live (bool): Could the order still be filled?
	Cacelled          bool    `json:"is_cancelled,bool"`          // is_cancelled (bool): Has the order been cancelled?
	Forced            bool    `json:"was_forced,bool"`            // was_forced (bool): For margin only: true if it was forced by the system.
	ExecutedAmount    float64 `json:"executed_amount,string"`     // executed_amount (decimal): How much of the order has been executed so far in its history?
	RemainingAmount   float64 `json:"remaining_amount,string"`    // remaining_amount (decimal): How much is still remaining to be submitted?
	OriginalAmount    float64 `json:"original_amount,string"`     // original_amount (decimal): What was the order originally submitted for?
}

OrderStatus ... (NEW)

type Orderbook

type Orderbook struct {
	Bids []OrderbookOffer // bids (array of bid offers)
	Asks []OrderbookOffer // asks (array of ask offers)
}

Orderbook ... Public (NEW)

type OrderbookOffer

type OrderbookOffer struct {
	Price     float64 `json:"price,string"`     // price
	Amount    float64 `json:"amount,string"`    // amount (decimal)
	Timestamp float64 `json:"timestamp,string"` // time
}

OrderbookOffer ... (NEW)

type Orders

type Orders []OrderStatus

Orders ... (NEW)

type Stat

type Stat struct {
	Period int     `json:"period"`        // period (integer), period covered in days
	Volume float64 `json:"volume,string"` // volume (price)
}

Stat ...

type Stats

type Stats []Stat

Stats ...

type Ticker

type Ticker struct {
	Mid       float64 `json:"mid,string"`        // mid (price): (bid + ask) / 2
	Bid       float64 `json:"bid,string"`        // bid (price): Innermost bid.
	Ask       float64 `json:"ask,string"`        // ask (price): Innermost ask.
	LastPrice float64 `json:"last_price,string"` // last_price (price) The price at which the last order executed.
	Low       float64 `json:"low,string"`        // low (price): Lowest trade price of the last 24 hours
	High      float64 `json:"high,string"`       // high (price): Highest trade price of the last 24 hours
	Volume    float64 `json:"volume,string"`     // volume (price): Trading volume of the last 24 hours
	Timestamp float64 `json:"timestamp,string"`  // timestamp (time) The timestamp at which this information was valid.
}

Ticker ...

type Trade

type Trade struct {
	TID       int     `json:"tid"`           // tid (integer)
	Timestamp int64   `json:"timestamp"`     // timestamp (time)
	Price     float64 `json:"price,string"`  // price (price)
	Amount    float64 `json:"amount,string"` // amount (decimal)
	Exchange  string  `json:"exchange"`      // exchange (string)
	Type      string  `json:"type"`          // type (string) "sell" or "buy" (can be "" if undetermined)
}

Trade ... (NEW)

type Trades

type Trades []Trade

Trades ... (NEW)

type WalletBalance

type WalletBalance struct {
	Type      string  `json:"type"`             // "trading", "deposit" or "exchange".
	Currency  string  `json:"currency"`         // Currency
	Amount    float64 `json:"amount,string"`    // How much balance of this currency in this wallet
	Available float64 `json:"available,string"` // How much X there is in this wallet that is available to trade.
}

WalletBalance ...

type WalletBalances

type WalletBalances map[WalletKey]WalletBalance

WalletBalances ...

type WalletKey

type WalletKey struct {
	Type, Currency string
}

WalletKey ...

Jump to

Keyboard shortcuts

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