mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-19 23:16:48 +00:00
* Improved error message when no config is set on startup * Change inccorect error wording * bump Bitfinex websocket orderbook return length to max * temporary fix of incorrect orderbook updates, limit to bid and ask len of 100, will be extended later if needed * Fixed issue in binance websocket that appended 0 volume bid/ask items * Fix panic when unmarshalling an empty pair from config * Add get pair asset method for exchange base Fix Bitmex orderbook stream Unbuffer Bitmex orderbook stream * force syncer to update ticker instead of fetch, which allows a stream * Fix websocket last price for coinbasepro * fix websocket ticker for coinut * Fix websocket orderbook stream Huobi * increase orderbook depth REST for Huobi * Fix websocket support and ensure data integrity * Fix time parsing issue after error checks * check error, only process enabled currency pairs, signal websocket data processing * expanded websocket functionality for okgroup * Add logic to not process zero length slice for orderbooks * fix websocket ticker only updating enabled and individual book updates * ZB fixes to order submission/retrieval/cancellation w/ general fixes * Quiet unnecessary warning * updated config entry values for REST and websocket (initial hack until I come up with a better solution for asset types) * Ch GetName function to field access modifyer & rm useless code * Add in error I missed * Nits addressed * some more fixes * Turned kraken default websocket to true and some small changes * fixes linter issues * Ensured okgroup books and sent update through to datahandler. Zb update as well. * Add test case to get asset type from pair * Add test for pairs unmarshal * Add testing and addressed nits * FIX linter issue * Addressed Gees nits * Thanks glorious spotter * more nitorinos * Addres even more nits * Add stringerino 4000 * Fix for panic cause by sort slice out of range, also nits addressed * fix linter issues * Changed from function to field access * Changed from function to field access * fix for orderbook update panic, removes quick fix - caused by sync item fetching through same protocol * Add new test and update random generator * pass in invalid string to future ob fetching, due to futures contract expire and a http 400 error is returned
79 lines
1.9 KiB
Go
79 lines
1.9 KiB
Go
package okgroup
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/common"
|
|
"github.com/thrasher-corp/gocryptotrader/config"
|
|
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
|
|
)
|
|
|
|
const (
|
|
apiKey = ""
|
|
apiSecret = ""
|
|
|
|
testAPIURL = "https://www.okex.com/api/"
|
|
testAPIVersion = "/v3/"
|
|
)
|
|
|
|
var o OKGroup
|
|
|
|
func TestMain(m *testing.M) {
|
|
cfg := config.GetConfig()
|
|
err := cfg.LoadConfig("../../testdata/configtest.json", true)
|
|
if err != nil {
|
|
log.Fatal("okgroup load config error", err)
|
|
}
|
|
okgroup, err := cfg.GetExchangeConfig("Okex")
|
|
if err != nil {
|
|
log.Fatal("okgroup Setup() init error", err)
|
|
}
|
|
|
|
okgroup.API.AuthenticatedSupport = true
|
|
okgroup.API.Credentials.Key = apiKey
|
|
okgroup.API.Credentials.Secret = apiSecret
|
|
o.API.Endpoints.URL = testAPIURL
|
|
o.APIVersion = testAPIVersion
|
|
|
|
o.Requester = request.New("okgroup_test_things",
|
|
request.NewRateLimit(time.Second, 10),
|
|
request.NewRateLimit(time.Second, 10),
|
|
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout),
|
|
)
|
|
o.Websocket = wshandler.New()
|
|
|
|
err = o.Setup(okgroup)
|
|
if err != nil {
|
|
log.Fatal("okgroup setup error", err)
|
|
}
|
|
os.Exit(m.Run())
|
|
}
|
|
|
|
func TestGetOrderbook(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := o.GetOrderBook(GetOrderBookRequest{InstrumentID: "BTC-USDT"},
|
|
asset.Spot)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
// futures expire and break test, will need to mock this in the future
|
|
_, err = o.GetOrderBook(GetOrderBookRequest{InstrumentID: "Payload"},
|
|
asset.Futures)
|
|
if err == nil {
|
|
t.Error("error cannot be nil")
|
|
}
|
|
|
|
_, err = o.GetOrderBook(GetOrderBookRequest{InstrumentID: "BTC-USD-SWAP"},
|
|
asset.PerpetualSwap)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|