From 9e1ddf046823bccf2e05815381615c8019c03b1f Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Wed, 1 Nov 2017 16:10:21 +1100 Subject: [PATCH] Update Bitfinex API Ref: https://github.com/thrasher-/gocryptotrader/issues/59 --- exchanges/bitfinex/bitfinex.go | 9 +++++++-- exchanges/bitfinex/bitfinex_wrapper.go | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/exchanges/bitfinex/bitfinex.go b/exchanges/bitfinex/bitfinex.go index 6be03af7..7ecc324c 100644 --- a/exchanges/bitfinex/bitfinex.go +++ b/exchanges/bitfinex/bitfinex.go @@ -140,9 +140,11 @@ func (b *Bitfinex) GetFundingBook(symbol string) (FundingBook, error) { return response, common.SendHTTPGetRequest(path, true, b.Verbose, &response) } -// GetOrderbook retieves the entire orderbook bid and ask price on a currency -// pair +// GetOrderbook retieves the orderbook bid and ask price points for a currency +// pair - By default the response will return 25 bid and 25 ask price points. // CurrencyPair - Example "BTCUSD" +// Values can contain limit amounts for both the asks and bids - Example +// "limit_bids" = 1000 func (b *Bitfinex) GetOrderbook(currencyPair string, values url.Values) (Orderbook, error) { response := Orderbook{} path := common.EncodeURLValues( @@ -153,7 +155,10 @@ func (b *Bitfinex) GetOrderbook(currencyPair string, values url.Values) (Orderbo } // GetTrades returns a list of the most recent trades for the given curencyPair +// By default the response will return 100 trades // CurrencyPair - Example "BTCUSD" +// Values can contain limit amounts for the number of trades returned - Example +// "limit_trades" = 1000 func (b *Bitfinex) GetTrades(currencyPair string, values url.Values) ([]TradeStructure, error) { response := []TradeStructure{} path := common.EncodeURLValues( diff --git a/exchanges/bitfinex/bitfinex_wrapper.go b/exchanges/bitfinex/bitfinex_wrapper.go index a2033f31..8108e0b5 100644 --- a/exchanges/bitfinex/bitfinex_wrapper.go +++ b/exchanges/bitfinex/bitfinex_wrapper.go @@ -2,6 +2,7 @@ package bitfinex import ( "log" + "net/url" "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/currency/pair" @@ -78,7 +79,10 @@ func (b *Bitfinex) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderb // UpdateOrderbook updates and returns the orderbook for a currency pair func (b *Bitfinex) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error) { var orderBook orderbook.Base - orderbookNew, err := b.GetOrderbook(p.Pair().String(), nil) + var vals url.Values + vals.Set("limit_bids", "100") + vals.Set("limit_asks", "100") + orderbookNew, err := b.GetOrderbook(p.Pair().String(), vals) if err != nil { return orderBook, err }