mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 23:16:54 +00:00
Engine QA (#381)
* 1) Update Dockerfile/docker-compose.yml 2) Remove inline strings for buy/sell/test pairs 3) Remove dangerous order submission values 4) Fix consistency with audit_events (all other spec files use CamelCase) 5) Update web websocket endpoint 6) Fix main param set (and induce dryrun mode on specific command line params) * Engine QA Link up exchange syncer to cmd params, disarm market selling bombs and fix OKEX endpoints * Fix linter issue after merge * Engine QA changes Template updates Wrapper code cleanup Disarmed order bombs Documentation updates * Daily engine QA Bitstamp improvements Spelling mistakes Add Coinbene exchange to support list Protect API authenticated calls for Coinbene/LBank * Engine QA changes Fix exchange_wrapper_coverage tool Add SupportsAsset to exchange interface Fix inline string usage and add BCH withdrawal support * Engine QA Fix Bitstamp types Inform user of errors when parsing time accross the codebase Change time parsing warnings to errors (as they are) Update markdown docs [with linter fixes] * Engine QA changes 1) Add test for dryrunParamInteraction 2) Disarm OKCoin/OKEX bombs if someone accidently sets canManipulateRealOrders to true and runs all package tests 3) Actually check exchange setup errors for BTSE and Coinbene, plus address this in the wrapper template 4) Hardcode missing/non-retrievable contributors and bump the contributors 5) Convert numbers/strings to meaningful types in Bitstamp and OKEX 6) If WS is supported for the exchange wrapper template, preset authWebsocketSupport var * Fix the shadow people * Link the SyncContinuously paramerino * Also show SyncContinuously in engine.PrintSettings * Address nitterinos and use correct filepath for logs * Bitstamp: Extract ALL THE APM * Fix additional nitterinos * Fix time parsing error for Bittrex
This commit is contained in:
@@ -42,6 +42,7 @@ const (
|
||||
btsePendingOrders = "pending"
|
||||
btseDeleteOrder = "deleteOrder"
|
||||
btseFills = "fills"
|
||||
btseTimeLayout = "2006-01-02 15:04:04"
|
||||
)
|
||||
|
||||
// GetMarketsSummary stores market summary data
|
||||
@@ -238,7 +239,7 @@ func (b *BTSE) SendAuthenticatedHTTPRequest(method, endpoint string, req map[str
|
||||
b.Name, method, path, string(payload))
|
||||
}
|
||||
return b.SendPayload(method,
|
||||
btseAPIURL+path,
|
||||
b.API.Endpoints.URL+path,
|
||||
headers,
|
||||
body,
|
||||
&result,
|
||||
@@ -320,7 +321,6 @@ func calculateTradingFee(isMaker bool) float64 {
|
||||
return fee
|
||||
}
|
||||
|
||||
func parseOrderTime(timeStr string) time.Time {
|
||||
t, _ := time.Parse("2006-01-02 15:04:04", timeStr)
|
||||
return t
|
||||
func parseOrderTime(timeStr string) (time.Time, error) {
|
||||
return time.Parse(btseTimeLayout, timeStr)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ const (
|
||||
apiKey = ""
|
||||
apiSecret = ""
|
||||
canManipulateRealOrders = false
|
||||
testPair = "BTC-USD"
|
||||
)
|
||||
|
||||
var b BTSE
|
||||
@@ -37,7 +38,11 @@ func TestMain(m *testing.M) {
|
||||
btseConfig.API.Credentials.Key = apiKey
|
||||
btseConfig.API.Credentials.Secret = apiSecret
|
||||
|
||||
b.Setup(btseConfig)
|
||||
err = b.Setup(btseConfig)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
@@ -63,7 +68,7 @@ func TestGetMarkets(t *testing.T) {
|
||||
|
||||
func TestFetchOrderBook(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.FetchOrderBook("BTC-USD")
|
||||
_, err := b.FetchOrderBook(testPair)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -71,7 +76,7 @@ func TestFetchOrderBook(t *testing.T) {
|
||||
|
||||
func TestGetTrades(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetTrades("BTC-USD")
|
||||
_, err := b.GetTrades(testPair)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -79,7 +84,7 @@ func TestGetTrades(t *testing.T) {
|
||||
|
||||
func TestGetTicker(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetTicker("BTC-USD")
|
||||
_, err := b.GetTicker(testPair)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -87,7 +92,7 @@ func TestGetTicker(t *testing.T) {
|
||||
|
||||
func TestGetMarketStatistics(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetMarketStatistics("BTC-USD")
|
||||
_, err := b.GetMarketStatistics(testPair)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -117,7 +122,7 @@ func TestGetFills(t *testing.T) {
|
||||
if !areTestAPIKeysSet() {
|
||||
t.Skip("API keys not set, skipping test")
|
||||
}
|
||||
_, err := b.GetFills("", "BTC-USD", "", "", "", "")
|
||||
_, err := b.GetFills("", testPair, "", "", "", "")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -128,7 +133,13 @@ func TestCreateOrder(t *testing.T) {
|
||||
if !areTestAPIKeysSet() || !canManipulateRealOrders {
|
||||
t.Skip("skipping test, either api keys or manipulaterealorders isnt set correctly")
|
||||
}
|
||||
_, err := b.CreateOrder(0.1, 10000, "sell", "limit", "BTC-USD", "", "")
|
||||
_, err := b.CreateOrder(0.1,
|
||||
10000,
|
||||
order.Sell.String(),
|
||||
order.Limit.String(),
|
||||
testPair,
|
||||
"",
|
||||
"")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -266,9 +277,12 @@ func TestGetFee(t *testing.T) {
|
||||
|
||||
func TestParseOrderTime(t *testing.T) {
|
||||
expected := int64(1534794360)
|
||||
actual := parseOrderTime("2018-08-20 19:20:46").Unix()
|
||||
if expected != actual {
|
||||
t.Errorf("TestParseOrderTime expected: %d, got %d", expected, actual)
|
||||
actual, err := parseOrderTime("2018-08-20 19:20:46")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if expected != actual.Unix() {
|
||||
t.Errorf("TestParseOrderTime expected: %d, got %d", expected, actual.Unix())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,8 +103,8 @@ func (b *BTSE) WsHandleData() {
|
||||
b.Websocket.DataHandler <- err
|
||||
continue
|
||||
}
|
||||
var newOB orderbook.Base
|
||||
var price, amount float64
|
||||
var asks, bids []orderbook.Item
|
||||
for i := range t.Data.SellQuote {
|
||||
p := strings.Replace(t.Data.SellQuote[i].Price, ",", "", -1)
|
||||
price, err = strconv.ParseFloat(p, 64)
|
||||
@@ -118,7 +118,10 @@ func (b *BTSE) WsHandleData() {
|
||||
b.Websocket.DataHandler <- err
|
||||
continue
|
||||
}
|
||||
asks = append(asks, orderbook.Item{Price: price, Amount: amount})
|
||||
newOB.Asks = append(newOB.Asks, orderbook.Item{
|
||||
Price: price,
|
||||
Amount: amount,
|
||||
})
|
||||
}
|
||||
for j := range t.Data.BuyQuote {
|
||||
p := strings.Replace(t.Data.BuyQuote[j].Price, ",", "", -1)
|
||||
@@ -133,11 +136,11 @@ func (b *BTSE) WsHandleData() {
|
||||
b.Websocket.DataHandler <- err
|
||||
continue
|
||||
}
|
||||
bids = append(bids, orderbook.Item{Price: price, Amount: amount})
|
||||
newOB.Bids = append(newOB.Bids, orderbook.Item{
|
||||
Price: price,
|
||||
Amount: amount,
|
||||
})
|
||||
}
|
||||
var newOB orderbook.Base
|
||||
newOB.Asks = asks
|
||||
newOB.Bids = bids
|
||||
newOB.AssetType = asset.Spot
|
||||
newOB.Pair = currency.NewPairFromString(t.Topic[strings.Index(t.Topic, ":")+1 : strings.Index(t.Topic, "_")])
|
||||
newOB.ExchangeName = b.Name
|
||||
|
||||
@@ -450,7 +450,11 @@ func (b *BTSE) GetOrderInfo(orderID string) (order.Detail, error) {
|
||||
od.Exchange = b.Name
|
||||
od.Amount = o[i].Amount
|
||||
od.ID = o[i].ID
|
||||
od.OrderDate = parseOrderTime(o[i].CreatedAt)
|
||||
od.OrderDate, err = parseOrderTime(o[i].CreatedAt)
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys,
|
||||
"%s GetOrderInfo unable to parse time: %s\n", b.Name, err)
|
||||
}
|
||||
od.OrderSide = side
|
||||
od.OrderType = order.Type(strings.ToUpper(o[i].Type))
|
||||
od.Price = o[i].Price
|
||||
@@ -464,7 +468,11 @@ func (b *BTSE) GetOrderInfo(orderID string) (order.Detail, error) {
|
||||
}
|
||||
|
||||
for i := range fills {
|
||||
createdAt, _ := time.Parse(time.RFC3339, fills[i].CreatedAt)
|
||||
createdAt, err := parseOrderTime(fills[i].CreatedAt)
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys,
|
||||
"%s GetOrderInfo unable to parse time: %s\n", b.Name, err)
|
||||
}
|
||||
od.Trades = append(od.Trades, order.TradeHistory{
|
||||
Timestamp: createdAt,
|
||||
TID: fills[i].ID,
|
||||
@@ -521,13 +529,21 @@ func (b *BTSE) GetActiveOrders(req *order.GetOrdersRequest) ([]order.Detail, err
|
||||
side = order.Sell
|
||||
}
|
||||
|
||||
tm, err := parseOrderTime(resp[i].CreatedAt)
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys,
|
||||
"%s GetActiveOrders unable to parse time: %s\n",
|
||||
b.Name,
|
||||
err)
|
||||
}
|
||||
|
||||
openOrder := order.Detail{
|
||||
CurrencyPair: currency.NewPairDelimiter(resp[i].Symbol,
|
||||
b.GetPairFormat(asset.Spot, false).Delimiter),
|
||||
Exchange: b.Name,
|
||||
Amount: resp[i].Amount,
|
||||
ID: resp[i].ID,
|
||||
OrderDate: parseOrderTime(resp[i].CreatedAt),
|
||||
OrderDate: tm,
|
||||
OrderSide: side,
|
||||
OrderType: order.Type(strings.ToUpper(resp[i].Type)),
|
||||
Price: resp[i].Price,
|
||||
@@ -544,7 +560,13 @@ func (b *BTSE) GetActiveOrders(req *order.GetOrdersRequest) ([]order.Detail, err
|
||||
}
|
||||
|
||||
for i := range fills {
|
||||
createdAt, _ := time.Parse(time.RFC3339, fills[i].CreatedAt)
|
||||
createdAt, err := parseOrderTime(fills[i].CreatedAt)
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys,
|
||||
"%s GetActiveOrders unable to parse time: %s\n",
|
||||
b.Name,
|
||||
err)
|
||||
}
|
||||
openOrder.Trades = append(openOrder.Trades, order.TradeHistory{
|
||||
Timestamp: createdAt,
|
||||
TID: fills[i].ID,
|
||||
|
||||
Reference in New Issue
Block a user