Add UpdateOrderbook exchange function and update all exchanges to support it

This commit is contained in:
Adrian Gallagher
2017-08-30 16:12:18 +10:00
parent a5b3a6b489
commit ad7ae88ff4
24 changed files with 404 additions and 89 deletions

View File

@@ -28,6 +28,7 @@ func (a *Alphapoint) GetExchangeAccountInfo() (exchange.AccountInfo, error) {
return response, nil
}
// UpdateTicker updates and returns the ticker for a currency pair
func (a *Alphapoint) UpdateTicker(p pair.CurrencyPair) (ticker.TickerPrice, error) {
var tickerPrice ticker.TickerPrice
tick, err := a.GetTicker(p.Pair().String())
@@ -46,6 +47,7 @@ func (a *Alphapoint) UpdateTicker(p pair.CurrencyPair) (ticker.TickerPrice, erro
return tickerPrice, nil
}
// GetTickerPrice returns the ticker for a currency pair
func (a *Alphapoint) GetTickerPrice(p pair.CurrencyPair) (ticker.TickerPrice, error) {
tick, err := ticker.GetTicker(a.GetName(), p)
if err != nil {
@@ -54,12 +56,8 @@ func (a *Alphapoint) GetTickerPrice(p pair.CurrencyPair) (ticker.TickerPrice, er
return tick, nil
}
func (a *Alphapoint) GetOrderbookEx(p pair.CurrencyPair) (orderbook.OrderbookBase, error) {
ob, err := orderbook.GetOrderbook(a.GetName(), p)
if err == nil {
return ob, nil
}
// UpdateOrderbook updates and returns the orderbook for a currency pair
func (a *Alphapoint) UpdateOrderbook(p pair.CurrencyPair) (orderbook.OrderbookBase, error) {
var orderBook orderbook.OrderbookBase
orderbookNew, err := a.GetOrderbook(p.Pair().String())
if err != nil {
@@ -80,3 +78,12 @@ func (a *Alphapoint) GetOrderbookEx(p pair.CurrencyPair) (orderbook.OrderbookBas
orderbook.ProcessOrderbook(a.GetName(), p, orderBook)
return orderBook, nil
}
// GetOrderbookEx returns the orderbook for a currency pair
func (a *Alphapoint) GetOrderbookEx(p pair.CurrencyPair) (orderbook.OrderbookBase, error) {
ob, err := orderbook.GetOrderbook(a.GetName(), p)
if err == nil {
return a.UpdateOrderbook(p)
}
return ob, nil
}