bitfinex

package
v0.0.0-...-77ca9cc Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BITFINEX_API_URL              = "https://api.bitfinex.com/v1/"
	BITFINEX_API_VERSION          = "1"
	BITFINEX_TICKER               = "pubticker/"
	BITFINEX_STATS                = "stats/"
	BITFINEX_LENDBOOK             = "lendbook/"
	BITFINEX_ORDERBOOK            = "book/"
	BITFINEX_TRADES               = "trades/"
	BITFINEX_LENDS                = "lends/"
	BITFINEX_SYMBOLS              = "symbols/"
	BITFINEX_SYMBOLS_DETAILS      = "symbols_details/"
	BITFINEX_ACCOUNT_INFO         = "account_infos"
	BITFINEX_DEPOSIT              = "deposit/new"
	BITFINEX_ORDER_NEW            = "order/new"
	BITFINEX_ORDER_NEW_MULTI      = "order/new/multi"
	BITFINEX_ORDER_CANCEL         = "order/cancel"
	BITFINEX_ORDER_CANCEL_MULTI   = "order/cancel/multi"
	BITFINEX_ORDER_CANCEL_ALL     = "order/cancel/all"
	BITFINEX_ORDER_CANCEL_REPLACE = "order/cancel/replace"
	BITFINEX_ORDER_STATUS         = "order/status"
	BITFINEX_ORDERS               = "orders"
	BITFINEX_POSITIONS            = "positions"
	BITFINEX_CLAIM_POSITION       = "position/claim"
	BITFINEX_HISTORY              = "history"
	BITFINEX_HISTORY_MOVEMENTS    = "history/movements"
	BITFINEX_TRADE_HISTORY        = "mytrades"
	BITFINEX_OFFER_NEW            = "offer/new"
	BITFINEX_OFFER_CANCEL         = "offer/cancel"
	BITFINEX_OFFER_STATUS         = "offer/status"
	BITFINEX_OFFERS               = "offers"
	BITFINEX_MARGIN_ACTIVE_FUNDS  = "taken_funds"
	BITFINEX_MARGIN_TOTAL_FUNDS   = "total_taken_funds"
	BITFINEX_MARGIN_CLOSE         = "funding/close"
	BITFINEX_BALANCES             = "balances"
	BITFINEX_MARGIN_INFO          = "margin_infos"
	BITFINEX_TRANSFER             = "transfer"
	BITFINEX_WITHDRAWAL           = "withdrawal"
)
View Source
const (
	BITFINEX_WEBSOCKET                     = "wss://api.bitfinex.com/ws"
	BITFINEX_WEBSOCKET_VERSION             = "1.1"
	BITFINEX_WEBSOCKET_POSITION_SNAPSHOT   = "ps"
	BITFINEX_WEBSOCKET_POSITION_NEW        = "pn"
	BITFINEX_WEBSOCKET_POSITION_UPDATE     = "pu"
	BITFINEX_WEBSOCKET_POSITION_CLOSE      = "pc"
	BITFINEX_WEBSOCKET_WALLET_SNAPSHOT     = "ws"
	BITFINEX_WEBSOCKET_WALLET_UPDATE       = "wu"
	BITFINEX_WEBSOCKET_ORDER_SNAPSHOT      = "os"
	BITFINEX_WEBSOCKET_ORDER_NEW           = "on"
	BITFINEX_WEBSOCKET_ORDER_UPDATE        = "ou"
	BITFINEX_WEBSOCKET_ORDER_CANCEL        = "oc"
	BITFINEX_WEBSOCKET_TRADE_EXECUTED      = "te"
	BITFINEX_WEBSOCKET_HEARTBEAT           = "hb"
	BITFINEX_WEBSOCKET_ALERT_RESTARTING    = "20051"
	BITFINEX_WEBSOCKET_ALERT_REFRESHING    = "20060"
	BITFINEX_WEBSOCKET_ALERT_RESUME        = "20061"
	BITFINEX_WEBSOCKET_UNKNOWN_EVENT       = "10000"
	BITFINEX_WEBSOCKET_UNKNOWN_PAIR        = "10001"
	BITFINEX_WEBSOCKET_SUBSCRIPTION_FAILED = "10300"
	BITFINEX_WEBSOCKET_ALREADY_SUBSCRIBED  = "10301"
	BITFINEX_WEBSOCKET_UNKNOWN_CHANNEL     = "10302"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitfinex

type Bitfinex struct {
	exchange.ExchangeBase
	WebsocketConn         *websocket.Conn
	WebsocketSubdChannels map[int]BitfinexWebsocketChanInfo
}

func (*Bitfinex) CancelAllOrders

func (b *Bitfinex) CancelAllOrders() (string, error)

func (*Bitfinex) CancelMultipleOrders

func (b *Bitfinex) CancelMultipleOrders(OrderIDs []int64) (string, error)

func (*Bitfinex) CancelOffer

func (b *Bitfinex) CancelOffer(OfferID int64) (BitfinexOffer, error)

func (*Bitfinex) CancelOrder

func (b *Bitfinex) CancelOrder(OrderID int64) (BitfinexOrder, error)

func (*Bitfinex) ClaimPosition

func (b *Bitfinex) ClaimPosition(PositionID int) (BitfinexPosition, error)

func (*Bitfinex) CloseMarginFunding

func (b *Bitfinex) CloseMarginFunding(SwapID int64) (BitfinexOffer, error)

func (*Bitfinex) GetAccountBalance

func (b *Bitfinex) GetAccountBalance() ([]BitfinexBalance, error)

func (*Bitfinex) GetAccountInfo

func (b *Bitfinex) GetAccountInfo() ([]BitfinexAccountInfo, error)

func (*Bitfinex) GetActiveMarginFunding

func (b *Bitfinex) GetActiveMarginFunding() ([]BitfinexMarginFunds, error)

func (*Bitfinex) GetActiveOffers

func (b *Bitfinex) GetActiveOffers() ([]BitfinexOffer, error)

func (*Bitfinex) GetActiveOrders

func (b *Bitfinex) GetActiveOrders() ([]BitfinexOrder, error)

func (*Bitfinex) GetActivePositions

func (b *Bitfinex) GetActivePositions() ([]BitfinexPosition, error)

func (*Bitfinex) GetBalanceHistory

func (b *Bitfinex) GetBalanceHistory(symbol string, timeSince time.Time, timeUntil time.Time, limit int, wallet string) ([]BitfinexBalanceHistory, error)

func (*Bitfinex) GetExchangeAccountInfo

func (e *Bitfinex) GetExchangeAccountInfo() (exchange.ExchangeAccountInfo, error)

GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the Bitfinex exchange

func (*Bitfinex) GetLendbook

func (b *Bitfinex) GetLendbook(symbol string, values url.Values) (BitfinexLendbook, error)

func (*Bitfinex) GetLends

func (b *Bitfinex) GetLends(symbol string, values url.Values) ([]BitfinexLends, error)

func (*Bitfinex) GetMarginInfo

func (b *Bitfinex) GetMarginInfo() ([]BitfinexMarginInfo, error)

func (*Bitfinex) GetMarginTotalTakenFunds

func (b *Bitfinex) GetMarginTotalTakenFunds() ([]BitfinexMarginTotalTakenFunds, error)

func (*Bitfinex) GetMovementHistory

func (b *Bitfinex) GetMovementHistory(symbol, method string, timeSince, timeUntil time.Time, limit int) ([]BitfinexMovementHistory, error)

func (*Bitfinex) GetOfferStatus

func (b *Bitfinex) GetOfferStatus(OfferID int64) (BitfinexOffer, error)

func (*Bitfinex) GetOrderStatus

func (b *Bitfinex) GetOrderStatus(OrderID int64) (BitfinexOrder, error)

func (*Bitfinex) GetOrderbook

func (b *Bitfinex) GetOrderbook(symbol string, values url.Values) (BitfinexOrderbook, error)

func (*Bitfinex) GetOrderbookEx

func (b *Bitfinex) GetOrderbookEx(p pair.CurrencyPair) (orderbook.OrderbookBase, error)

func (*Bitfinex) GetStats

func (b *Bitfinex) GetStats(symbol string) ([]BitfinexStats, error)

func (*Bitfinex) GetSymbols

func (b *Bitfinex) GetSymbols() ([]string, error)

func (*Bitfinex) GetSymbolsDetails

func (b *Bitfinex) GetSymbolsDetails() ([]BitfinexSymbolDetails, error)

func (*Bitfinex) GetTicker

func (b *Bitfinex) GetTicker(symbol string, values url.Values) (BitfinexTicker, error)

func (*Bitfinex) GetTickerPrice

func (b *Bitfinex) GetTickerPrice(p pair.CurrencyPair) (ticker.TickerPrice, error)

func (*Bitfinex) GetTradeHistory

func (b *Bitfinex) GetTradeHistory(symbol string, timestamp, until time.Time, limit, reverse int) ([]BitfinexTradeHistory, error)

func (*Bitfinex) GetTrades

func (b *Bitfinex) GetTrades(symbol string, values url.Values) ([]BitfinexTradeStructure, error)

func (*Bitfinex) NewDeposit

func (b *Bitfinex) NewDeposit(method, walletName string, renew int) (BitfinexDepositResponse, error)

func (*Bitfinex) NewOffer

func (b *Bitfinex) NewOffer(symbol string, amount, rate float64, period int64, direction string) int64

func (*Bitfinex) NewOrder

func (b *Bitfinex) NewOrder(Symbol string, Amount float64, Price float64, Buy bool, Type string, Hidden bool) (BitfinexOrder, error)

func (*Bitfinex) NewOrderMulti

func (b *Bitfinex) NewOrderMulti(orders []BitfinexPlaceOrder) (BitfinexOrderMultiResponse, error)

func (*Bitfinex) ReplaceOrder

func (b *Bitfinex) ReplaceOrder(OrderID int64, Symbol string, Amount float64, Price float64, Buy bool, Type string, Hidden bool) (BitfinexOrder, error)

func (*Bitfinex) Run

func (b *Bitfinex) Run()

func (*Bitfinex) SendAuthenticatedHTTPRequest

func (b *Bitfinex) SendAuthenticatedHTTPRequest(method, path string, params map[string]interface{}, result interface{}) error

func (*Bitfinex) SetDefaults

func (b *Bitfinex) SetDefaults()

func (*Bitfinex) Setup

func (b *Bitfinex) Setup(exch config.ExchangeConfig)

func (*Bitfinex) Start

func (b *Bitfinex) Start()

func (*Bitfinex) WalletTransfer

func (b *Bitfinex) WalletTransfer(amount float64, currency, walletFrom, walletTo string) ([]BitfinexWalletTransfer, error)

func (*Bitfinex) WebsocketAddSubscriptionChannel

func (b *Bitfinex) WebsocketAddSubscriptionChannel(chanID int, channel, pair string)

func (*Bitfinex) WebsocketClient

func (b *Bitfinex) WebsocketClient()

func (*Bitfinex) WebsocketPingHandler

func (b *Bitfinex) WebsocketPingHandler() error

func (*Bitfinex) WebsocketSend

func (b *Bitfinex) WebsocketSend(data interface{}) error

func (*Bitfinex) WebsocketSendAuth

func (b *Bitfinex) WebsocketSendAuth() error

func (*Bitfinex) WebsocketSendUnauth

func (b *Bitfinex) WebsocketSendUnauth() error

func (*Bitfinex) WebsocketSubscribe

func (b *Bitfinex) WebsocketSubscribe(channel string, params map[string]string) error

func (*Bitfinex) Withdrawal

func (b *Bitfinex) Withdrawal(withdrawType, wallet, address string, amount float64) ([]BitfinexWithdrawal, error)

type BitfinexAccountInfo

type BitfinexAccountInfo struct {
	MakerFees string `json:"maker_fees"`
	TakerFees string `json:"taker_fees"`
	Fees      []struct {
		Pairs     string `json:"pairs"`
		MakerFees string `json:"maker_fees"`
		TakerFees string `json:"taker_fees"`
	} `json:"fees"`
}

type BitfinexBalance

type BitfinexBalance struct {
	Type      string
	Currency  string
	Amount    float64 `json:"amount,string"`
	Available float64 `json:"available,string"`
}

type BitfinexBalanceHistory

type BitfinexBalanceHistory struct {
	Currency    string  `json:"currency"`
	Amount      float64 `json:"amount,string"`
	Balance     float64 `json:"balance,string"`
	Description string  `json:"description"`
	Timestamp   string  `json:"timestamp"`
}

type BitfinexBookStructure

type BitfinexBookStructure struct {
	Price, Amount, Timestamp string
}

type BitfinexDepositResponse

type BitfinexDepositResponse struct {
	Result   string `json:"string"`
	Method   string `json:"method"`
	Currency string `json:"currency"`
	Address  string `json:"address"`
}

type BitfinexFee

type BitfinexFee struct {
	Currency  string
	TakerFees float64
	MakerFees float64
}

type BitfinexGenericResponse

type BitfinexGenericResponse struct {
	Result string `json:"result"`
}

type BitfinexLendbook

type BitfinexLendbook struct {
	Bids []BitfinexLendbookBidAsk `json:"bids"`
	Asks []BitfinexLendbookBidAsk `json:"asks"`
}

type BitfinexLendbookBidAsk

type BitfinexLendbookBidAsk struct {
	Rate            float64 `json:"rate,string"`
	Amount          float64 `json:"amount,string"`
	Period          int     `json:"period"`
	Timestamp       string  `json:"timestamp"`
	FlashReturnRate string  `json:"frr"`
}

type BitfinexLends

type BitfinexLends struct {
	Rate       float64 `json:"rate,string"`
	AmountLent float64 `json:"amount_lent,string"`
	AmountUsed float64 `json:"amount_used,string"`
	Timestamp  int64   `json:"timestamp"`
}

type BitfinexMarginFunds

type BitfinexMarginFunds struct {
	ID         int64   `json:"id"`
	PositionID int64   `json:"position_id"`
	Currency   string  `json:"currency"`
	Rate       float64 `json:"rate,string"`
	Period     int     `json:"period"`
	Amount     float64 `json:"amount,string"`
	Timestamp  string  `json:"timestamp"`
}

type BitfinexMarginInfo

type BitfinexMarginInfo struct {
	MarginBalance     float64                `json:"margin_balance,string"`
	TradableBalance   float64                `json:"tradable_balance,string"`
	UnrealizedPL      int64                  `json:"unrealized_pl"`
	UnrealizedSwap    int64                  `json:"unrealized_swap"`
	NetValue          float64                `json:"net_value,string"`
	RequiredMargin    int64                  `json:"required_margin"`
	Leverage          float64                `json:"leverage,string"`
	MarginRequirement float64                `json:"margin_requirement,string"`
	MarginLimits      []BitfinexMarginLimits `json:"margin_limits"`
	Message           string
}

type BitfinexMarginLimits

type BitfinexMarginLimits struct {
	On_Pair           string
	InitialMargin     float64 `json:"initial_margin,string"`
	MarginRequirement float64 `json:"margin_requirement,string"`
	TradableBalance   float64 `json:"tradable_balance,string"`
}

type BitfinexMarginTotalTakenFunds

type BitfinexMarginTotalTakenFunds struct {
	PositionPair string  `json:"position_pair"`
	TotalSwaps   float64 `json:"total_swaps,string"`
}

type BitfinexMovementHistory

type BitfinexMovementHistory struct {
	ID          int64   `json:"id"`
	Currency    string  `json:"currency"`
	Method      string  `json:"method"`
	Type        string  `json:"withdrawal"`
	Amount      float64 `json:"amount,string"`
	Description string  `json:"description"`
	Status      string  `json:"status"`
	Timestamp   string  `json:"timestamp"`
}

type BitfinexOffer

type BitfinexOffer struct {
	ID              int64
	Currency        string
	Rate            float64 `json:"rate,string"`
	Period          int64
	Direction       string
	Timestamp       string
	Type            string
	IsLive          bool    `json:"is_live"`
	IsCancelled     bool    `json:"is_cancelled"`
	OriginalAmount  float64 `json:"original_amount,string"`
	RemainingAmount float64 `json:"remaining_amount,string"`
	ExecutedAmount  float64 `json:"executed_amount,string"`
}

type BitfinexOrder

type BitfinexOrder struct {
	ID                    int64
	Symbol                string
	Exchange              string
	Price                 float64 `json:"price,string"`
	AverageExecutionPrice float64 `json:"avg_execution_price,string"`
	Side                  string
	Type                  string
	Timestamp             string
	IsLive                bool    `json:"is_live"`
	IsCancelled           bool    `json:"is_cancelled"`
	IsHidden              bool    `json:"is_hidden"`
	WasForced             bool    `json:"was_forced"`
	OriginalAmount        float64 `json:"original_amount,string"`
	RemainingAmount       float64 `json:"remaining_amount,string"`
	ExecutedAmount        float64 `json:"executed_amount,string"`
	OrderID               int64   `json:"order_id"`
}

type BitfinexOrderMultiResponse

type BitfinexOrderMultiResponse struct {
	Orders []BitfinexOrder `json:"order_ids"`
	Status string          `json:"status"`
}

type BitfinexOrderbook

type BitfinexOrderbook struct {
	Bids []BitfinexBookStructure
	Asks []BitfinexBookStructure
}

type BitfinexPlaceOrder

type BitfinexPlaceOrder struct {
	Symbol   string  `json:"symbol"`
	Amount   float64 `json:"amount,string"`
	Price    float64 `json:"price,string"`
	Exchange string  `json:"exchange"`
	Side     string  `json:"side"`
	Type     string  `json:"type"`
}

type BitfinexPosition

type BitfinexPosition struct {
	ID        int64   `json:"id"`
	Symbol    string  `json:"string"`
	Status    string  `json:"active"`
	Base      float64 `json:"base,string"`
	Amount    float64 `json:"amount,string"`
	Timestamp string  `json:"timestamp"`
	Swap      float64 `json:"swap,string"`
	PL        float64 `json:"pl,string"`
}

type BitfinexStats

type BitfinexStats struct {
	Period int64
	Volume float64 `json:",string"`
}

type BitfinexSymbolDetails

type BitfinexSymbolDetails struct {
	Pair             string  `json:"pair"`
	PricePrecision   int     `json:"price_precision"`
	InitialMargin    float64 `json:"initial_margin,string"`
	MinimumMargin    float64 `json:"minimum_margin,string"`
	MaximumOrderSize float64 `json:"maximum_order_size,string"`
	MinimumOrderSize float64 `json:"minimum_order_size,string"`
	Expiration       string  `json:"expiration"`
}

type BitfinexTicker

type BitfinexTicker struct {
	Mid       float64 `json:",string"`
	Bid       float64 `json:",string"`
	Ask       float64 `json:",string"`
	Last      float64 `json:"Last_price,string"`
	Low       float64 `json:",string"`
	High      float64 `json:",string"`
	Volume    float64 `json:",string"`
	Timestamp string
}

type BitfinexTradeHistory

type BitfinexTradeHistory struct {
	Price       float64 `json:"price,string"`
	Amount      float64 `json:"amount,string"`
	Timestamp   string  `json:"timestamp"`
	Exchange    string  `json:"exchange"`
	Type        string  `json:"type"`
	FeeCurrency string  `json:"fee_currency"`
	FeeAmount   float64 `json:"fee_amount,string"`
	TID         int64   `json:"tid"`
	OrderID     int64   `json:"order_id"`
}

type BitfinexTradeStructure

type BitfinexTradeStructure struct {
	Timestamp, Tid                int64
	Price, Amount, Exchange, Type string
}

type BitfinexWalletTransfer

type BitfinexWalletTransfer struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

type BitfinexWebsocketBook

type BitfinexWebsocketBook struct {
	Price  float64
	Count  int
	Amount float64
}

type BitfinexWebsocketChanInfo

type BitfinexWebsocketChanInfo struct {
	Channel string
	Pair    string
}

type BitfinexWebsocketOrder

type BitfinexWebsocketOrder struct {
	OrderID    int64
	Pair       string
	Amount     float64
	OrigAmount float64
	OrderType  string
	Status     string
	Price      float64
	PriceAvg   float64
	Timestamp  string
	Notify     int
}

type BitfinexWebsocketPosition

type BitfinexWebsocketPosition struct {
	Pair              string
	Status            string
	Amount            float64
	Price             float64
	MarginFunding     float64
	MarginFundingType int
}

type BitfinexWebsocketTicker

type BitfinexWebsocketTicker struct {
	Bid             float64
	BidSize         float64
	Ask             float64
	AskSize         float64
	DailyChange     float64
	DialyChangePerc float64
	LastPrice       float64
	Volume          float64
}

type BitfinexWebsocketTrade

type BitfinexWebsocketTrade struct {
	ID        int64
	Timestamp int64
	Price     float64
	Amount    float64
}

type BitfinexWebsocketTradeExecuted

type BitfinexWebsocketTradeExecuted struct {
	TradeID        int64
	Pair           string
	Timestamp      int64
	OrderID        int64
	AmountExecuted float64
	PriceExecuted  float64
}

type BitfinexWebsocketWallet

type BitfinexWebsocketWallet struct {
	Name              string
	Currency          string
	Balance           float64
	UnsettledInterest float64
}

type BitfinexWithdrawal

type BitfinexWithdrawal struct {
	Status       string `json:"status"`
	Message      string `json:"message"`
	WithdrawalID int64  `json:"withdrawal_id"`
}

Jump to

Keyboard shortcuts

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