mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-03 15:10:49 +00:00
Miscellaneous bug fixes (#513)
* Various bug fixes * Deadlink, cleanup plus bug fixes * Various Kraken fixes * Add convert func for decimal unix timestamps * Convert all test times to UTC * Kraken: Make assets a pointer to prevent excessive copying * Docker slash fix * Address nits plus bump ITBit last checked pairs timestamp * Set pairs to enabled pairs when getting active orders * Use asset translator for UpdateAccountInfo and more checks for the exchange template tool * Address MadCozBadd's nits * Make exchange var 2 chars * Make program more user friendly * Project wide comment checks and exchName check * Fix Huobi indexing bug and use correct pair formatting * Address nits + readme change
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/common/convert"
|
||||
"github.com/thrasher-corp/gocryptotrader/config"
|
||||
"github.com/thrasher-corp/gocryptotrader/core"
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
@@ -743,3 +744,21 @@ func TestWsBalanceUpdate(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseTime(t *testing.T) {
|
||||
// Test REST example
|
||||
r := convert.TimeFromUnixTimestampDecimal(1574846296.995313).UTC()
|
||||
if r.Year() != 2019 ||
|
||||
r.Month().String() != "November" ||
|
||||
r.Day() != 27 {
|
||||
t.Error("unexpected result")
|
||||
}
|
||||
|
||||
// Test websocket example
|
||||
r = convert.TimeFromUnixTimestampDecimal(1523887354.256974).UTC()
|
||||
if r.Year() != 2018 ||
|
||||
r.Month().String() != "April" ||
|
||||
r.Day() != 16 {
|
||||
t.Error("unexpected result")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,16 +223,7 @@ func (g *Gateio) wsHandleData(respRaw []byte) error {
|
||||
case 2:
|
||||
oSide = order.Buy
|
||||
}
|
||||
var cTime, cTimeDec, mTime, mTimeDec int64
|
||||
var price, amount, filledTotal, left, fee float64
|
||||
cTime, cTimeDec, err = convert.SplitFloatDecimals(invalidJSON["ctime"].(float64))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mTime, mTimeDec, err = convert.SplitFloatDecimals(invalidJSON["mtime"].(float64))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
price, err = strconv.ParseFloat(invalidJSON["price"].(string), 64)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -271,8 +262,8 @@ func (g *Gateio) wsHandleData(respRaw []byte) error {
|
||||
Side: oSide,
|
||||
Status: oStatus,
|
||||
AssetType: a,
|
||||
Date: time.Unix(cTime, cTimeDec),
|
||||
LastUpdated: time.Unix(mTime, mTimeDec),
|
||||
Date: convert.TimeFromUnixTimestampDecimal(invalidJSON["ctime"].(float64)),
|
||||
LastUpdated: convert.TimeFromUnixTimestampDecimal(invalidJSON["mtime"].(float64)),
|
||||
Pair: p,
|
||||
}
|
||||
case strings.Contains(result.Method, "depth"):
|
||||
|
||||
@@ -592,11 +592,6 @@ func (g *Gateio) GetActiveOrders(req *order.GetOrdersRequest) ([]order.Detail, e
|
||||
if resp.WebSocketOrderQueryRecords[j].OrderType == 1 {
|
||||
orderType = order.Limit
|
||||
}
|
||||
firstNum, decNum, err := convert.SplitFloatDecimals(resp.WebSocketOrderQueryRecords[j].Ctime)
|
||||
if err != nil {
|
||||
return orders, err
|
||||
}
|
||||
orderDate := time.Unix(firstNum, decNum)
|
||||
orders = append(orders, order.Detail{
|
||||
Exchange: g.Name,
|
||||
AccountID: strconv.FormatInt(resp.WebSocketOrderQueryRecords[j].User, 10),
|
||||
@@ -604,7 +599,7 @@ func (g *Gateio) GetActiveOrders(req *order.GetOrdersRequest) ([]order.Detail, e
|
||||
Pair: currency.NewPairFromString(resp.WebSocketOrderQueryRecords[j].Market),
|
||||
Side: orderSide,
|
||||
Type: orderType,
|
||||
Date: orderDate,
|
||||
Date: convert.TimeFromUnixTimestampDecimal(resp.WebSocketOrderQueryRecords[j].Ctime),
|
||||
Price: resp.WebSocketOrderQueryRecords[j].Price,
|
||||
Amount: resp.WebSocketOrderQueryRecords[j].Amount,
|
||||
ExecutedAmount: resp.WebSocketOrderQueryRecords[j].FilledAmount,
|
||||
|
||||
Reference in New Issue
Block a user