mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-22 15:10:13 +00:00
Engine: Protocol Features, coverage, types, BTC markets websocket (#368)
* Attempts to update orderbook so it doesn't need to sort * Reverts the ws ob stuff. Gets rid of sorting because it happens later. Adds some exchange features * update existing feature lists. Expands list definition to match my emotions * Adds bithumb bitmex and bitstamp. adds a couple more types * Features for you, features for me, features for bittrex, btcmarkets, btse, coinbasepro, coinut, exmo, gateio and gemini * Features for hitbtc, huobi, itbit, kraken, lakebtc, lbank, localbitcoins, okcoin, okex, poloniex, yobit, zb * Who can forget good old alphapoint? * Adds btcmarksets websocket :glitch_crab: fixes alphapoint features * Adds extra data not in the documentation :/ * Replaces websocket features by using protocol features. However, it breaks it due to import cycles. I'm not sure what I'll do just yet * Removes import cycle via duplicate structs. * Increases coverage of config with `TestCheckCurrencyConfigValues`. Moves all currency pair package types into their own files or places it at the bottom of files if necessary * Increase coverage in code.go * One way of determining a test has failed, is when to it fails. Removed redundant explanation * Increases code coverage of conversion * Lint fixes * Fixes orderbook tests * Re-adds sorting because its important to still have the internal pre-processed orderbook to be representative of a real orderbook * Secret lints that did not show up via Windows linting * Adds protocol package to contain exchange features * Fixes protocol implementation * Fixes ws tests * Addresses the following: Removes st-st-stutters in config types, changes GetAvailableForexProviders -> GetSupportedForexProviders, removes errors from tests where error is nil, removes orderbook setup when not necessary, removes import newlines, removes false bools from declaration, changes should of to should have * imports and casing * Fixes two more nil error checks
This commit is contained in:
@@ -20,7 +20,7 @@ func TestLenByPrice(t *testing.T) {
|
||||
}
|
||||
|
||||
if ByPrice.Len(Items) < 1 {
|
||||
t.Error("Test Failed - stats LenByPrice() length not correct.")
|
||||
t.Error("stats LenByPrice() length not correct.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ func TestLessByPrice(t *testing.T) {
|
||||
}
|
||||
|
||||
if !ByPrice.Less(Items, 1, 0) {
|
||||
t.Error("Test Failed - stats LessByPrice() incorrect return.")
|
||||
t.Error("stats LessByPrice() incorrect return.")
|
||||
}
|
||||
if ByPrice.Less(Items, 0, 1) {
|
||||
t.Error("Test Failed - stats LessByPrice() incorrect return.")
|
||||
t.Error("stats LessByPrice() incorrect return.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,22 +74,22 @@ func TestSwapByPrice(t *testing.T) {
|
||||
|
||||
ByPrice.Swap(Items, 0, 1)
|
||||
if Items[0].Exchange != "bitfinex" || Items[1].Exchange != "bitstamp" {
|
||||
t.Error("Test Failed - stats SwapByPrice did not swap values.")
|
||||
t.Error("stats SwapByPrice did not swap values.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLenByVolume(t *testing.T) {
|
||||
if ByVolume.Len(Items) != 2 {
|
||||
t.Error("Test Failed - stats lenByVolume did not swap values.")
|
||||
t.Error("stats lenByVolume did not swap values.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLessByVolume(t *testing.T) {
|
||||
if !ByVolume.Less(Items, 1, 0) {
|
||||
t.Error("Test Failed - stats LessByVolume() incorrect return.")
|
||||
t.Error("stats LessByVolume() incorrect return.")
|
||||
}
|
||||
if ByVolume.Less(Items, 0, 1) {
|
||||
t.Error("Test Failed - stats LessByVolume() incorrect return.")
|
||||
t.Error("stats LessByVolume() incorrect return.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func TestSwapByVolume(t *testing.T) {
|
||||
ByPrice.Swap(Items, 0, 1)
|
||||
|
||||
if Items[1].Exchange != "bitfinex" || Items[0].Exchange != "bitstamp" {
|
||||
t.Error("Test Failed - stats SwapByVolume did not swap values.")
|
||||
t.Error("stats SwapByVolume did not swap values.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,27 +107,27 @@ func TestAdd(t *testing.T) {
|
||||
Add("ANX", p, asset.Spot, 1200, 42)
|
||||
|
||||
if len(Items) < 1 {
|
||||
t.Error("Test Failed - stats Add did not add exchange info.")
|
||||
t.Error("stats Add did not add exchange info.")
|
||||
}
|
||||
|
||||
Add("", p, "", 0, 0)
|
||||
|
||||
if len(Items) != 1 {
|
||||
t.Error("Test Failed - stats Add did not add exchange info.")
|
||||
t.Error("stats Add did not add exchange info.")
|
||||
}
|
||||
|
||||
p.Base = currency.XBT
|
||||
Add("ANX", p, asset.Spot, 1201, 43)
|
||||
|
||||
if Items[1].Pair.String() != "XBTUSD" {
|
||||
t.Fatal("Test failed. stats Add did not add exchange info.")
|
||||
t.Fatal("stats Add did not add exchange info.")
|
||||
}
|
||||
|
||||
p = currency.NewPairFromStrings("ETH", "USDT")
|
||||
Add("ANX", p, asset.Spot, 300, 1000)
|
||||
|
||||
if Items[2].Pair.String() != "ETHUSD" {
|
||||
t.Fatal("Test failed. stats Add did not add exchange info.")
|
||||
t.Fatal("stats Add did not add exchange info.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,23 +135,23 @@ func TestAppend(t *testing.T) {
|
||||
p := currency.NewPairFromStrings("BTC", "USD")
|
||||
Append("sillyexchange", p, asset.Spot, 1234, 45)
|
||||
if len(Items) < 2 {
|
||||
t.Error("Test Failed - stats Append did not add exchange values.")
|
||||
t.Error("stats Append did not add exchange values.")
|
||||
}
|
||||
|
||||
Append("sillyexchange", p, asset.Spot, 1234, 45)
|
||||
if len(Items) == 3 {
|
||||
t.Error("Test Failed - stats Append added exchange values")
|
||||
t.Error("stats Append added exchange values")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAlreadyExists(t *testing.T) {
|
||||
p := currency.NewPairFromStrings("BTC", "USD")
|
||||
if !AlreadyExists("ANX", p, asset.Spot, 1200, 42) {
|
||||
t.Error("Test Failed - stats AlreadyExists exchange does not exist.")
|
||||
t.Error("stats AlreadyExists exchange does not exist.")
|
||||
}
|
||||
p.Base = currency.NewCode("dii")
|
||||
if AlreadyExists("bla", p, asset.Spot, 1234, 123) {
|
||||
t.Error("Test Failed - stats AlreadyExists found incorrect exchange.")
|
||||
t.Error("stats AlreadyExists found incorrect exchange.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,12 +159,12 @@ func TestSortExchangesByVolume(t *testing.T) {
|
||||
p := currency.NewPairFromStrings("BTC", "USD")
|
||||
topVolume := SortExchangesByVolume(p, asset.Spot, true)
|
||||
if topVolume[0].Exchange != "sillyexchange" {
|
||||
t.Error("Test Failed - stats SortExchangesByVolume incorrectly sorted values.")
|
||||
t.Error("stats SortExchangesByVolume incorrectly sorted values.")
|
||||
}
|
||||
|
||||
topVolume = SortExchangesByVolume(p, asset.Spot, false)
|
||||
if topVolume[0].Exchange != "ANX" {
|
||||
t.Error("Test Failed - stats SortExchangesByVolume incorrectly sorted values.")
|
||||
t.Error("stats SortExchangesByVolume incorrectly sorted values.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,11 +172,11 @@ func TestSortExchangesByPrice(t *testing.T) {
|
||||
p := currency.NewPairFromStrings("BTC", "USD")
|
||||
topPrice := SortExchangesByPrice(p, asset.Spot, true)
|
||||
if topPrice[0].Exchange != "sillyexchange" {
|
||||
t.Error("Test Failed - stats SortExchangesByPrice incorrectly sorted values.")
|
||||
t.Error("stats SortExchangesByPrice incorrectly sorted values.")
|
||||
}
|
||||
|
||||
topPrice = SortExchangesByPrice(p, asset.Spot, false)
|
||||
if topPrice[0].Exchange != "ANX" {
|
||||
t.Error("Test Failed - stats SortExchangesByPrice incorrectly sorted values.")
|
||||
t.Error("stats SortExchangesByPrice incorrectly sorted values.")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user