mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-08 07:26:48 +00:00
(BTC Markets): Wrapper SubmitOrder parameter order fix & IsOrderPlaced condition correction (#394)
* corrected param order Side -> Type, also corrected condition check for IsOrderPlaced * send open status for GetActiveOrders * GetActiveOrder() changes to include OrderID and status matching * BTC Markets batch order limit fixes & SplitStringSliceByLimit method BTC markets batch end points have limits (20 for cancel 50 for query) adds new method SplitStringSliceByLimit in common to split a slice by limit and return slice of slice * rm line :D * Added test for SplitStringSliceByLimit and moved to const * ntp client reworked to not return error if no valid time servers are found but default to system * clean up * new line added * use TimeMgr sublogger and wording correction on output * Moved to DialTimeout() & Removed SetDeadline call * removed line * added setdeadline fix * goimport file * removed unused error from NTPClient as we now default to system time if no server can be reached * Added checks for number overflows * converted to uint as you should not be passing a negative number in * Increased test cases for NTPClient * Removed Helper call as no longer outputting any data from function * removed unused param
This commit is contained in:
@@ -340,3 +340,17 @@ func ChangePermission(directory string) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// SplitStringSliceByLimit splits a slice of strings into slices by input limit and returns a slice of slice of strings
|
||||
func SplitStringSliceByLimit(in []string, limit uint) [][]string {
|
||||
var stringSlice []string
|
||||
sliceSlice := make([][]string, 0, len(in)/int(limit)+1)
|
||||
for len(in) >= int(limit) {
|
||||
stringSlice, in = in[:limit], in[limit:]
|
||||
sliceSlice = append(sliceSlice, stringSlice)
|
||||
}
|
||||
if len(in) > 0 {
|
||||
sliceSlice = append(sliceSlice, in)
|
||||
}
|
||||
return sliceSlice
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -499,3 +500,29 @@ func TestChangePermission(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func initStringSlice(size int) (out []string) {
|
||||
for x := 0; x < size; x++ {
|
||||
out = append(out, "gct-"+strconv.Itoa(x))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func TestSplitStringSliceByLimit(t *testing.T) {
|
||||
slice50 := initStringSlice(50)
|
||||
out := SplitStringSliceByLimit(slice50, 20)
|
||||
if len(out) != 3 {
|
||||
t.Errorf("expected len() to be 3 instead received: %v", len(out))
|
||||
}
|
||||
if len(out[0]) != 20 {
|
||||
t.Errorf("expected len() to be 20 instead received: %v", len(out[0]))
|
||||
}
|
||||
|
||||
out = SplitStringSliceByLimit(slice50, 50)
|
||||
if len(out) != 1 {
|
||||
t.Errorf("expected len() to be 3 instead received: %v", len(out))
|
||||
}
|
||||
if len(out[0]) != 50 {
|
||||
t.Errorf("expected len() to be 20 instead received: %v", len(out[0]))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user