Exchanges: Include format pair in wrapper functions and test for formatting issues via tool wrapper issues (#582)

* Adds formatting of pair within binance wrapper, adds return of error from cli.ShowCommmandHelp

* Add formatting function to submit order wrapper functions

* Remove superfluous functionality

* Updated exchange wrapper issues to create a disruptive pair to see which exchanges require attention, updates currency code generation and matching

* reinstated format check, fixed tests

* fixed niterinos

* fix test

* fix spelling mistake

* make html file more aesthetic

* Add missing format pairs

* add formatting to pair for BTC Markets func

* fix spelling
This commit is contained in:
Ryan O'Hara-Reid
2020-10-26 16:54:51 +11:00
committed by GitHub
parent 8a241c2efa
commit 220245c5a8
32 changed files with 429 additions and 199 deletions

View File

@@ -183,13 +183,18 @@ func (b *Bitflyer) UpdateTradablePairs(forceUpdate bool) error {
// UpdateTicker updates and returns the ticker for a currency pair
func (b *Bitflyer) UpdateTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error) {
tickerNew, err := b.GetTicker(b.CheckFXString(p).String())
fPair, err := b.FormatExchangeCurrency(p, assetType)
if err != nil {
return nil, err
}
tickerNew, err := b.GetTicker(b.CheckFXString(fPair).String())
if err != nil {
return nil, err
}
err = ticker.ProcessTicker(&ticker.Price{
Pair: p,
Pair: fPair,
Ask: tickerNew.BestAsk,
Bid: tickerNew.BestBid,
Last: tickerNew.Last,
@@ -200,14 +205,19 @@ func (b *Bitflyer) UpdateTicker(p currency.Pair, assetType asset.Item) (*ticker.
return nil, err
}
return ticker.GetTicker(b.Name, p, assetType)
return ticker.GetTicker(b.Name, fPair, assetType)
}
// FetchTicker returns the ticker for a currency pair
func (b *Bitflyer) FetchTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error) {
tick, err := ticker.GetTicker(b.Name, p, assetType)
fPair, err := b.FormatExchangeCurrency(p, assetType)
if err != nil {
return b.UpdateTicker(p, assetType)
return nil, err
}
tick, err := ticker.GetTicker(b.Name, fPair, assetType)
if err != nil {
return b.UpdateTicker(fPair, assetType)
}
return tick, nil
}
@@ -223,18 +233,28 @@ func (b *Bitflyer) CheckFXString(p currency.Pair) currency.Pair {
// FetchOrderbook returns the orderbook for a currency pair
func (b *Bitflyer) FetchOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {
ob, err := orderbook.Get(b.Name, p, assetType)
fPair, err := b.FormatExchangeCurrency(p, assetType)
if err != nil {
return b.UpdateOrderbook(p, assetType)
return nil, err
}
ob, err := orderbook.Get(b.Name, fPair, assetType)
if err != nil {
return b.UpdateOrderbook(fPair, assetType)
}
return ob, nil
}
// UpdateOrderbook updates and returns the orderbook for a currency pair
func (b *Bitflyer) UpdateOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {
fPair, err := b.FormatExchangeCurrency(p, assetType)
if err != nil {
return nil, err
}
orderBook := new(orderbook.Base)
orderbookNew, err := b.GetOrderBook(b.CheckFXString(p).String())
orderbookNew, err := b.GetOrderBook(b.CheckFXString(fPair).String())
if err != nil {
return orderBook, err
}
@@ -247,7 +267,7 @@ func (b *Bitflyer) UpdateOrderbook(p currency.Pair, assetType asset.Item) (*orde
orderBook.Bids = append(orderBook.Bids, orderbook.Item{Price: orderbookNew.Bids[x].Price, Amount: orderbookNew.Bids[x].Size})
}
orderBook.Pair = p
orderBook.Pair = fPair
orderBook.ExchangeName = b.Name
orderBook.AssetType = assetType
@@ -256,7 +276,7 @@ func (b *Bitflyer) UpdateOrderbook(p currency.Pair, assetType asset.Item) (*orde
return orderBook, err
}
return orderbook.Get(b.Name, p, assetType)
return orderbook.Get(b.Name, fPair, assetType)
}
// UpdateAccountInfo retrieves balances for all enabled currencies on the