Currency package update (#247)

* Initial currency overhaul before service system implementation

* Remove redundant currency string in orderbook.Base
Unexport lastupdated field in orderbook.Base as it was being instantiated multiple times
Add error handling for process orderbook

*  Remove redundant currency string in ticker.Price
 Unexport lastupdated field in ticker.Price
 Add error handling for process ticker function and fix tests

* Phase Two Update

* Update translations to use map type - thankyou to kempeng for spotting this

* Change pair method name from Display -> Format for better readability

* Fixes misspelling and tests

* Implement requested changes from GloriousCode

* Remove reduntant function and streamlined return in currency_translation.go

* Revert pair method naming conventions

* Change currency naming conventions

* Changed code type to exported Item type with underlying string to reduce complexity

* Added interim orderbook process method to orderbook.Base type

* Changed feebuilder struct field to currency.Pair

* Adds fall over system for backup fx providers

* deprecate function and children and fix linter issue with btcmarkets

* Fixed requested changes

* Fix bug and move mtx for rates

* Fixed after rebase oopsies

* Fix linter issues

* Fixes race conditions in testing functions

* Final phase coinmarketcap update

* fix linter issues

* Implement requested changes

* Adds configuration variables to increase/decrease time durations between updating currency file and fetching new currency rates

* Add a collection of tests to improve codecov

* After rebase oopsy fixes for btse

* Fix requested changes

* fix after rebase oopsies and add more efficient comparison checks within currency pair

* Fix linter issues
This commit is contained in:
Ryan O'Hara-Reid
2019-03-19 11:49:05 +11:00
committed by Adrian Gallagher
parent ed760e184e
commit 0990f9d118
189 changed files with 11982 additions and 8055 deletions

View File

@@ -10,7 +10,7 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/currency"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
)
@@ -56,7 +56,7 @@ func (g *Gateio) WsSubscribe() error {
ticker := WebsocketRequest{
ID: 1337,
Method: "ticker.subscribe",
Params: []interface{}{c.Pair().String()},
Params: []interface{}{c.String()},
}
err := g.WebsocketConn.WriteJSON(ticker)
@@ -67,7 +67,7 @@ func (g *Gateio) WsSubscribe() error {
trade := WebsocketRequest{
ID: 1337,
Method: "trades.subscribe",
Params: []interface{}{c.Pair().String()},
Params: []interface{}{c.String()},
}
err = g.WebsocketConn.WriteJSON(trade)
@@ -78,7 +78,7 @@ func (g *Gateio) WsSubscribe() error {
depth := WebsocketRequest{
ID: 1337,
Method: "depth.subscribe",
Params: []interface{}{c.Pair().String(), 30, "0.1"},
Params: []interface{}{c.String(), 30, "0.1"},
}
err = g.WebsocketConn.WriteJSON(depth)
@@ -89,7 +89,7 @@ func (g *Gateio) WsSubscribe() error {
kline := WebsocketRequest{
ID: 1337,
Method: "kline.subscribe",
Params: []interface{}{c.Pair().String(), 1800},
Params: []interface{}{c.String(), 1800},
}
err = g.WebsocketConn.WriteJSON(kline)
@@ -170,7 +170,7 @@ func (g *Gateio) WsHandleData() {
g.Websocket.DataHandler <- exchange.TickerData{
Timestamp: time.Now(),
Pair: pair.NewCurrencyPairFromString(c),
Pair: currency.NewPairFromString(c),
AssetType: "SPOT",
Exchange: g.GetName(),
ClosePrice: ticker.Close,
@@ -198,7 +198,7 @@ func (g *Gateio) WsHandleData() {
for _, trade := range trades {
g.Websocket.DataHandler <- exchange.TradeData{
Timestamp: time.Now(),
CurrencyPair: pair.NewCurrencyPairFromString(c),
CurrencyPair: currency.NewPairFromString(c),
AssetType: "SPOT",
Exchange: g.GetName(),
Price: trade.Price,
@@ -268,9 +268,7 @@ func (g *Gateio) WsHandleData() {
newOrderbook.Asks = asks
newOrderbook.Bids = bids
newOrderbook.AssetType = "SPOT"
newOrderbook.CurrencyPair = c
newOrderbook.LastUpdated = time.Now()
newOrderbook.Pair = pair.NewCurrencyPairFromString(c)
newOrderbook.Pair = currency.NewPairFromString(c)
err = g.Websocket.Orderbook.LoadSnapshot(newOrderbook,
g.GetName(),
@@ -281,7 +279,7 @@ func (g *Gateio) WsHandleData() {
} else {
err = g.Websocket.Orderbook.Update(asks,
bids,
pair.NewCurrencyPairFromString(c),
currency.NewPairFromString(c),
time.Now(),
g.GetName(),
"SPOT")
@@ -291,7 +289,7 @@ func (g *Gateio) WsHandleData() {
}
g.Websocket.DataHandler <- exchange.WebsocketOrderbookUpdate{
Pair: pair.NewCurrencyPairFromString(c),
Pair: currency.NewPairFromString(c),
Asset: "SPOT",
Exchange: g.GetName(),
}
@@ -312,7 +310,7 @@ func (g *Gateio) WsHandleData() {
g.Websocket.DataHandler <- exchange.KlineData{
Timestamp: time.Now(),
Pair: pair.NewCurrencyPairFromString(data[7].(string)),
Pair: currency.NewPairFromString(data[7].(string)),
AssetType: "SPOT",
Exchange: g.GetName(),
OpenPrice: open,