exchanges/kraken,bittrex,gemini: Resolve Kraken panic, lint corrections, Bittrex batch tickers, set Gemini order limits and update tradable pairs (#1372)

* fix kraken, batch bittrex, fix lint

* surprise gemini!

* thought this happened automatically

* fix before shazbert sees

* fixes annoying atoi bug

* rm futures from gemini

* lint

* bittrex UpdatedAt, gemini Limits, stats relook

* STATS used HARDEN!(improve stats package)

* Whoopsies in your Daisies

* rm RWMutex, json stringeroo

* fixes additional index issues 😆 😭
This commit is contained in:
Scott
2023-10-23 17:06:25 +10:00
committed by GitHub
parent f8e943ea8e
commit 2ea3083468
14 changed files with 1855 additions and 120 deletions

View File

@@ -12,11 +12,12 @@ const (
)
func TestLenByPrice(t *testing.T) {
t.Parallel()
p, err := currency.NewPairFromStrings("BTC", "USD")
if err != nil {
t.Fatal(err)
}
Items = []Item{
localItems := []Item{
{
Exchange: testExchange,
Pair: p,
@@ -26,17 +27,18 @@ func TestLenByPrice(t *testing.T) {
},
}
if ByPrice.Len(Items) < 1 {
if byPrice.Len(localItems) < 1 {
t.Error("stats LenByPrice() length not correct.")
}
}
func TestLessByPrice(t *testing.T) {
t.Parallel()
p, err := currency.NewPairFromStrings("BTC", "USD")
if err != nil {
t.Fatal(err)
}
Items = []Item{
localItems := []Item{
{
Exchange: "alphapoint",
Pair: p,
@@ -53,20 +55,21 @@ func TestLessByPrice(t *testing.T) {
},
}
if !ByPrice.Less(Items, 1, 0) {
if !byPrice.Less(localItems, 1, 0) {
t.Error("stats LessByPrice() incorrect return.")
}
if ByPrice.Less(Items, 0, 1) {
if byPrice.Less(localItems, 0, 1) {
t.Error("stats LessByPrice() incorrect return.")
}
}
func TestSwapByPrice(t *testing.T) {
t.Parallel()
p, err := currency.NewPairFromStrings("BTC", "USD")
if err != nil {
t.Fatal(err)
}
Items = []Item{
localItems := []Item{
{
Exchange: "bitstamp",
Pair: p,
@@ -83,37 +86,97 @@ func TestSwapByPrice(t *testing.T) {
},
}
ByPrice.Swap(Items, 0, 1)
if Items[0].Exchange != "bitfinex" || Items[1].Exchange != "bitstamp" {
byPrice.Swap(localItems, 0, 1)
if localItems[0].Exchange != "bitfinex" || localItems[1].Exchange != "bitstamp" {
t.Error("stats SwapByPrice did not swap values.")
}
}
func TestLenByVolume(t *testing.T) {
if ByVolume.Len(Items) != 2 {
t.Parallel()
p, err := currency.NewPairFromStrings("BTC", "USD")
if err != nil {
t.Fatal(err)
}
localItems := []Item{
{
Exchange: "bitstamp",
Pair: p,
AssetType: asset.Spot,
Price: 1324,
Volume: 5,
},
{
Exchange: "bitfinex",
Pair: p,
AssetType: asset.Spot,
Price: 7863,
Volume: 20,
},
}
if byVolume.Len(localItems) != 2 {
t.Error("stats lenByVolume did not swap values.")
}
}
func TestLessByVolume(t *testing.T) {
if !ByVolume.Less(Items, 1, 0) {
t.Error("stats LessByVolume() incorrect return.")
t.Parallel()
p, err := currency.NewPairFromStrings("BTC", "USD")
if err != nil {
t.Fatal(err)
}
if ByVolume.Less(Items, 0, 1) {
t.Error("stats LessByVolume() incorrect return.")
localItems := []Item{
{
Exchange: "bitstamp",
Pair: p,
AssetType: asset.Spot,
Price: 1324,
Volume: 5,
},
{
Exchange: "bitfinex",
Pair: p,
AssetType: asset.Spot,
Price: 7863,
Volume: 20,
},
}
if !byVolume.Less(localItems, 0, 1) {
t.Error("localItems[0].Volume should be less than localItems[1].Volume")
}
}
func TestSwapByVolume(t *testing.T) {
ByPrice.Swap(Items, 0, 1)
if Items[1].Exchange != "bitfinex" || Items[0].Exchange != "bitstamp" {
t.Parallel()
p, err := currency.NewPairFromStrings("BTC", "USD")
if err != nil {
t.Fatal(err)
}
localItems := []Item{
{
Exchange: "bitstamp",
Pair: p,
AssetType: asset.Spot,
Price: 1324,
Volume: 5,
},
{
Exchange: "bitfinex",
Pair: p,
AssetType: asset.Spot,
Price: 7863,
Volume: 20,
},
}
byVolume.Swap(localItems, 0, 1)
if localItems[0].Exchange != "bitfinex" || localItems[1].Exchange != "bitstamp" {
t.Error("stats SwapByVolume did not swap values.")
}
}
func TestAdd(t *testing.T) {
Items = Items[:0]
items = items[:0]
p, err := currency.NewPairFromStrings("BTC", "USD")
if err != nil {
t.Fatal(err)
@@ -123,7 +186,7 @@ func TestAdd(t *testing.T) {
t.Fatal(err)
}
if len(Items) < 1 {
if len(items) < 1 {
t.Error("stats Add did not add exchange info.")
}
@@ -132,7 +195,7 @@ func TestAdd(t *testing.T) {
t.Fatal("error cannot be nil")
}
if len(Items) != 1 {
if len(items) != 1 {
t.Error("stats Add did not add exchange info.")
}
@@ -142,7 +205,7 @@ func TestAdd(t *testing.T) {
t.Fatal(err)
}
if Items[1].Pair.String() != "XBTUSD" {
if items[1].Pair.String() != "XBTUSD" {
t.Fatal("stats Add did not add exchange info.")
}
@@ -156,7 +219,7 @@ func TestAdd(t *testing.T) {
t.Fatal(err)
}
if Items[2].Pair.String() != "ETHUSD" {
if items[2].Pair.String() != "ETHUSD" {
t.Fatal("stats Add did not add exchange info.")
}
}
@@ -167,12 +230,12 @@ func TestAppend(t *testing.T) {
t.Fatal(err)
}
Append("sillyexchange", p, asset.Spot, 1234, 45)
if len(Items) < 2 {
if len(items) < 2 {
t.Error("stats AppendResults did not add exchange values.")
}
Append("sillyexchange", p, asset.Spot, 1234, 45)
if len(Items) == 3 {
if len(items) == 3 {
t.Error("stats AppendResults added exchange values")
}
}