mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
* reworked request struct and exchange response started work on validation system * removed import cycle until work around * Added intial withdraw support via CLI added * Added Crypto command to gctcli * moved var declartion to single line * Test updates for binance and anx * All exchange tests have been updated test coverage added to validate * First pass at adding withdrawl select from database * started adding basic lru cache system * Added basic LRU cache including Add Get Remove Contains ContainsOrAdd Clear * wording changes on comments * removed exported var's in strut as they are not required * Added README * README updates * corrected ID on commands * rm line :D * merged in origin/cache * linter fixes (gofmt) * Added basic cache lookup to events * swapped to mutex over rwmutex updated comments * unexported getNewest & getOldest * unexported getNewest & getOldest * Updated comments and cited references in source * updated comments * WIP * Migrated exchange WithdrawFiat wrapper to new struct response * Migrated exchange WithdrawFiat wrapper to new struct response * started work on bank management * Added exchange level banking details back with migration to banking package * Removed broken tests for now * Added validation to bank accounts * removed duplicate bank details from withdraw struct * Test coverage increased * gofmt * merged upstream/master with clean up * First pass at adding command line linking to gctcli * added validation for crypto address, added gctcli support to retreive previous withdrawal requests * general cleanup * general cleanup * reordered imports * Increased test coverage moved to database sublogger * Pass incorrect currency no longer return error from c.CheckBankAccountConfig * remove TestMain() for now as other tests in this package will need to be reworked * Happy little race car * Reverted to upstream tests * Added test covarege for validation method, corrected response on cli protobuf * query clean up and removal of duplicated code * cleaned up queries into singlem ethod increased test coverage * Migrated international fund withdraw to new exchange response and added cache size override * Migrated international fund withdraw to new exchange response and added cache size override * Extended gctcli commands * lowered default cache to 25 * small code clean up * added get by date method * add returned error * cli commands cleaing return error on nil results to fix out of bounds * merged write & read helpers into one for test coverage and increased engine/withdraw test coverage * gofmt * Added test coverage for valid ID * removed unused param * converted to use timestamp package from protobuf * gofmt * use built in RFC3339 timestamp * remove setting of CreatedAt & UpdatedAt and allow ORm to take care of it * also use ptype on byid * code flow improvements * remove inverse conditional check and linters run * removed test data * removed comment * removed comment * also write failures to database for auditing * converted to use default time for start & end * Default to time.Now() minus 30 days * Default to time.Now() minus 30 days * small code clean up * fixed missing semicolon on migrations, code clean up * updated sqlite migrations * Added additonal check for exchange level bank account if global is not found * case sensativity fix for currency names * use correct compare * test coverage fixed * removed space * return pointer to banking.Account * return pointer to banking.Account * added else check back to validate() * Added empty string as default to migration over NULL due to retrivial of data
194 lines
4.8 KiB
Go
194 lines
4.8 KiB
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"math/rand"
|
|
"sync"
|
|
"time"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/common"
|
|
"github.com/thrasher-corp/gocryptotrader/currency"
|
|
"github.com/thrasher-corp/gocryptotrader/engine"
|
|
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
|
)
|
|
|
|
const (
|
|
totalWrappers = 20
|
|
)
|
|
|
|
func main() {
|
|
var err error
|
|
engine.Bot, err = engine.New()
|
|
if err != nil {
|
|
log.Fatalf("Failed to initialise engine. Err: %s", err)
|
|
}
|
|
|
|
engine.Bot.Settings = engine.Settings{
|
|
DisableExchangeAutoPairUpdates: true,
|
|
}
|
|
|
|
log.Printf("Loading exchanges..")
|
|
var wg sync.WaitGroup
|
|
for x := range exchange.Exchanges {
|
|
name := exchange.Exchanges[x]
|
|
err := engine.LoadExchange(name, true, &wg)
|
|
if err != nil {
|
|
log.Printf("Failed to load exchange %s. Err: %s", name, err)
|
|
continue
|
|
}
|
|
}
|
|
wg.Wait()
|
|
log.Println("Done.")
|
|
|
|
log.Printf("Testing exchange wrappers..")
|
|
results := make(map[string][]string)
|
|
wg = sync.WaitGroup{}
|
|
exchanges := engine.GetExchanges()
|
|
for x := range exchanges {
|
|
wg.Add(1)
|
|
go func(num int) {
|
|
name := exchanges[num].GetName()
|
|
results[name] = testWrappers(exchanges[num])
|
|
wg.Done()
|
|
}(x)
|
|
}
|
|
wg.Wait()
|
|
log.Println("Done.")
|
|
|
|
log.Println()
|
|
for name, funcs := range results {
|
|
pct := float64(totalWrappers-len(funcs)) / float64(totalWrappers) * 100
|
|
log.Printf("Exchange %s wrapper coverage [%d/%d - %.2f%%] | Total missing: %d", name, totalWrappers-len(funcs), totalWrappers, pct, len(funcs))
|
|
log.Printf("\t Wrappers not implemented:")
|
|
|
|
for x := range funcs {
|
|
log.Printf("\t - %s", funcs[x])
|
|
}
|
|
log.Println()
|
|
}
|
|
}
|
|
|
|
func testWrappers(e exchange.IBotExchange) []string {
|
|
p := currency.NewPair(currency.BTC, currency.USD)
|
|
assetType := asset.Spot
|
|
if !e.SupportsAsset(assetType) {
|
|
assets := e.GetAssetTypes()
|
|
rand.Seed(time.Now().Unix())
|
|
assetType = assets[rand.Intn(len(assets))]
|
|
}
|
|
|
|
var funcs []string
|
|
|
|
_, err := e.FetchTicker(p, assetType)
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "FetchTicker")
|
|
}
|
|
|
|
_, err = e.UpdateTicker(p, assetType)
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "UpdateTicker")
|
|
}
|
|
|
|
_, err = e.FetchOrderbook(p, assetType)
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "FetchOrderbook")
|
|
}
|
|
|
|
_, err = e.UpdateOrderbook(p, assetType)
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "UpdateOrderbook")
|
|
}
|
|
|
|
_, err = e.FetchTradablePairs(asset.Spot)
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "FetchTradablePairs")
|
|
}
|
|
|
|
err = e.UpdateTradablePairs(false)
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "UpdateTradablePairs")
|
|
}
|
|
|
|
_, err = e.FetchAccountInfo()
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "GetAccountInfo")
|
|
}
|
|
|
|
_, err = e.GetExchangeHistory(p, assetType)
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "GetExchangeHistory")
|
|
}
|
|
|
|
_, err = e.GetFundingHistory()
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "GetFundingHistory")
|
|
}
|
|
|
|
s := &order.Submit{
|
|
Pair: p,
|
|
OrderSide: order.Buy,
|
|
OrderType: order.Limit,
|
|
Amount: 1000000,
|
|
Price: 10000000000,
|
|
ClientID: "meow",
|
|
}
|
|
_, err = e.SubmitOrder(s)
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "SubmitOrder")
|
|
}
|
|
|
|
_, err = e.ModifyOrder(&order.Modify{})
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "ModifyOrder")
|
|
}
|
|
|
|
err = e.CancelOrder(&order.Cancel{})
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "CancelOrder")
|
|
}
|
|
|
|
_, err = e.CancelAllOrders(&order.Cancel{})
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "CancelAllOrders")
|
|
}
|
|
|
|
_, err = e.GetOrderInfo("1")
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "GetOrderInfo")
|
|
}
|
|
|
|
_, err = e.GetOrderHistory(&order.GetOrdersRequest{})
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "GetOrderHistory")
|
|
}
|
|
|
|
_, err = e.GetActiveOrders(&order.GetOrdersRequest{})
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "GetActiveOrders")
|
|
}
|
|
|
|
_, err = e.GetDepositAddress(currency.BTC, "")
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "GetDepositAddress")
|
|
}
|
|
|
|
_, err = e.WithdrawCryptocurrencyFunds(&withdraw.Request{})
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "WithdrawCryptocurrencyFunds")
|
|
}
|
|
|
|
_, err = e.WithdrawFiatFunds(&withdraw.Request{})
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "WithdrawFiatFunds")
|
|
}
|
|
_, err = e.WithdrawFiatFundsToInternationalBank(&withdraw.Request{})
|
|
if err == common.ErrNotYetImplemented {
|
|
funcs = append(funcs, "WithdrawFiatFundsToInternationalBank")
|
|
}
|
|
|
|
return funcs
|
|
}
|