mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Merge branch 'master' into engine
This commit is contained in:
@@ -25,7 +25,7 @@ environment:
|
||||
PSQL_DBNAME: gct_dev_ci
|
||||
PSQL_SSLMODE: disable
|
||||
|
||||
stack: go 1.12.3
|
||||
stack: go 1.13.x
|
||||
|
||||
services:
|
||||
- postgresql96
|
||||
@@ -48,7 +48,7 @@ before_test:
|
||||
|
||||
test_script:
|
||||
# test back-end
|
||||
- go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.18.0
|
||||
- go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.20.1
|
||||
- '%GOPATH%\bin\golangci-lint.exe run --verbose'
|
||||
- ps: >-
|
||||
if($env:APPVEYOR_SCHEDULED_BUILD -eq 'true') {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
run:
|
||||
deadline: 1m0s
|
||||
timeout: 1m0s
|
||||
issues-exit-code: 1
|
||||
tests: true
|
||||
skip-dirs:
|
||||
@@ -11,41 +11,46 @@ linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
# defaults
|
||||
- govet
|
||||
# - errcheck
|
||||
- staticcheck
|
||||
# - unused
|
||||
- gosimple
|
||||
- structcheck
|
||||
# - varcheck
|
||||
- ineffassign
|
||||
# - deadcode
|
||||
# - errcheck
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- typecheck
|
||||
# - unused
|
||||
# - varcheck
|
||||
|
||||
# disabled by default linters
|
||||
# - bodyclose
|
||||
- golint
|
||||
- stylecheck
|
||||
- gosec
|
||||
# - interfacer
|
||||
- unconvert
|
||||
- depguard
|
||||
- dogsled
|
||||
# - dupl
|
||||
# - funlen
|
||||
# - gochecknoglobals
|
||||
# - gochecknoinits
|
||||
# - gocognit
|
||||
- goconst
|
||||
- gocritic
|
||||
# - gocyclo
|
||||
# - godox
|
||||
- gofmt
|
||||
- goimports
|
||||
# - maligned
|
||||
- depguard
|
||||
- misspell
|
||||
- golint
|
||||
- gosec
|
||||
# - interfacer
|
||||
# - lll
|
||||
- unparam
|
||||
# - maligned
|
||||
- misspell
|
||||
- nakedret
|
||||
# - prealloc
|
||||
- scopelint
|
||||
- gocritic
|
||||
# - gochecknoinits
|
||||
# - gochecknoglobals
|
||||
# - funlen
|
||||
- stylecheck
|
||||
- unconvert
|
||||
- unparam
|
||||
- whitespace
|
||||
# - wsl
|
||||
|
||||
linters-settings:
|
||||
govet:
|
||||
@@ -76,7 +81,4 @@ issues:
|
||||
exclude-rules:
|
||||
- text: "weak cryptographic primitive"
|
||||
linters:
|
||||
- gosec
|
||||
|
||||
service:
|
||||
golangci-lint-version: 1.16.x
|
||||
- gosec
|
||||
2
Makefile
2
Makefile
@@ -1,6 +1,6 @@
|
||||
LDFLAGS = -ldflags "-w -s"
|
||||
GCTPKG = github.com/thrasher-corp/gocryptotrader
|
||||
LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.18.0
|
||||
LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.20.1
|
||||
LINTBIN = $(GOPATH)/bin/golangci-lint
|
||||
GCTLISTENPORT=9050
|
||||
GCTPROFILERLISTENPORT=8085
|
||||
|
||||
@@ -347,7 +347,6 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
|
||||
if err != nil {
|
||||
msg = err.Error()
|
||||
responseContainer.ErrorCount++
|
||||
|
||||
}
|
||||
responseContainer.EndpointResponses = append(responseContainer.EndpointResponses, EndpointResponse{
|
||||
SentParams: jsonifyInterface([]interface{}{p, assetTypes[i]}),
|
||||
@@ -362,7 +361,6 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
|
||||
if err != nil {
|
||||
msg = err.Error()
|
||||
responseContainer.ErrorCount++
|
||||
|
||||
}
|
||||
responseContainer.EndpointResponses = append(responseContainer.EndpointResponses, EndpointResponse{
|
||||
SentParams: jsonifyInterface([]interface{}{p, assetTypes[i]}),
|
||||
|
||||
@@ -98,7 +98,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
} else {
|
||||
var pubKeyData []byte
|
||||
pubKeyData, err = ioutil.ReadFile("publickey.pem")
|
||||
|
||||
@@ -80,7 +80,6 @@ func TestGetMD5(t *testing.T) {
|
||||
t.Errorf("Expected '%s'. Actual '%s'",
|
||||
expectedOutput, []byte(actualStr))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestGetSHA512(t *testing.T) {
|
||||
@@ -166,7 +165,6 @@ func TestGetHMAC(t *testing.T) {
|
||||
expectedmd5, md5,
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestSha1Tohex(t *testing.T) {
|
||||
|
||||
@@ -219,34 +219,28 @@ func (s *Slack) WebsocketReader() {
|
||||
}
|
||||
|
||||
switch data.Type {
|
||||
|
||||
case "error":
|
||||
err = s.handleErrorResponse(data)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
case "hello":
|
||||
s.handleHelloResponse()
|
||||
|
||||
case "reconnect_url":
|
||||
err = s.handleReconnectResponse(resp)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
case "presence_change":
|
||||
err = s.handlePresenceChange(resp)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
case "message":
|
||||
err = s.handleMessageResponse(resp, data)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
case "pong":
|
||||
if s.Verbose {
|
||||
log.Debugln(log.CommunicationMgr, "Slack: Pong received from server")
|
||||
|
||||
@@ -143,7 +143,6 @@ func TestGetUsernameByID(t *testing.T) {
|
||||
if username != "cranktakular" {
|
||||
t.Error("slack GetUsernameByID() error")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestGetIDByName(t *testing.T) {
|
||||
@@ -178,7 +177,6 @@ func TestGetGroupIDByName(t *testing.T) {
|
||||
t.Errorf("slack GetGroupIDByName() Expected '11223344' Actual '%s' Error: %s",
|
||||
id, err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestGetChannelIDByName(t *testing.T) {
|
||||
|
||||
@@ -79,7 +79,6 @@ func (c *Config) GetClientBankAccounts(exchangeName, targetCurrency string) (Ban
|
||||
c.BankAccounts[x].SupportedExchanges == "ALL") &&
|
||||
strings.Contains(c.BankAccounts[x].SupportedCurrencies, targetCurrency) {
|
||||
return c.BankAccounts[x], nil
|
||||
|
||||
}
|
||||
}
|
||||
return BankAccount{}, fmt.Errorf("client banking details not found for %s and currency %s",
|
||||
@@ -255,7 +254,6 @@ func (c *Config) CheckCommunicationsConfig() {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if c.Communications.SMSGlobalConfig.From == "" {
|
||||
c.Communications.SMSGlobalConfig.From = c.Name
|
||||
@@ -1581,7 +1579,6 @@ func (c *Config) CheckRemoteControlConfig() {
|
||||
// Then flush the old webserver settings
|
||||
c.Webserver = nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// CheckConfig checks all config settings
|
||||
|
||||
@@ -195,7 +195,6 @@ func TestCheckClientBankAccounts(t *testing.T) {
|
||||
if !cfg.BankAccounts[0].Enabled {
|
||||
t.Error("unexpected result")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestPurgeExchangeCredentials(t *testing.T) {
|
||||
|
||||
@@ -358,7 +358,7 @@ var (
|
||||
HBZ = NewCode("HBZ")
|
||||
USDT_ETH = NewCode("USDT_ETH") // nolint: golint,stylecheck
|
||||
QTUM_ETH = NewCode("QTUM_ETH") // nolint: golint
|
||||
BTM_ETH = NewCode("BTM_ETH") // nolint: golint
|
||||
BTM_ETH = NewCode("BTM_ETH") // nolint: golint,stylecheck
|
||||
FIL = NewCode("FIL")
|
||||
STX = NewCode("STX")
|
||||
BOT = NewCode("BOT")
|
||||
@@ -371,7 +371,7 @@ var (
|
||||
GOD = NewCode("GOD")
|
||||
SMT = NewCode("SMT")
|
||||
BTF = NewCode("BTF")
|
||||
NAS_ETH = NewCode("NAS_ETH") // nolint: golint
|
||||
NAS_ETH = NewCode("NAS_ETH") // nolint: golint,stylecheck
|
||||
TSL = NewCode("TSL")
|
||||
BIFI = NewCode("BIFI")
|
||||
BNTY = NewCode("BNTY")
|
||||
@@ -397,7 +397,7 @@ var (
|
||||
MOBI = NewCode("MOBI")
|
||||
LEDU = NewCode("LEDU")
|
||||
DBC = NewCode("DBC")
|
||||
MKR_OLD = NewCode("MKR_OLD") // nolint: golint
|
||||
MKR_OLD = NewCode("MKR_OLD") // nolint: golint,stylecheck
|
||||
DPY = NewCode("DPY")
|
||||
BCDN = NewCode("BCDN")
|
||||
EOSDAC = NewCode("EOSDAC") // nolint: golint
|
||||
@@ -406,7 +406,7 @@ var (
|
||||
PPS = NewCode("PPS")
|
||||
BOE = NewCode("BOE")
|
||||
MEDX = NewCode("MEDX")
|
||||
SMT_ETH = NewCode("SMT_ETH") // nolint: golint
|
||||
SMT_ETH = NewCode("SMT_ETH") // nolint: golint,stylecheck
|
||||
CS = NewCode("CS")
|
||||
MAN = NewCode("MAN")
|
||||
REM = NewCode("REM")
|
||||
@@ -426,7 +426,7 @@ var (
|
||||
SWTH = NewCode("SWTH")
|
||||
NKN = NewCode("NKN")
|
||||
SOUL = NewCode("SOUL")
|
||||
GALA_NEO = NewCode("GALA_NEO") // nolint: golint
|
||||
GALA_NEO = NewCode("GALA_NEO") // nolint: golint,stylecheck
|
||||
LRN = NewCode("LRN")
|
||||
GSE = NewCode("GSE")
|
||||
RATING = NewCode("RATING")
|
||||
@@ -1651,5 +1651,5 @@ var (
|
||||
YER = NewCode("YER")
|
||||
ZWD = NewCode("ZWD")
|
||||
XETH = NewCode("XETH")
|
||||
FX_BTC = NewCode("FX_BTC") // nolint: golint
|
||||
FX_BTC = NewCode("FX_BTC") // nolint: golint,stylecheck
|
||||
)
|
||||
|
||||
@@ -87,7 +87,6 @@ func TestDelete(t *testing.T) {
|
||||
if p.Get(asset.Spot) != nil {
|
||||
t.Error("Delete should have deleted AssetTypeSpot")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestGetPairs(t *testing.T) {
|
||||
|
||||
@@ -323,7 +323,6 @@ func (s *Storage) WriteCurrencyDataToFile(path string, mainUpdate bool) error {
|
||||
|
||||
// LoadFileCurrencyData loads currencies into the currency codes
|
||||
func (s *Storage) LoadFileCurrencyData(f *File) error {
|
||||
|
||||
for i := range f.Contracts {
|
||||
err := s.currencyCodes.LoadItem(&f.Contracts[i])
|
||||
if err != nil {
|
||||
|
||||
@@ -17,5 +17,4 @@ func TestGetSymbolByCurrencyName(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Errorf("TestGetSymbolByCurrencyNam returned nil on non-existent currency")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -298,7 +298,6 @@ func SetupExchanges() {
|
||||
continue
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
if !exch.Enabled && !Bot.Settings.EnableAllExchanges {
|
||||
log.Debugf(log.ExchangeSys, "%s: Exchange support: Disabled\n", exch.Name)
|
||||
|
||||
@@ -519,11 +519,9 @@ func SeedExchangeAccountInfo(data []exchange.AccountInfo) {
|
||||
|
||||
for _, exchangeData := range data {
|
||||
exchangeName := exchangeData.Exchange
|
||||
|
||||
var currencies []exchange.AccountCurrencyInfo
|
||||
for _, account := range exchangeData.Accounts {
|
||||
for _, info := range account.Currencies {
|
||||
|
||||
var update bool
|
||||
for i := range currencies {
|
||||
if info.CurrencyName == currencies[i].CurrencyName {
|
||||
@@ -566,19 +564,16 @@ func SeedExchangeAccountInfo(data []exchange.AccountInfo) {
|
||||
CoinType: currencyName,
|
||||
Balance: total,
|
||||
Description: portfolio.PortfolioAddressExchange})
|
||||
|
||||
} else {
|
||||
if total <= 0 {
|
||||
log.Debugf(log.PortfolioMgr, "Portfolio: Removing %s %s entry.\n",
|
||||
exchangeName,
|
||||
currencyName)
|
||||
|
||||
port.RemoveExchangeAddress(exchangeName, currencyName)
|
||||
} else {
|
||||
balance, ok := port.GetAddressBalance(exchangeName,
|
||||
portfolio.PortfolioAddressExchange,
|
||||
currencyName)
|
||||
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
@@ -588,7 +583,6 @@ func SeedExchangeAccountInfo(data []exchange.AccountInfo) {
|
||||
exchangeName,
|
||||
currencyName,
|
||||
total)
|
||||
|
||||
port.UpdateExchangeAddressBalance(exchangeName,
|
||||
currencyName,
|
||||
total)
|
||||
@@ -635,7 +629,6 @@ func GetCryptocurrenciesByExchange(exchangeName string, enabledExchangesOnly, en
|
||||
cryptocurrencies = append(cryptocurrencies, pairs[y].Quote.String())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return cryptocurrencies, nil
|
||||
}
|
||||
@@ -651,7 +644,6 @@ func GetCryptocurrencyDepositAddressesByExchange(exchName string) (map[string]st
|
||||
if !ok {
|
||||
return nil, ErrExchangeNotFound
|
||||
}
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
||||
@@ -666,14 +658,12 @@ func GetExchangeCryptocurrencyDepositAddress(exchName, accountID string, item cu
|
||||
if exch == nil {
|
||||
return "", ErrExchangeNotFound
|
||||
}
|
||||
|
||||
return exch.GetDepositAddress(item, accountID)
|
||||
}
|
||||
|
||||
// GetExchangeCryptocurrencyDepositAddresses obtains an exchanges deposit cryptocurrency list
|
||||
func GetExchangeCryptocurrencyDepositAddresses() map[string]map[string]string {
|
||||
result := make(map[string]map[string]string)
|
||||
|
||||
for x := range Bot.Exchanges {
|
||||
if !Bot.Exchanges[x].IsEnabled() {
|
||||
continue
|
||||
@@ -704,7 +694,6 @@ func GetExchangeCryptocurrencyDepositAddresses() map[string]map[string]string {
|
||||
}
|
||||
result[exchName] = cryptoAddr
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package engine
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
_ "net/http/pprof" // blank import required for pprof
|
||||
_ "net/http/pprof" // nolint: gosec
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -929,7 +929,6 @@ func (s *RPCServer) EnableExchangePair(ctx context.Context, r *gctrpc.ExchangePa
|
||||
err = GetExchangeByName(r.Exchange).GetBase().CurrencyPairs.EnablePair(
|
||||
asset.Item(r.AssetType), p)
|
||||
return &gctrpc.GenericExchangeNameResponse{}, err
|
||||
|
||||
}
|
||||
|
||||
// DisableExchangePair disables the specified pair on an exchange
|
||||
|
||||
@@ -463,7 +463,6 @@ func (e *ExchangeCurrencyPairSyncer) worker() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Start starts an exchange currency pair syncer
|
||||
|
||||
@@ -132,7 +132,6 @@ func (a *ANX) GetDataToken() (string, error) {
|
||||
// NewOrder sends a new order request to the exchange.
|
||||
func (a *ANX) NewOrder(orderType string, buy bool, tradedCurrency string, tradedCurrencyAmount float64, settlementCurrency string, settlementCurrencyAmount, limitPriceSettlement float64,
|
||||
replace bool, replaceUUID string, replaceIfActive bool) (string, error) {
|
||||
|
||||
req := make(map[string]interface{})
|
||||
var order Order
|
||||
order.OrderType = orderType
|
||||
|
||||
@@ -241,7 +241,6 @@ func TestGetFee(t *testing.T) {
|
||||
t.Errorf("GetFee() error. Expected: %f, Received: %f", float64(0), resp)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// CryptocurrencyWithdrawalFee Basic
|
||||
|
||||
@@ -243,7 +243,6 @@ func TestGetSymbols(t *testing.T) {
|
||||
"rrtusd",
|
||||
}
|
||||
if len(expectedCurrencies) <= len(symbols) {
|
||||
|
||||
for _, explicitSymbol := range expectedCurrencies {
|
||||
if common.StringDataCompare(expectedCurrencies, explicitSymbol) {
|
||||
break
|
||||
|
||||
@@ -203,7 +203,6 @@ func (b *Bitfinex) WsDataHandler() {
|
||||
if status == "OK" {
|
||||
b.Websocket.DataHandler <- eventData
|
||||
b.WsAddSubscriptionChannel(0, "account", "N/A")
|
||||
|
||||
} else if status == "fail" {
|
||||
b.Websocket.DataHandler <- fmt.Errorf("bitfinex.go error - Websocket unable to AUTH. Error code: %s",
|
||||
eventData["code"].(string))
|
||||
|
||||
@@ -187,7 +187,6 @@ func (b *Bitmex) wsHandleIncomingData() {
|
||||
|
||||
b.Websocket.DataHandler <- fmt.Errorf("%s websocket error: Unable to subscribe %s",
|
||||
b.Name, decodedResp.Subscribe)
|
||||
|
||||
} else if _, ok := quickCapture["table"]; ok {
|
||||
var decodedResp WebsocketMainResponse
|
||||
err := common.JSONDecode(resp.Raw, &decodedResp)
|
||||
|
||||
@@ -269,7 +269,6 @@ func (b *Bitstamp) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error
|
||||
feeBuilder.FeeType = exchange.OfflineTradeFee
|
||||
}
|
||||
return b.GetFee(feeBuilder)
|
||||
|
||||
}
|
||||
|
||||
// FetchOrderbook returns the orderbook for a currency pair
|
||||
|
||||
@@ -507,5 +507,4 @@ func (b *Bittrex) GetWithdrawalFee(c currency.Code) (float64, error) {
|
||||
// calculateTradingFee returns the fee for trading any currency on Bittrex
|
||||
func calculateTradingFee(price, amount float64) float64 {
|
||||
return 0.0025 * price * amount
|
||||
|
||||
}
|
||||
|
||||
@@ -435,7 +435,6 @@ func (b *Bittrex) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error)
|
||||
feeBuilder.FeeType = exchange.OfflineTradeFee
|
||||
}
|
||||
return b.GetFee(feeBuilder)
|
||||
|
||||
}
|
||||
|
||||
// GetActiveOrders retrieves any orders that are active/open
|
||||
|
||||
@@ -68,7 +68,6 @@ func (b *BTSE) GetTrades(symbol string) ([]Trade, error) {
|
||||
var t []Trade
|
||||
endpoint := fmt.Sprintf("%s/%s", btseTrades, symbol)
|
||||
return t, b.SendHTTPRequest(http.MethodGet, endpoint, &t)
|
||||
|
||||
}
|
||||
|
||||
// GetTicker returns the ticker for a specified symbol
|
||||
|
||||
@@ -121,7 +121,6 @@ func TestGetFills(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestCreateOrder(t *testing.T) {
|
||||
|
||||
@@ -114,7 +114,6 @@ func (b *BTSE) SetDefaults() {
|
||||
b.WebsocketResponseMaxLimit = exchange.DefaultWebsocketResponseMaxLimit
|
||||
b.WebsocketResponseCheckTimeout = exchange.DefaultWebsocketResponseCheckTimeout
|
||||
b.WebsocketOrderbookBufferLimit = exchange.DefaultWebsocketOrderbookBufferLimit
|
||||
|
||||
}
|
||||
|
||||
// Setup takes in the supplied exchange configuration details and sets params
|
||||
|
||||
@@ -368,12 +368,9 @@ func TestCalculateTradingFee(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFormatWithdrawPermissions(t *testing.T) {
|
||||
|
||||
c.SetDefaults()
|
||||
expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + " & " + exchange.AutoWithdrawFiatWithAPIPermissionText
|
||||
|
||||
withdrawPermissions := c.FormatWithdrawPermissions()
|
||||
|
||||
if withdrawPermissions != expectedResult {
|
||||
t.Errorf("Expected: %s, Received: %s", expectedResult, withdrawPermissions)
|
||||
}
|
||||
@@ -450,7 +447,6 @@ func TestSubmitOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCancelExchangeOrder(t *testing.T) {
|
||||
|
||||
c.SetDefaults()
|
||||
TestSetup(t)
|
||||
|
||||
@@ -477,7 +473,6 @@ func TestCancelExchangeOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
|
||||
c.SetDefaults()
|
||||
TestSetup(t)
|
||||
|
||||
|
||||
@@ -454,7 +454,7 @@ type WebsocketTicker struct {
|
||||
BestBid float64 `json:"best_bid,string"`
|
||||
BestAsk float64 `json:"best_ask,string"`
|
||||
Side string `json:"side"`
|
||||
Time time.Time `json:"time,string"`
|
||||
Time time.Time `json:"time"`
|
||||
TradeID int64 `json:"trade_id"`
|
||||
LastSize float64 `json:"last_size,string"`
|
||||
}
|
||||
|
||||
@@ -248,7 +248,6 @@ func TestGetFee(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFormatWithdrawPermissions(t *testing.T) {
|
||||
|
||||
c.SetDefaults()
|
||||
expectedResult := exchange.WithdrawCryptoViaWebsiteOnlyText + " & " + exchange.WithdrawFiatViaWebsiteOnlyText
|
||||
|
||||
@@ -323,7 +322,6 @@ func TestSubmitOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCancelExchangeOrder(t *testing.T) {
|
||||
|
||||
c.SetDefaults()
|
||||
TestSetup(t)
|
||||
|
||||
@@ -350,7 +348,6 @@ func TestCancelExchangeOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
|
||||
c.SetDefaults()
|
||||
TestSetup(t)
|
||||
|
||||
|
||||
@@ -103,7 +103,6 @@ func (c *COINUT) WsHandleData() {
|
||||
}
|
||||
c.wsProcessResponse(individualJSON)
|
||||
}
|
||||
|
||||
} else {
|
||||
var incoming wsResponse
|
||||
err = common.JSONDecode(resp.Raw, &incoming)
|
||||
@@ -114,7 +113,6 @@ func (c *COINUT) WsHandleData() {
|
||||
|
||||
c.wsProcessResponse(resp.Raw)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +356,6 @@ func (c *COINUT) UpdateTicker(p currency.Pair, assetType asset.Item) (ticker.Pri
|
||||
}
|
||||
|
||||
return ticker.GetTicker(c.Name, p, assetType)
|
||||
|
||||
}
|
||||
|
||||
// FetchTicker returns the ticker for a currency pair
|
||||
@@ -728,7 +727,6 @@ func (c *COINUT) GetOrderHistory(req *order.GetOrdersRequest) ([]order.Detail, e
|
||||
CurrencyPair: p,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
order.FilterOrdersByTickRange(&allOrders, req.StartTicks, req.EndTicks)
|
||||
|
||||
@@ -255,7 +255,6 @@ func TestGetFee(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFormatWithdrawPermissions(t *testing.T) {
|
||||
|
||||
e.SetDefaults()
|
||||
expectedResult := exchange.AutoWithdrawCryptoWithSetupText + " & " + exchange.NoFiatWithdrawalsText
|
||||
|
||||
@@ -335,7 +334,6 @@ func TestSubmitOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCancelExchangeOrder(t *testing.T) {
|
||||
|
||||
e.SetDefaults()
|
||||
TestSetup(t)
|
||||
if areTestAPIKeysSet() && !canManipulateRealOrders {
|
||||
@@ -361,7 +359,6 @@ func TestCancelExchangeOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCancelAllExchangeOrders(t *testing.T) {
|
||||
|
||||
e.SetDefaults()
|
||||
TestSetup(t)
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ type TradeHistory struct {
|
||||
|
||||
// ChartData contains chart data
|
||||
type ChartData struct {
|
||||
Timestamp time.Time `json:"timestamp,string"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
Max float64 `json:"max,string"` // Max price
|
||||
Min float64 `json:"min,string"` // Min price
|
||||
Open float64 `json:"open,string"` // Open price
|
||||
@@ -74,7 +74,7 @@ type ChartData struct {
|
||||
type Currencies struct {
|
||||
ID string `json:"id"` // Currency identifier.
|
||||
FullName string `json:"fullName"` // Currency full name
|
||||
Crypto bool `json:"crypto,boolean"` // Is currency belongs to blockchain (false for ICO and fiat, like EUR)
|
||||
Crypto bool `json:"crypto"` // Is currency belongs to blockchain (false for ICO and fiat, like EUR)
|
||||
PayinEnabled bool `json:"payinEnabled"` // Is allowed for deposit (false for ICO)
|
||||
PayinPaymentID bool `json:"payinPaymentId"` // Is required to provide additional information other than the address for deposit
|
||||
PayinConfirmations int64 `json:"payinConfirmations"` // Blocks confirmations count for deposit
|
||||
@@ -134,10 +134,10 @@ type Order struct {
|
||||
Quantity float64 `json:"quantity,string"` // Order quantity
|
||||
Price float64 `json:"price,string"` // Order price
|
||||
CumQuantity float64 `json:"cumQuantity,string"` // Cumulative executed quantity
|
||||
CreatedAt time.Time `json:"createdAt,string"`
|
||||
UpdatedAt time.Time `json:"updatedAt,string"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
StopPrice float64 `json:"stopPrice,string"`
|
||||
ExpireTime time.Time `json:"expireTime,string"`
|
||||
ExpireTime time.Time `json:"expireTime"`
|
||||
}
|
||||
|
||||
// OpenOrdersResponseAll holds the full open order response
|
||||
@@ -260,7 +260,7 @@ type LoanOffer struct {
|
||||
Rate float64 `json:"rate,string"`
|
||||
Amount float64 `json:"amount,string"`
|
||||
Duration int `json:"duration"`
|
||||
AutoRenew bool `json:"autoRenew,int"`
|
||||
AutoRenew bool `json:"autoRenew"`
|
||||
Date string `json:"date"`
|
||||
}
|
||||
|
||||
|
||||
@@ -470,7 +470,6 @@ func (k *Kraken) GetTradeBalance(args ...TradeBalanceOptions) (TradeBalanceInfo,
|
||||
if len(args[0].Asset) > 0 {
|
||||
params.Set("asset", args[0].Asset)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var response struct {
|
||||
|
||||
@@ -375,7 +375,6 @@ func (l *LakeBTC) CancelAllOrders(_ *order.Cancel) (order.CancelAllResponse, err
|
||||
}
|
||||
|
||||
return cancelAllOrdersResponse, l.CancelExistingOrders(ordersToCancel)
|
||||
|
||||
}
|
||||
|
||||
// GetOrderInfo returns information on a current open order
|
||||
|
||||
@@ -169,7 +169,6 @@ func (l *Lbank) GetKlines(symbol, size, klineType, time string) ([]KlineResponse
|
||||
} else {
|
||||
tempResp.TradingVolume = resp2[x].(float64)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
k = append(k, tempResp)
|
||||
|
||||
@@ -655,7 +655,6 @@ func (l *Lbank) getAllOpenOrderID() (map[string][]string, error) {
|
||||
|
||||
for c := 0; c < tempData; c++ {
|
||||
resp[p] = append(resp[p], tempResp.Orders[c].OrderID)
|
||||
|
||||
}
|
||||
tempData = len(tempResp.Orders)
|
||||
b++
|
||||
|
||||
@@ -106,7 +106,7 @@ type AdEdit struct {
|
||||
MaxAmount int `json:"max_amount"`
|
||||
OpeningHours []string `json:"opening_hours"`
|
||||
LimitToFiatAmounts string `json:"limit_to_fiat_amounts"`
|
||||
Visible bool `json:"visible,int"`
|
||||
Visible bool `json:"visible"`
|
||||
|
||||
// Optional Arguments ONLINE_SELL ads
|
||||
RequireTradeVolume int `json:"require_trade_volume"`
|
||||
@@ -114,13 +114,13 @@ type AdEdit struct {
|
||||
FirstTimeLimitBTC int `json:"first_time_limit_btc"`
|
||||
VolumeCoefficientBTC int `json:"volume_coefficient_btc"`
|
||||
ReferenceType string `json:"reference_type"`
|
||||
DisplayReference bool `json:"display_reference,int"`
|
||||
DisplayReference bool `json:"display_reference"`
|
||||
|
||||
// Optional Arguments ONLINE_BUY
|
||||
PaymentWindowMinutes int `json:"payment_window_minutes"`
|
||||
|
||||
// Optional Arguments LOCAL_SELL
|
||||
Floating bool `json:"floating,int"`
|
||||
Floating bool `json:"floating"`
|
||||
}
|
||||
|
||||
// AdCreate references an outgoing paramater type for CreateAd() method
|
||||
@@ -148,7 +148,7 @@ type AdCreate struct {
|
||||
MaxAmount int `json:"max_amount"`
|
||||
OpeningHours []string `json:"opening_hours"`
|
||||
LimitToFiatAmounts string `json:"limit_to_fiat_amounts"`
|
||||
Visible bool `json:"visible,int"`
|
||||
Visible bool `json:"visible"`
|
||||
|
||||
// Optional Arguments ONLINE_SELL ads
|
||||
RequireTradeVolume int `json:"require_trade_volume"`
|
||||
@@ -156,13 +156,13 @@ type AdCreate struct {
|
||||
FirstTimeLimitBTC int `json:"first_time_limit_btc"`
|
||||
VolumeCoefficientBTC int `json:"volume_coefficient_btc"`
|
||||
ReferenceType string `json:"reference_type"`
|
||||
DisplayReference bool `json:"display_reference,int"`
|
||||
DisplayReference bool `json:"display_reference"`
|
||||
|
||||
// Optional Arguments ONLINE_BUY
|
||||
PaymentWindowMinutes int `json:"payment_window_minutes"`
|
||||
|
||||
// Optional Arguments LOCAL_SELL
|
||||
Floating bool `json:"floating,int"`
|
||||
Floating bool `json:"floating"`
|
||||
}
|
||||
|
||||
// Message holds the returned message data from a contact
|
||||
|
||||
@@ -160,7 +160,6 @@ func (l *LocalBitcoins) UpdateTradablePairs(forceUpdate bool) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return l.UpdatePairs(currency.NewPairsFromStrings(pairs), asset.Spot, false, forceUpdate)
|
||||
}
|
||||
|
||||
|
||||
@@ -420,7 +420,6 @@ func GetExcludedItems() (Exclusion, error) {
|
||||
if mErr != nil {
|
||||
return excludedList, mErr
|
||||
}
|
||||
|
||||
} else {
|
||||
err = json.Unmarshal(file, &excludedList)
|
||||
if err != nil {
|
||||
|
||||
@@ -1074,7 +1074,6 @@ func TestCancelExchangeOrder(t *testing.T) {
|
||||
|
||||
err := o.CancelOrder(&orderCancellation)
|
||||
testStandardErrorHandling(t, err)
|
||||
|
||||
}
|
||||
|
||||
// TestCancelAllExchangeOrders Wrapper test
|
||||
|
||||
@@ -1815,7 +1815,6 @@ func TestCancelExchangeOrder(t *testing.T) {
|
||||
|
||||
err := o.CancelOrder(&orderCancellation)
|
||||
testStandardErrorHandling(t, err)
|
||||
|
||||
}
|
||||
|
||||
// TestCancelAllExchangeOrders Wrapper test
|
||||
|
||||
@@ -626,7 +626,6 @@ func (o *OKGroup) SendHTTPRequest(httpMethod, requestType, requestPath string, d
|
||||
if !errCap.Result {
|
||||
return errors.New("unspecified error occurred")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return common.JSONDecode(intermediary, result)
|
||||
|
||||
@@ -20,19 +20,19 @@ type WhaleBombResult struct {
|
||||
}
|
||||
|
||||
// WhaleBomb finds the amount required to target a price
|
||||
func (o *Base) WhaleBomb(priceTarget float64, buy bool) (*WhaleBombResult, error) {
|
||||
func (b *Base) WhaleBomb(priceTarget float64, buy bool) (*WhaleBombResult, error) {
|
||||
if priceTarget < 0 {
|
||||
return nil, errors.New("price target is invalid")
|
||||
}
|
||||
if buy {
|
||||
a, orders := o.findAmount(priceTarget, true)
|
||||
a, orders := b.findAmount(priceTarget, true)
|
||||
min, max := orders.MinimumPrice(false), orders.MaximumPrice(true)
|
||||
var err error
|
||||
if max < priceTarget {
|
||||
err = errors.New("unable to hit price target due to insufficient orderbook items")
|
||||
}
|
||||
status := fmt.Sprintf("Buying %.2f %v worth of %v will send the price from %v to %v [%.2f%%] and take %v orders.",
|
||||
a, o.Pair.Quote.String(), o.Pair.Base.String(), min, max,
|
||||
a, b.Pair.Quote.String(), b.Pair.Base.String(), min, max,
|
||||
math.CalculatePercentageGainOrLoss(max, min), len(orders))
|
||||
return &WhaleBombResult{
|
||||
Amount: a,
|
||||
@@ -43,14 +43,14 @@ func (o *Base) WhaleBomb(priceTarget float64, buy bool) (*WhaleBombResult, error
|
||||
}, err
|
||||
}
|
||||
|
||||
a, orders := o.findAmount(priceTarget, false)
|
||||
a, orders := b.findAmount(priceTarget, false)
|
||||
min, max := orders.MinimumPrice(false), orders.MaximumPrice(true)
|
||||
var err error
|
||||
if min > priceTarget {
|
||||
err = errors.New("unable to hit price target due to insufficient orderbook items")
|
||||
}
|
||||
status := fmt.Sprintf("Selling %.2f %v worth of %v will send the price from %v to %v [%.2f%%] and take %v orders.",
|
||||
a, o.Pair.Base.String(), o.Pair.Quote.String(), max, min,
|
||||
a, b.Pair.Base.String(), b.Pair.Quote.String(), max, min,
|
||||
math.CalculatePercentageGainOrLoss(min, max), len(orders))
|
||||
return &WhaleBombResult{
|
||||
Amount: a,
|
||||
@@ -65,13 +65,13 @@ func (o *Base) WhaleBomb(priceTarget float64, buy bool) (*WhaleBombResult, error
|
||||
type OrderSimulationResult WhaleBombResult
|
||||
|
||||
// SimulateOrder simulates an order
|
||||
func (o *Base) SimulateOrder(amount float64, buy bool) *OrderSimulationResult {
|
||||
func (b *Base) SimulateOrder(amount float64, buy bool) *OrderSimulationResult {
|
||||
if buy {
|
||||
orders, amt := o.buy(amount)
|
||||
orders, amt := b.buy(amount)
|
||||
min, max := orders.MinimumPrice(false), orders.MaximumPrice(true)
|
||||
pct := math.CalculatePercentageGainOrLoss(max, min)
|
||||
status := fmt.Sprintf("Buying %.2f %v worth of %v will send the price from %v to %v [%.2f%%] and take %v orders.",
|
||||
amount, o.Pair.Quote.String(), o.Pair.Base.String(), min, max,
|
||||
amount, b.Pair.Quote.String(), b.Pair.Base.String(), min, max,
|
||||
pct, len(orders))
|
||||
return &OrderSimulationResult{
|
||||
Orders: orders,
|
||||
@@ -82,11 +82,11 @@ func (o *Base) SimulateOrder(amount float64, buy bool) *OrderSimulationResult {
|
||||
Status: status,
|
||||
}
|
||||
}
|
||||
orders, amt := o.sell(amount)
|
||||
orders, amt := b.sell(amount)
|
||||
min, max := orders.MinimumPrice(false), orders.MaximumPrice(true)
|
||||
pct := math.CalculatePercentageGainOrLoss(min, max)
|
||||
status := fmt.Sprintf("Selling %f %v worth of %v will send the price from %v to %v [%.2f%%] and take %v orders.",
|
||||
amount, o.Pair.Base.String(), o.Pair.Quote.String(), max, min,
|
||||
amount, b.Pair.Base.String(), b.Pair.Quote.String(), max, min,
|
||||
pct, len(orders))
|
||||
return &OrderSimulationResult{
|
||||
Orders: orders,
|
||||
@@ -138,89 +138,88 @@ func sortOrdersByPrice(o *orderSummary, reverse bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Base) findAmount(price float64, buy bool) (float64, orderSummary) {
|
||||
func (b *Base) findAmount(price float64, buy bool) (float64, orderSummary) {
|
||||
var orders orderSummary
|
||||
var amt float64
|
||||
|
||||
if buy {
|
||||
asks := o.Asks
|
||||
for x := range asks {
|
||||
if asks[x].Price >= price {
|
||||
amt += asks[x].Price * asks[x].Amount
|
||||
for x := range b.Asks {
|
||||
if b.Asks[x].Price >= price {
|
||||
amt += b.Asks[x].Price * b.Asks[x].Amount
|
||||
orders = append(orders, Item{
|
||||
Price: asks[x].Price,
|
||||
Amount: asks[x].Amount,
|
||||
Price: b.Asks[x].Price,
|
||||
Amount: b.Asks[x].Amount,
|
||||
})
|
||||
return amt, orders
|
||||
}
|
||||
orders = append(orders, Item{
|
||||
Price: asks[x].Price,
|
||||
Amount: asks[x].Amount,
|
||||
Price: b.Asks[x].Price,
|
||||
Amount: b.Asks[x].Amount,
|
||||
})
|
||||
amt += asks[x].Price * asks[x].Amount
|
||||
amt += b.Asks[x].Price * b.Asks[x].Amount
|
||||
}
|
||||
return amt, orders
|
||||
}
|
||||
|
||||
for x := range o.Bids {
|
||||
if o.Bids[x].Price <= price {
|
||||
amt += o.Bids[x].Amount
|
||||
for x := range b.Bids {
|
||||
if b.Bids[x].Price <= price {
|
||||
amt += b.Bids[x].Amount
|
||||
orders = append(orders, Item{
|
||||
Price: o.Bids[x].Price,
|
||||
Amount: o.Bids[x].Amount,
|
||||
Price: b.Bids[x].Price,
|
||||
Amount: b.Bids[x].Amount,
|
||||
})
|
||||
break
|
||||
}
|
||||
orders = append(orders, Item{
|
||||
Price: o.Bids[x].Price,
|
||||
Amount: o.Bids[x].Amount,
|
||||
Price: b.Bids[x].Price,
|
||||
Amount: b.Bids[x].Amount,
|
||||
})
|
||||
amt += o.Bids[x].Amount
|
||||
amt += b.Bids[x].Amount
|
||||
}
|
||||
return amt, orders
|
||||
}
|
||||
|
||||
func (o *Base) buy(amount float64) (orders orderSummary, baseAmount float64) {
|
||||
func (b *Base) buy(amount float64) (orders orderSummary, baseAmount float64) {
|
||||
var processedAmt float64
|
||||
for x := range o.Asks {
|
||||
subtotal := o.Asks[x].Price * o.Asks[x].Amount
|
||||
for x := range b.Asks {
|
||||
subtotal := b.Asks[x].Price * b.Asks[x].Amount
|
||||
if processedAmt+subtotal >= amount {
|
||||
diff := amount - processedAmt
|
||||
subAmt := diff / o.Asks[x].Price
|
||||
subAmt := diff / b.Asks[x].Price
|
||||
orders = append(orders, Item{
|
||||
Price: o.Asks[x].Price,
|
||||
Price: b.Asks[x].Price,
|
||||
Amount: subAmt,
|
||||
})
|
||||
baseAmount += subAmt
|
||||
break
|
||||
}
|
||||
processedAmt += subtotal
|
||||
baseAmount += o.Asks[x].Amount
|
||||
baseAmount += b.Asks[x].Amount
|
||||
orders = append(orders, Item{
|
||||
Price: o.Asks[x].Price,
|
||||
Amount: o.Asks[x].Amount,
|
||||
Price: b.Asks[x].Price,
|
||||
Amount: b.Asks[x].Amount,
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (o *Base) sell(amount float64) (orders orderSummary, quoteAmount float64) {
|
||||
func (b *Base) sell(amount float64) (orders orderSummary, quoteAmount float64) {
|
||||
var processedAmt float64
|
||||
for x := range o.Bids {
|
||||
if processedAmt+o.Bids[x].Amount >= amount {
|
||||
for x := range b.Bids {
|
||||
if processedAmt+b.Bids[x].Amount >= amount {
|
||||
diff := amount - processedAmt
|
||||
orders = append(orders, Item{
|
||||
Price: o.Bids[x].Price,
|
||||
Price: b.Bids[x].Price,
|
||||
Amount: diff,
|
||||
})
|
||||
quoteAmount += diff * o.Bids[x].Price
|
||||
quoteAmount += diff * b.Bids[x].Price
|
||||
break
|
||||
}
|
||||
processedAmt += o.Bids[x].Amount
|
||||
quoteAmount += o.Bids[x].Amount * o.Bids[x].Price
|
||||
processedAmt += b.Bids[x].Amount
|
||||
quoteAmount += b.Bids[x].Amount * b.Bids[x].Price
|
||||
orders = append(orders, Item{
|
||||
Price: o.Bids[x].Price,
|
||||
Amount: o.Bids[x].Amount,
|
||||
Price: b.Bids[x].Price,
|
||||
Amount: b.Bids[x].Amount,
|
||||
})
|
||||
}
|
||||
return
|
||||
|
||||
@@ -262,7 +262,7 @@ type LoanOffer struct {
|
||||
Rate float64 `json:"rate,string"`
|
||||
Amount float64 `json:"amount,string"`
|
||||
Duration int `json:"duration"`
|
||||
AutoRenew bool `json:"autoRenew,int"`
|
||||
AutoRenew bool `json:"autoRenew"`
|
||||
Date string `json:"date"`
|
||||
}
|
||||
|
||||
|
||||
@@ -595,7 +595,6 @@ func TestFlushCache(t *testing.T) {
|
||||
if obl.ob[cp][asset.Spot] != nil {
|
||||
t.Error("expected ob be flushed")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TestInsertingSnapShots logic test
|
||||
|
||||
@@ -50,7 +50,6 @@ func CloseLogger() error {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func validSubLogger(s string) (bool, *subLogger) {
|
||||
|
||||
@@ -366,7 +366,6 @@ func (p *Base) GetPortfolioSummary() Summary {
|
||||
Percentage: getPercentageSpecific(z, y, totalCoins),
|
||||
}
|
||||
coinSummary[y] = coinSum
|
||||
|
||||
}
|
||||
exchangeSummary[exchgName] = coinSummary
|
||||
}
|
||||
|
||||
@@ -108,7 +108,6 @@ func TestExchangeAddressExists(t *testing.T) {
|
||||
if newbase.ExchangeAddressExists("TEST", currency.LTC) {
|
||||
t.Error("portfolio_test.go - ExchangeAddressExists error")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestAddExchangeAddress(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user