Link up websocket handler to routes after refactor and various improvements

This commit is contained in:
Adrian Gallagher
2017-09-11 09:07:41 +10:00
parent 0682dcec88
commit 6e9bda83a1
9 changed files with 148 additions and 169 deletions

View File

@@ -54,6 +54,16 @@ func Add(exchange string, p pair.CurrencyPair, assetType string, price, volume f
return
}
if p.FirstCurrency == "XBT" {
newPair := pair.NewCurrencyPair("BTC", p.SecondCurrency.String())
Append(exchange, newPair, assetType, price, volume)
}
if p.SecondCurrency == "USDT" {
newPair := pair.NewCurrencyPair(p.FirstCurrency.String(), "USD")
Append(exchange, newPair, assetType, price, volume)
}
Append(exchange, p, assetType, price, volume)
}

View File

@@ -114,6 +114,20 @@ func TestAdd(t *testing.T) {
if len(Items) != 1 {
t.Error("Test Failed - stats Add did not add exchange info.")
}
p.FirstCurrency = "XBT"
Add("ANX", p, "SPOT", 1201, 43)
if Items[1].Pair.Pair() != "XBTUSD" {
t.Fatal("Test failed. stats Add did not add exchange info.")
}
p = pair.NewCurrencyPair("ETH", "USDT")
Add("ANX", p, "SPOT", 300, 1000)
if Items[2].Pair.Pair() != "ETHUSD" {
t.Fatal("Test failed. stats Add did not add exchange info.")
}
}
func TestAppend(t *testing.T) {