Periodic pairsLastUpdated timestamp update

Fix other GoReportCard warnings
This commit is contained in:
Adrian Gallagher
2018-12-27 15:32:59 +11:00
parent 046e15a67e
commit dffa8eca99
12 changed files with 118 additions and 94 deletions

View File

@@ -1015,10 +1015,15 @@ func GetFilePath(file string) (string, error) {
}
data, err := common.ReadFile(newDirs[x])
if err != nil {
return "", err
}
if ConfirmECS(data) {
if path.Ext(newDirs[x]) == ".dat" {
return newDirs[x], nil
}
err = os.Rename(newDirs[x], newDirs[1])
if err != nil {
return "", err
@@ -1029,10 +1034,12 @@ func GetFilePath(file string) (string, error) {
if path.Ext(newDirs[x]) == ".json" {
return newDirs[x], nil
}
err = os.Rename(newDirs[x], newDirs[0])
if err != nil {
return "", err
}
return newDirs[0], nil
}

View File

@@ -265,7 +265,7 @@
"baseCurrencies": "JPY",
"assetTypes": "SPOT",
"supportsAutoPairUpdates": false,
"pairsLastUpdated": 1543208659,
"pairsLastUpdated": 1545884823,
"configCurrencyPairFormat": {
"uppercase": true,
"delimiter": "_"
@@ -873,7 +873,7 @@
"baseCurrencies": "USD,SGD",
"assetTypes": "SPOT",
"supportsAutoPairUpdates": false,
"pairsLastUpdated": 1543208659,
"pairsLastUpdated": 1545884823,
"configCurrencyPairFormat": {
"uppercase": true
},
@@ -1074,7 +1074,7 @@
"baseCurrencies": "CNY",
"assetTypes": "SPOT",
"supportsAutoPairUpdates": false,
"pairsLastUpdated": 1543207521,
"pairsLastUpdated": 1545884823,
"configCurrencyPairFormat": {
"uppercase": true
},
@@ -1280,7 +1280,7 @@
"baseCurrencies": "USD,RUR",
"assetTypes": "SPOT",
"supportsAutoPairUpdates": false,
"pairsLastUpdated": 1543208659,
"pairsLastUpdated": 1545884823,
"configCurrencyPairFormat": {
"uppercase": true,
"delimiter": "_"

View File

@@ -143,7 +143,7 @@ type OrderCancelResponse struct {
ErrorCode int64 `json:"errorCode"`
}
// OrderCancellationResponse contians the orderID and error when cancelling multiple orders
// OrderCancellationResponse contains the orderID and error when cancelling multiple orders
type OrderCancellationResponse struct {
UUID string `json:"uuid"`
Error string `json:"errorCode"`

View File

@@ -179,9 +179,11 @@ func (b *BTCMarkets) ModifyOrder(action exchange.ModifyOrder) (string, error) {
// CancelOrder cancels an order by its corresponding ID number
func (b *BTCMarkets) CancelOrder(order exchange.OrderCancellation) error {
orderIDInt, err := strconv.ParseInt(order.OrderID, 10, 64)
if err != nil {
return err
}
_, err = b.CancelExistingOrder([]int64{orderIDInt})
return err
}

View File

@@ -407,7 +407,7 @@ func (e *Base) SetAssetTypes() error {
return err
}
var update = false
var update bool
if exch.AssetTypes == "" {
exch.AssetTypes = common.JoinStrings(e.AssetTypes, ",")
update = true

View File

@@ -127,31 +127,31 @@ func TestWebsocket(t *testing.T) {
func TestInsertingSnapShots(t *testing.T) {
var snapShot1 orderbook.Base
asks := []orderbook.Item{
orderbook.Item{Price: 6000, Amount: 1, ID: 1},
orderbook.Item{Price: 6001, Amount: 0.5, ID: 2},
orderbook.Item{Price: 6002, Amount: 2, ID: 3},
orderbook.Item{Price: 6003, Amount: 3, ID: 4},
orderbook.Item{Price: 6004, Amount: 5, ID: 5},
orderbook.Item{Price: 6005, Amount: 2, ID: 6},
orderbook.Item{Price: 6006, Amount: 1.5, ID: 7},
orderbook.Item{Price: 6007, Amount: 0.5, ID: 8},
orderbook.Item{Price: 6008, Amount: 23, ID: 9},
orderbook.Item{Price: 6009, Amount: 9, ID: 10},
orderbook.Item{Price: 6010, Amount: 7, ID: 11},
{Price: 6000, Amount: 1, ID: 1},
{Price: 6001, Amount: 0.5, ID: 2},
{Price: 6002, Amount: 2, ID: 3},
{Price: 6003, Amount: 3, ID: 4},
{Price: 6004, Amount: 5, ID: 5},
{Price: 6005, Amount: 2, ID: 6},
{Price: 6006, Amount: 1.5, ID: 7},
{Price: 6007, Amount: 0.5, ID: 8},
{Price: 6008, Amount: 23, ID: 9},
{Price: 6009, Amount: 9, ID: 10},
{Price: 6010, Amount: 7, ID: 11},
}
bids := []orderbook.Item{
orderbook.Item{Price: 5999, Amount: 1, ID: 12},
orderbook.Item{Price: 5998, Amount: 0.5, ID: 13},
orderbook.Item{Price: 5997, Amount: 2, ID: 14},
orderbook.Item{Price: 5996, Amount: 3, ID: 15},
orderbook.Item{Price: 5995, Amount: 5, ID: 16},
orderbook.Item{Price: 5994, Amount: 2, ID: 17},
orderbook.Item{Price: 5993, Amount: 1.5, ID: 18},
orderbook.Item{Price: 5992, Amount: 0.5, ID: 19},
orderbook.Item{Price: 5991, Amount: 23, ID: 20},
orderbook.Item{Price: 5990, Amount: 9, ID: 21},
orderbook.Item{Price: 5989, Amount: 7, ID: 22},
{Price: 5999, Amount: 1, ID: 12},
{Price: 5998, Amount: 0.5, ID: 13},
{Price: 5997, Amount: 2, ID: 14},
{Price: 5996, Amount: 3, ID: 15},
{Price: 5995, Amount: 5, ID: 16},
{Price: 5994, Amount: 2, ID: 17},
{Price: 5993, Amount: 1.5, ID: 18},
{Price: 5992, Amount: 0.5, ID: 19},
{Price: 5991, Amount: 23, ID: 20},
{Price: 5990, Amount: 9, ID: 21},
{Price: 5989, Amount: 7, ID: 22},
}
snapShot1.Asks = asks
@@ -165,31 +165,31 @@ func TestInsertingSnapShots(t *testing.T) {
var snapShot2 orderbook.Base
asks = []orderbook.Item{
orderbook.Item{Price: 51, Amount: 1, ID: 1},
orderbook.Item{Price: 52, Amount: 0.5, ID: 2},
orderbook.Item{Price: 53, Amount: 2, ID: 3},
orderbook.Item{Price: 54, Amount: 3, ID: 4},
orderbook.Item{Price: 55, Amount: 5, ID: 5},
orderbook.Item{Price: 56, Amount: 2, ID: 6},
orderbook.Item{Price: 57, Amount: 1.5, ID: 7},
orderbook.Item{Price: 58, Amount: 0.5, ID: 8},
orderbook.Item{Price: 59, Amount: 23, ID: 9},
orderbook.Item{Price: 50, Amount: 9, ID: 10},
orderbook.Item{Price: 60, Amount: 7, ID: 11},
{Price: 51, Amount: 1, ID: 1},
{Price: 52, Amount: 0.5, ID: 2},
{Price: 53, Amount: 2, ID: 3},
{Price: 54, Amount: 3, ID: 4},
{Price: 55, Amount: 5, ID: 5},
{Price: 56, Amount: 2, ID: 6},
{Price: 57, Amount: 1.5, ID: 7},
{Price: 58, Amount: 0.5, ID: 8},
{Price: 59, Amount: 23, ID: 9},
{Price: 50, Amount: 9, ID: 10},
{Price: 60, Amount: 7, ID: 11},
}
bids = []orderbook.Item{
orderbook.Item{Price: 49, Amount: 1, ID: 12},
orderbook.Item{Price: 48, Amount: 0.5, ID: 13},
orderbook.Item{Price: 47, Amount: 2, ID: 14},
orderbook.Item{Price: 46, Amount: 3, ID: 15},
orderbook.Item{Price: 45, Amount: 5, ID: 16},
orderbook.Item{Price: 44, Amount: 2, ID: 17},
orderbook.Item{Price: 43, Amount: 1.5, ID: 18},
orderbook.Item{Price: 42, Amount: 0.5, ID: 19},
orderbook.Item{Price: 41, Amount: 23, ID: 20},
orderbook.Item{Price: 40, Amount: 9, ID: 21},
orderbook.Item{Price: 39, Amount: 7, ID: 22},
{Price: 49, Amount: 1, ID: 12},
{Price: 48, Amount: 0.5, ID: 13},
{Price: 47, Amount: 2, ID: 14},
{Price: 46, Amount: 3, ID: 15},
{Price: 45, Amount: 5, ID: 16},
{Price: 44, Amount: 2, ID: 17},
{Price: 43, Amount: 1.5, ID: 18},
{Price: 42, Amount: 0.5, ID: 19},
{Price: 41, Amount: 23, ID: 20},
{Price: 40, Amount: 9, ID: 21},
{Price: 39, Amount: 7, ID: 22},
}
snapShot2.Asks = asks
@@ -203,31 +203,31 @@ func TestInsertingSnapShots(t *testing.T) {
var snapShot3 orderbook.Base
asks = []orderbook.Item{
orderbook.Item{Price: 51, Amount: 1, ID: 1},
orderbook.Item{Price: 52, Amount: 0.5, ID: 2},
orderbook.Item{Price: 53, Amount: 2, ID: 3},
orderbook.Item{Price: 54, Amount: 3, ID: 4},
orderbook.Item{Price: 55, Amount: 5, ID: 5},
orderbook.Item{Price: 56, Amount: 2, ID: 6},
orderbook.Item{Price: 57, Amount: 1.5, ID: 7},
orderbook.Item{Price: 58, Amount: 0.5, ID: 8},
orderbook.Item{Price: 59, Amount: 23, ID: 9},
orderbook.Item{Price: 50, Amount: 9, ID: 10},
orderbook.Item{Price: 60, Amount: 7, ID: 11},
{Price: 51, Amount: 1, ID: 1},
{Price: 52, Amount: 0.5, ID: 2},
{Price: 53, Amount: 2, ID: 3},
{Price: 54, Amount: 3, ID: 4},
{Price: 55, Amount: 5, ID: 5},
{Price: 56, Amount: 2, ID: 6},
{Price: 57, Amount: 1.5, ID: 7},
{Price: 58, Amount: 0.5, ID: 8},
{Price: 59, Amount: 23, ID: 9},
{Price: 50, Amount: 9, ID: 10},
{Price: 60, Amount: 7, ID: 11},
}
bids = []orderbook.Item{
orderbook.Item{Price: 49, Amount: 1, ID: 12},
orderbook.Item{Price: 48, Amount: 0.5, ID: 13},
orderbook.Item{Price: 47, Amount: 2, ID: 14},
orderbook.Item{Price: 46, Amount: 3, ID: 15},
orderbook.Item{Price: 45, Amount: 5, ID: 16},
orderbook.Item{Price: 44, Amount: 2, ID: 17},
orderbook.Item{Price: 43, Amount: 1.5, ID: 18},
orderbook.Item{Price: 42, Amount: 0.5, ID: 19},
orderbook.Item{Price: 41, Amount: 23, ID: 20},
orderbook.Item{Price: 40, Amount: 9, ID: 21},
orderbook.Item{Price: 39, Amount: 7, ID: 22},
{Price: 49, Amount: 1, ID: 12},
{Price: 48, Amount: 0.5, ID: 13},
{Price: 47, Amount: 2, ID: 14},
{Price: 46, Amount: 3, ID: 15},
{Price: 45, Amount: 5, ID: 16},
{Price: 44, Amount: 2, ID: 17},
{Price: 43, Amount: 1.5, ID: 18},
{Price: 42, Amount: 0.5, ID: 19},
{Price: 41, Amount: 23, ID: 20},
{Price: 40, Amount: 9, ID: 21},
{Price: 39, Amount: 7, ID: 22},
}
snapShot3.Asks = asks
@@ -249,17 +249,17 @@ func TestUpdate(t *testing.T) {
BTCUSDPAIR := pair.NewCurrencyPairFromString("BTCUSD")
bidTargets := []orderbook.Item{
orderbook.Item{Price: 49, Amount: 24}, // Amend
orderbook.Item{Price: 48, Amount: 0}, // Delete
orderbook.Item{Price: 1337, Amount: 100}, // Append
orderbook.Item{Price: 1336, Amount: 0}, // Ghost delete
{Price: 49, Amount: 24}, // Amend
{Price: 48, Amount: 0}, // Delete
{Price: 1337, Amount: 100}, // Append
{Price: 1336, Amount: 0}, // Ghost delete
}
askTargets := []orderbook.Item{
orderbook.Item{Price: 51, Amount: 24}, // Amend
orderbook.Item{Price: 52, Amount: 0}, // Delete
orderbook.Item{Price: 1337, Amount: 100}, // Append
orderbook.Item{Price: 1336, Amount: 0}, // Ghost delete
{Price: 51, Amount: 24}, // Amend
{Price: 52, Amount: 0}, // Delete
{Price: 1337, Amount: 100}, // Append
{Price: 1336, Amount: 0}, // Ghost delete
}
err := wsTest.Websocket.Orderbook.Update(bidTargets,
@@ -285,17 +285,17 @@ func TestUpdate(t *testing.T) {
}
bidTargets = []orderbook.Item{
orderbook.Item{Price: 5999, Amount: 24}, // Amend
orderbook.Item{Price: 5998, Amount: 0}, // Delete
orderbook.Item{Price: 1337, Amount: 100}, // Append
orderbook.Item{Price: 1336, Amount: 0}, // Ghost delete
{Price: 5999, Amount: 24}, // Amend
{Price: 5998, Amount: 0}, // Delete
{Price: 1337, Amount: 100}, // Append
{Price: 1336, Amount: 0}, // Ghost delete
}
askTargets = []orderbook.Item{
orderbook.Item{Price: 6000, Amount: 24}, // Amend
orderbook.Item{Price: 6001, Amount: 0}, // Delete
orderbook.Item{Price: 1337, Amount: 100}, // Append
orderbook.Item{Price: 1336, Amount: 0}, // Ghost delete
{Price: 6000, Amount: 24}, // Amend
{Price: 6001, Amount: 0}, // Delete
{Price: 1337, Amount: 100}, // Append
{Price: 1336, Amount: 0}, // Ghost delete
}
err = wsTest.Websocket.Orderbook.Update(bidTargets,

View File

@@ -421,6 +421,9 @@ func TestSubmitOrder(t *testing.T) {
SecondCurrency: symbol.USDT,
}
accounts, err := h.GetAccounts()
if err != nil {
t.Errorf("Failed to get accounts. Err: %s", err)
}
response, err := h.SubmitOrder(p, exchange.Buy, exchange.Limit, 1, 10, strconv.FormatInt(accounts[0].ID, 10))
if err != nil || !response.IsOrderPlaced {

View File

@@ -240,6 +240,10 @@ func (h *HUOBI) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exc
func (h *HUOBI) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
accountID, err := strconv.ParseInt(clientID, 10, 64)
if err != nil {
return submitOrderResponse, err
}
var formattedType SpotNewOrderRequestParamsType
var params = SpotNewOrderRequestParams{
Amount: amount,

View File

@@ -399,7 +399,11 @@ func TestSubmitOrder(t *testing.T) {
FirstCurrency: symbol.BTC,
SecondCurrency: symbol.USDT,
}
accounts, err := h.GetAccounts()
if err != nil {
t.Errorf("Failed to get accounts. Err: %s", err)
}
response, err := h.SubmitOrder(p, exchange.Buy, exchange.Limit, 1, 10, strconv.FormatInt(accounts[0].ID, 10))
if err != nil || !response.IsOrderPlaced {

View File

@@ -205,6 +205,10 @@ func (h *HUOBIHADAX) GetExchangeHistory(p pair.CurrencyPair, assetType string) (
func (h *HUOBIHADAX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
accountID, err := strconv.ParseInt(clientID, 0, 64)
if err != nil {
return submitOrderResponse, err
}
var formattedType SpotNewOrderRequestParamsType
var params = SpotNewOrderRequestParams{
Amount: amount,

View File

@@ -1190,7 +1190,7 @@ func getWithdrawalFee(currency string) float64 {
return WithdrawalFees[currency]
}
// GetBalance returns the full balance accross all wallets
// GetBalance returns the full balance across all wallets
func (o *OKEX) GetBalance() ([]FullBalance, error) {
var resp Balance
var balances []FullBalance

View File

@@ -274,7 +274,7 @@
"baseCurrencies": "JPY",
"assetTypes": "SPOT",
"supportsAutoPairUpdates": false,
"pairsLastUpdated": 1543208659,
"pairsLastUpdated": 1545884823,
"configCurrencyPairFormat": {
"uppercase": true,
"delimiter": "_"
@@ -885,7 +885,7 @@
"baseCurrencies": "USD,SGD",
"assetTypes": "SPOT",
"supportsAutoPairUpdates": false,
"pairsLastUpdated": 1543208659,
"pairsLastUpdated": 1545884823,
"configCurrencyPairFormat": {
"uppercase": true
},
@@ -1086,7 +1086,7 @@
"baseCurrencies": "CNY",
"assetTypes": "SPOT",
"supportsAutoPairUpdates": false,
"pairsLastUpdated": 1543207521,
"pairsLastUpdated": 1545884823,
"configCurrencyPairFormat": {
"uppercase": true
},
@@ -1250,7 +1250,7 @@
"baseCurrencies": "USD",
"assetTypes": "SPOT",
"supportsAutoPairUpdates": false,
"pairsLastUpdated": 1543207521,
"pairsLastUpdated": 1545884823,
"configCurrencyPairFormat": {
"uppercase": true,
"delimiter": "_"