Split up common.go, file path fixes and much more

This commit is contained in:
Adrian Gallagher
2019-06-04 17:04:18 +10:00
parent 8c62316e82
commit e965e54e09
74 changed files with 524 additions and 617 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"strconv"
"strings"
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
@@ -534,7 +535,7 @@ func (a *Alphapoint) SendAuthenticatedHTTPRequest(method, path string, data map[
hmac := crypto.GetHMAC(crypto.HashSHA256,
[]byte(n.String()+a.API.Credentials.ClientID+a.API.Credentials.Key),
[]byte(a.API.Credentials.Secret))
data["apiSig"] = common.StringToUpper(crypto.HexEncodeToString(hmac))
data["apiSig"] = strings.ToUpper(crypto.HexEncodeToString(hmac))
path = fmt.Sprintf("%s/ajax/v%s/%s", a.API.Endpoints.URL, alphapointAPIVersion, path)
PayloadJSON, err := common.JSONEncode(data)

View File

@@ -2,8 +2,6 @@ package assets
import (
"strings"
"github.com/thrasher-/gocryptotrader/common"
)
// AssetType stores the asset type
@@ -93,7 +91,7 @@ func IsValid(input AssetType) bool {
// New takes an input of asset types as string and returns an AssetTypes
// array
func New(input string) AssetTypes {
if !common.StringContains(input, ",") {
if !strings.Contains(input, ",") {
if IsValid(AssetType(input)) {
return AssetTypes{
AssetType(input),

View File

@@ -8,6 +8,7 @@ import (
"net/http"
"net/url"
"strconv"
"strings"
"time"
"github.com/gorilla/websocket"
@@ -92,7 +93,7 @@ func (b *Binance) GetOrderBook(obd OrderBookDataRequestParams) (OrderBook, error
}
params := url.Values{}
params.Set("symbol", common.StringToUpper(obd.Symbol))
params.Set("symbol", strings.ToUpper(obd.Symbol))
params.Set("limit", fmt.Sprintf("%d", obd.Limit))
path := fmt.Sprintf("%s%s?%s", b.API.Endpoints.URL, orderBookDepth, params.Encode())
@@ -143,7 +144,7 @@ func (b *Binance) GetRecentTrades(rtr RecentTradeRequestParams) ([]RecentTrade,
var resp []RecentTrade
params := url.Values{}
params.Set("symbol", common.StringToUpper(rtr.Symbol))
params.Set("symbol", strings.ToUpper(rtr.Symbol))
params.Set("limit", fmt.Sprintf("%d", rtr.Limit))
path := fmt.Sprintf("%s%s?%s", b.API.Endpoints.URL, recentTrades, params.Encode())
@@ -164,7 +165,7 @@ func (b *Binance) GetHistoricalTrades(symbol string, limit int, fromID int64) ([
}
params := url.Values{}
params.Set("symbol", common.StringToUpper(symbol))
params.Set("symbol", strings.ToUpper(symbol))
params.Set("limit", strconv.Itoa(limit))
params.Set("fromid", strconv.FormatInt(fromID, 10))
@@ -185,7 +186,7 @@ func (b *Binance) GetAggregatedTrades(symbol string, limit int) ([]AggregatedTra
}
params := url.Values{}
params.Set("symbol", common.StringToUpper(symbol))
params.Set("symbol", strings.ToUpper(symbol))
params.Set("limit", strconv.Itoa(limit))
path := fmt.Sprintf("%s%s?%s", b.API.Endpoints.URL, aggregatedTrades, params.Encode())
@@ -263,7 +264,7 @@ func (b *Binance) GetSpotKline(arg KlinesRequestParams) ([]CandleStick, error) {
func (b *Binance) GetAveragePrice(symbol string) (AveragePrice, error) {
resp := AveragePrice{}
params := url.Values{}
params.Set("symbol", common.StringToUpper(symbol))
params.Set("symbol", strings.ToUpper(symbol))
path := fmt.Sprintf("%s%s?%s", b.API.Endpoints.URL, averagePrice, params.Encode())
@@ -276,7 +277,7 @@ func (b *Binance) GetAveragePrice(symbol string) (AveragePrice, error) {
func (b *Binance) GetPriceChangeStats(symbol string) (PriceChangeStats, error) {
resp := PriceChangeStats{}
params := url.Values{}
params.Set("symbol", common.StringToUpper(symbol))
params.Set("symbol", strings.ToUpper(symbol))
path := fmt.Sprintf("%s%s?%s", b.API.Endpoints.URL, priceChange, params.Encode())
@@ -296,7 +297,7 @@ func (b *Binance) GetTickers() ([]PriceChangeStats, error) {
func (b *Binance) GetLatestSpotPrice(symbol string) (SymbolPrice, error) {
resp := SymbolPrice{}
params := url.Values{}
params.Set("symbol", common.StringToUpper(symbol))
params.Set("symbol", strings.ToUpper(symbol))
path := fmt.Sprintf("%s%s?%s", b.API.Endpoints.URL, symbolPrice, params.Encode())
@@ -309,7 +310,7 @@ func (b *Binance) GetLatestSpotPrice(symbol string) (SymbolPrice, error) {
func (b *Binance) GetBestPrice(symbol string) (BestPrice, error) {
resp := BestPrice{}
params := url.Values{}
params.Set("symbol", common.StringToUpper(symbol))
params.Set("symbol", strings.ToUpper(symbol))
path := fmt.Sprintf("%s%s?%s", b.API.Endpoints.URL, bestPrice, params.Encode())
@@ -391,7 +392,7 @@ func (b *Binance) OpenOrders(symbol string) ([]QueryOrderData, error) {
params := url.Values{}
if symbol != "" {
params.Set("symbol", common.StringToUpper(symbol))
params.Set("symbol", strings.ToUpper(symbol))
}
if err := b.SendAuthHTTPRequest(http.MethodGet, path, params, &resp); err != nil {
@@ -410,7 +411,7 @@ func (b *Binance) AllOrders(symbol, orderID, limit string) ([]QueryOrderData, er
path := fmt.Sprintf("%s%s", b.API.Endpoints.URL, allOrders)
params := url.Values{}
params.Set("symbol", common.StringToUpper(symbol))
params.Set("symbol", strings.ToUpper(symbol))
if orderID != "" {
params.Set("orderId", orderID)
}
@@ -431,7 +432,7 @@ func (b *Binance) QueryOrder(symbol, origClientOrderID string, orderID int64) (Q
path := fmt.Sprintf("%s%s", b.API.Endpoints.URL, queryOrder)
params := url.Values{}
params.Set("symbol", common.StringToUpper(symbol))
params.Set("symbol", strings.ToUpper(symbol))
if origClientOrderID != "" {
params.Set("origClientOrderId", origClientOrderID)
}

View File

@@ -170,7 +170,7 @@ func (b *Bitfinex) UpdateTicker(p currency.Pair, assetType assets.AssetType) (ti
pairs = append(pairs, "t"+enabledPairs[x].String())
}
tickerNew, err := b.GetTickersV2(common.JoinStrings(pairs, ","))
tickerNew, err := b.GetTickersV2(strings.Join(pairs, ","))
if err != nil {
return tickerPrice, err
}

View File

@@ -2,6 +2,7 @@ package bitflyer
import (
"errors"
"strings"
"sync"
"time"
@@ -136,7 +137,7 @@ func (b *Bitflyer) FetchTradablePairs(assetType assets.AssetType) ([]string, err
for _, info := range pairs {
if info.Alias != "" && assetType == assets.AssetTypeFutures {
products = append(products, info.Alias)
} else if info.Alias == "" && assetType == assets.AssetTypeSpot && common.StringContains(info.ProductCode, "_") {
} else if info.Alias == "" && assetType == assets.AssetTypeSpot && strings.Contains(info.ProductCode, "_") {
products = append(products, info.ProductCode)
}
}
@@ -198,7 +199,7 @@ func (b *Bitflyer) FetchTicker(p currency.Pair, assetType assets.AssetType) (tic
// CheckFXString upgrades currency pair if needed
func (b *Bitflyer) CheckFXString(p currency.Pair) currency.Pair {
if common.StringContains(p.Base.String(), "FX") {
if strings.Contains(p.Base.String(), "FX") {
p.Base = currency.FX_BTC
return p
}

View File

@@ -9,6 +9,7 @@ import (
"net/url"
"reflect"
"strconv"
"strings"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/common/crypto"
@@ -74,7 +75,7 @@ func (b *Bithumb) GetTradablePairs() ([]string, error) {
// symbol e.g. "btc"
func (b *Bithumb) GetTicker(symbol string) (Ticker, error) {
response := Ticker{}
path := fmt.Sprintf("%s%s%s", b.API.Endpoints.URL, publicTicker, common.StringToUpper(symbol))
path := fmt.Sprintf("%s%s%s", b.API.Endpoints.URL, publicTicker, strings.ToUpper(symbol))
err := b.SendHTTPRequest(path, &response)
if err != nil {
@@ -140,7 +141,7 @@ func (b *Bithumb) GetAllTickers() (map[string]Ticker, error) {
// symbol e.g. "btc"
func (b *Bithumb) GetOrderBook(symbol string) (Orderbook, error) {
response := Orderbook{}
path := fmt.Sprintf("%s%s%s", b.API.Endpoints.URL, publicOrderBook, common.StringToUpper(symbol))
path := fmt.Sprintf("%s%s%s", b.API.Endpoints.URL, publicOrderBook, strings.ToUpper(symbol))
err := b.SendHTTPRequest(path, &response)
if err != nil {
@@ -159,7 +160,7 @@ func (b *Bithumb) GetOrderBook(symbol string) (Orderbook, error) {
// symbol e.g. "btc"
func (b *Bithumb) GetTransactionHistory(symbol string) (TransactionHistory, error) {
response := TransactionHistory{}
path := fmt.Sprintf("%s%s%s", b.API.Endpoints.URL, publicTransactionHistory, common.StringToUpper(symbol))
path := fmt.Sprintf("%s%s%s", b.API.Endpoints.URL, publicTransactionHistory, strings.ToUpper(symbol))
err := b.SendHTTPRequest(path, &response)
if err != nil {
@@ -210,7 +211,7 @@ func (b *Bithumb) GetAccountBalance(c string) (FullBalance, error) {
// Added due to increasing of the usuable currencies on exchange, usually
// without notificatation, so we dont need to update structs later on
for tag, datum := range response.Data {
splitTag := common.SplitStrings(tag, "_")
splitTag := strings.Split(tag, "_")
c := splitTag[len(splitTag)-1]
var val float64
if reflect.TypeOf(datum).String() != "float64" {
@@ -253,7 +254,7 @@ func (b *Bithumb) GetAccountBalance(c string) (FullBalance, error) {
func (b *Bithumb) GetWalletAddress(currency string) (WalletAddressRes, error) {
response := WalletAddressRes{}
params := url.Values{}
params.Set("currency", common.StringToUpper(currency))
params.Set("currency", strings.ToUpper(currency))
err := b.SendAuthenticatedHTTPRequest(privateWalletAdd, params, &response)
if err != nil {
@@ -305,7 +306,7 @@ func (b *Bithumb) GetOrders(orderID, transactionType, count, after, currency str
}
if len(currency) > 0 {
params.Set("currency", common.StringToUpper(currency))
params.Set("currency", strings.ToUpper(currency))
}
return response,
@@ -331,9 +332,9 @@ func (b *Bithumb) PlaceTrade(orderCurrency, transactionType string, units float6
response := OrderPlace{}
params := url.Values{}
params.Set("order_currency", common.StringToUpper(orderCurrency))
params.Set("order_currency", strings.ToUpper(orderCurrency))
params.Set("Payment_currency", "KRW")
params.Set("type", common.StringToUpper(transactionType))
params.Set("type", strings.ToUpper(transactionType))
params.Set("units", strconv.FormatFloat(units, 'f', -1, 64))
params.Set("price", strconv.FormatInt(price, 10))
@@ -346,9 +347,9 @@ func (b *Bithumb) ModifyTrade(orderID, orderCurrency, transactionType string, un
response := OrderPlace{}
params := url.Values{}
params.Set("order_currency", common.StringToUpper(orderCurrency))
params.Set("order_currency", strings.ToUpper(orderCurrency))
params.Set("Payment_currency", "KRW")
params.Set("type", common.StringToUpper(transactionType))
params.Set("type", strings.ToUpper(transactionType))
params.Set("units", strconv.FormatFloat(units, 'f', -1, 64))
params.Set("price", strconv.FormatInt(price, 10))
params.Set("order_id", orderID)
@@ -367,9 +368,9 @@ func (b *Bithumb) GetOrderDetails(orderID, transactionType, currency string) (Or
response := OrderDetails{}
params := url.Values{}
params.Set("order_id", common.StringToUpper(orderID))
params.Set("order_id", strings.ToUpper(orderID))
params.Set("type", transactionType)
params.Set("currency", common.StringToUpper(currency))
params.Set("currency", strings.ToUpper(currency))
return response,
b.SendAuthenticatedHTTPRequest(privateOrderDetail, params, &response)
@@ -384,9 +385,9 @@ func (b *Bithumb) CancelTrade(transactionType, orderID, currency string) (Action
response := ActionStatus{}
params := url.Values{}
params.Set("order_id", common.StringToUpper(orderID))
params.Set("type", common.StringToUpper(transactionType))
params.Set("currency", common.StringToUpper(currency))
params.Set("order_id", strings.ToUpper(orderID))
params.Set("type", strings.ToUpper(transactionType))
params.Set("currency", strings.ToUpper(currency))
return response,
b.SendAuthenticatedHTTPRequest(privateCancelTrade, nil, &response)
@@ -408,7 +409,7 @@ func (b *Bithumb) WithdrawCrypto(address, destination, currency string, units fl
if len(destination) > 0 {
params.Set("destination", destination)
}
params.Set("currency", common.StringToUpper(currency))
params.Set("currency", strings.ToUpper(currency))
params.Set("units", strconv.FormatFloat(units, 'f', -1, 64))
return response,
@@ -450,7 +451,7 @@ func (b *Bithumb) MarketBuyOrder(currency string, units float64) (MarketBuy, err
response := MarketBuy{}
params := url.Values{}
params.Set("currency", common.StringToUpper(currency))
params.Set("currency", strings.ToUpper(currency))
params.Set("units", strconv.FormatFloat(units, 'f', -1, 64))
return response,
@@ -466,7 +467,7 @@ func (b *Bithumb) MarketSellOrder(currency string, units float64) (MarketSell, e
response := MarketSell{}
params := url.Values{}
params.Set("currency", common.StringToUpper(currency))
params.Set("currency", strings.ToUpper(currency))
params.Set("units", strconv.FormatFloat(units, 'f', -1, 64))
return response,

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"math"
"strconv"
"strings"
"sync"
"time"
@@ -301,7 +302,7 @@ func (b *Bithumb) SubmitOrder(p currency.Pair, side exchange.OrderSide, _ exchan
func (b *Bithumb) ModifyOrder(action *exchange.ModifyOrder) (string, error) {
order, err := b.ModifyTrade(action.OrderID,
action.CurrencyPair.Base.String(),
common.StringToLower(action.OrderSide.ToString()),
strings.ToLower(action.OrderSide.ToString()),
action.Amount,
int64(action.Price))

View File

@@ -5,6 +5,7 @@ import (
"net/url"
"reflect"
"strconv"
"strings"
"github.com/thrasher-/gocryptotrader/common"
)
@@ -35,7 +36,7 @@ func StructValsToURLVals(v interface{}) (url.Values, error) {
if structType.Field(i).Tag != "" {
jsonTag := structType.Field(i).Tag.Get("json")
if jsonTag != "" {
split := common.SplitStrings(jsonTag, ",")
split := strings.Split(jsonTag, ",")
outgoingTag = split[0]
}
}

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"net/url"
"strconv"
"strings"
"time"
"github.com/gorilla/websocket"
@@ -152,12 +153,12 @@ func (b *Bitmex) wsHandleIncomingData() {
}
message := string(resp.Raw)
if common.StringContains(message, "pong") {
if strings.Contains(message, "pong") {
pongChan <- 1
continue
}
if common.StringContains(message, "ping") {
if strings.Contains(message, "ping") {
err = b.wsSend("pong")
if err != nil {
b.Websocket.DataHandler <- err

View File

@@ -157,7 +157,7 @@ func (b *Bitstamp) GetTicker(currency string, hourly bool) (Ticker, error) {
b.API.Endpoints.URL,
bitstampAPIVersion,
tickerEndpoint,
common.StringToLower(currency),
strings.ToLower(currency),
)
return response, b.SendHTTPRequest(path, &response)
}
@@ -178,7 +178,7 @@ func (b *Bitstamp) GetOrderbook(currency string) (Orderbook, error) {
b.API.Endpoints.URL,
bitstampAPIVersion,
bitstampAPIOrderbook,
common.StringToLower(currency),
strings.ToLower(currency),
)
err := b.SendHTTPRequest(path, &resp)
@@ -244,7 +244,7 @@ func (b *Bitstamp) GetTransactions(currencyPair string, values url.Values) ([]Tr
b.API.Endpoints.URL,
bitstampAPIVersion,
bitstampAPITransactions,
common.StringToLower(currencyPair),
strings.ToLower(currencyPair),
),
values,
)
@@ -339,7 +339,7 @@ func (b *Bitstamp) GetUserTransactions(currencyPair string) ([]UserTransactions,
func (b *Bitstamp) GetOpenOrders(currencyPair string) ([]Order, error) {
var resp []Order
path := fmt.Sprintf(
"%s/%s", bitstampAPIOpenOrders, common.StringToLower(currencyPair),
"%s/%s", bitstampAPIOpenOrders, strings.ToLower(currencyPair),
)
return resp, b.SendAuthenticatedHTTPRequest(path, true, nil, &resp)
@@ -385,10 +385,10 @@ func (b *Bitstamp) PlaceOrder(currencyPair string, price, amount float64, buy, m
orderType = exchange.SellOrderSide.ToLower().ToString()
}
path := fmt.Sprintf("%s/%s", orderType, common.StringToLower(currencyPair))
path := fmt.Sprintf("%s/%s", orderType, strings.ToLower(currencyPair))
if market {
path = fmt.Sprintf("%s/%s/%s", orderType, bitstampAPIMarket, common.StringToLower(currencyPair))
path = fmt.Sprintf("%s/%s/%s", orderType, bitstampAPIMarket, strings.ToLower(currencyPair))
}
return response,
@@ -428,7 +428,7 @@ func (b *Bitstamp) CryptoWithdrawal(amount float64, address, symbol, destTag str
resp := CryptoWithdrawalResponse{}
var endpoint string
switch common.StringToLower(symbol) {
switch strings.ToLower(symbol) {
case "btc":
if instant {
req.Add("instant", "1")
@@ -586,7 +586,7 @@ func (b *Bitstamp) SendAuthenticatedHTTPRequest(path string, v2 bool, values url
hmac := crypto.GetHMAC(crypto.HashSHA256,
[]byte(n+b.API.Credentials.ClientID+b.API.Credentials.Key),
[]byte(b.API.Credentials.Secret))
values.Set("signature", common.StringToUpper(crypto.HexEncodeToString(hmac)))
values.Set("signature", strings.ToUpper(crypto.HexEncodeToString(hmac)))
if v2 {
path = fmt.Sprintf("%s/v%s/%s/", b.API.Endpoints.URL, bitstampAPIVersion, path)

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"net/url"
"strconv"
"strings"
"time"
"github.com/gorilla/websocket"
@@ -117,8 +118,8 @@ func (b *Bitstamp) WsHandleData() {
continue
}
currencyPair := common.SplitStrings(wsResponse.Channel, "_")
p := currency.NewPairFromString(common.StringToUpper(currencyPair[3]))
currencyPair := strings.Split(wsResponse.Channel, "_")
p := currency.NewPairFromString(strings.ToUpper(currencyPair[3]))
err = b.wsUpdateOrderbook(wsOrderBookTemp.Data, p, assets.AssetTypeSpot)
if err != nil {
@@ -135,8 +136,8 @@ func (b *Bitstamp) WsHandleData() {
continue
}
currencyPair := common.SplitStrings(wsResponse.Channel, "_")
p := currency.NewPairFromString(common.StringToUpper(currencyPair[2]))
currencyPair := strings.Split(wsResponse.Channel, "_")
p := currency.NewPairFromString(strings.ToUpper(currencyPair[2]))
b.Websocket.DataHandler <- exchange.TradeData{
Price: wsTradeTemp.Data.Price,

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"strconv"
"strings"
"sync"
"time"
@@ -155,7 +156,7 @@ func (b *Bitstamp) FetchTradablePairs(asset assets.AssetType) ([]string, error)
continue
}
pair := common.SplitStrings(pairs[x].Name, "/")
pair := strings.Split(pairs[x].Name, "/")
products = append(products, pair[0]+pair[1])
}

View File

@@ -6,8 +6,8 @@ import (
"net/http"
"net/url"
"strconv"
"strings"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/common/crypto"
"github.com/thrasher-/gocryptotrader/currency"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
@@ -96,7 +96,7 @@ func (b *Bittrex) GetCurrencies() (Currency, error) {
func (b *Bittrex) GetTicker(currencyPair string) (Ticker, error) {
tick := Ticker{}
path := fmt.Sprintf("%s/%s?market=%s", b.API.Endpoints.URL, bittrexAPIGetTicker,
common.StringToUpper(currencyPair),
strings.ToUpper(currencyPair),
)
if err := b.SendHTTPRequest(path, &tick); err != nil {
@@ -130,7 +130,7 @@ func (b *Bittrex) GetMarketSummaries() (MarketSummary, error) {
func (b *Bittrex) GetMarketSummary(currencyPair string) (MarketSummary, error) {
var summary MarketSummary
path := fmt.Sprintf("%s/%s?market=%s", b.API.Endpoints.URL,
bittrexAPIGetMarketSummary, common.StringToLower(currencyPair),
bittrexAPIGetMarketSummary, strings.ToLower(currencyPair),
)
if err := b.SendHTTPRequest(path, &summary); err != nil {
@@ -153,7 +153,7 @@ func (b *Bittrex) GetMarketSummary(currencyPair string) (MarketSummary, error) {
func (b *Bittrex) GetOrderbook(currencyPair string) (OrderBooks, error) {
var orderbooks OrderBooks
path := fmt.Sprintf("%s/%s?market=%s&type=both&depth=50", b.API.Endpoints.URL,
bittrexAPIGetOrderbook, common.StringToUpper(currencyPair),
bittrexAPIGetOrderbook, strings.ToUpper(currencyPair),
)
if err := b.SendHTTPRequest(path, &orderbooks); err != nil {
@@ -171,7 +171,7 @@ func (b *Bittrex) GetOrderbook(currencyPair string) (OrderBooks, error) {
func (b *Bittrex) GetMarketHistory(currencyPair string) (MarketHistory, error) {
var marketHistoriae MarketHistory
path := fmt.Sprintf("%s/%s?market=%s", b.API.Endpoints.URL,
bittrexAPIGetMarketHistory, common.StringToUpper(currencyPair),
bittrexAPIGetMarketHistory, strings.ToUpper(currencyPair),
)
if err := b.SendHTTPRequest(path, &marketHistoriae); err != nil {

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"net/url"
"strings"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/common/crypto"
@@ -75,8 +76,8 @@ func (b *BTCMarkets) GetTicker(firstPair, secondPair string) (Ticker, error) {
tick := Ticker{}
path := fmt.Sprintf("%s/market/%s/%s/tick",
b.API.Endpoints.URL,
common.StringToUpper(firstPair),
common.StringToUpper(secondPair))
strings.ToUpper(firstPair),
strings.ToUpper(secondPair))
return tick, b.SendHTTPRequest(path, &tick)
}
@@ -87,8 +88,8 @@ func (b *BTCMarkets) GetOrderbook(firstPair, secondPair string) (Orderbook, erro
orderbook := Orderbook{}
path := fmt.Sprintf("%s/market/%s/%s/orderbook",
b.API.Endpoints.URL,
common.StringToUpper(firstPair),
common.StringToUpper(secondPair))
strings.ToUpper(firstPair),
strings.ToUpper(secondPair))
return orderbook, b.SendHTTPRequest(path, &orderbook)
}
@@ -99,8 +100,8 @@ func (b *BTCMarkets) GetOrderbook(firstPair, secondPair string) (Orderbook, erro
func (b *BTCMarkets) GetTrades(firstPair, secondPair string, values url.Values) ([]Trade, error) {
var trades []Trade
path := common.EncodeURLValues(fmt.Sprintf("%s/market/%s/%s/trades",
b.API.Endpoints.URL, common.StringToUpper(firstPair),
common.StringToUpper(secondPair)), values)
b.API.Endpoints.URL, strings.ToUpper(firstPair),
strings.ToUpper(secondPair)), values)
return trades, b.SendHTTPRequest(path, &trades)
}
@@ -118,8 +119,8 @@ func (b *BTCMarkets) NewOrder(instrument, currency string, price, amount float64
newVolume := int64(amount * float64(common.SatoshisPerBTC))
order := OrderToGo{
Currency: common.StringToUpper(currency),
Instrument: common.StringToUpper(instrument),
Currency: strings.ToUpper(currency),
Instrument: strings.ToUpper(instrument),
Price: newPrice,
Volume: newVolume,
OrderSide: orderSide,
@@ -172,10 +173,10 @@ func (b *BTCMarkets) GetOrders(currency, instrument string, limit, since int64,
req := make(map[string]interface{})
if currency != "" {
req["currency"] = common.StringToUpper(currency)
req["currency"] = strings.ToUpper(currency)
}
if instrument != "" {
req["instrument"] = common.StringToUpper(instrument)
req["instrument"] = strings.ToUpper(instrument)
}
if limit != 0 {
req["limit"] = limit
@@ -312,7 +313,7 @@ func (b *BTCMarkets) WithdrawCrypto(amount float64, currency, address string) (s
req := WithdrawRequestCrypto{
Amount: newAmount,
Currency: common.StringToUpper(currency),
Currency: strings.ToUpper(currency),
Address: address,
}

View File

@@ -8,7 +8,6 @@ import (
"strings"
"time"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/common/crypto"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency"
@@ -489,7 +488,7 @@ func (e *Base) ValidateAPICredentials() bool {
if e.API.CredentialsValidator.RequiresPEM {
if e.API.Credentials.PEMKey == "" ||
common.StringContains(e.API.Credentials.PEMKey, "JUSTADUMMY") {
strings.Contains(e.API.Credentials.PEMKey, "JUSTADUMMY") {
log.Warnf("exchange %s requires API PEM key but default/empty one set",
e.Name)
return false

View File

@@ -6,7 +6,6 @@ import (
"strings"
"time"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency"
"github.com/thrasher-/gocryptotrader/exchanges/assets"
@@ -164,7 +163,7 @@ const (
// ToLower changes the ordertype to lower case
func (o OrderType) ToLower() OrderType {
return OrderType(common.StringToLower(string(o)))
return OrderType(strings.ToLower(string(o)))
}
// ToString changes the ordertype to the exchange standard and returns a string
@@ -186,7 +185,7 @@ const (
// ToLower changes the ordertype to lower case
func (o OrderSide) ToLower() OrderSide {
return OrderSide(common.StringToLower(string(o)))
return OrderSide(strings.ToLower(string(o)))
}
// ToString changes the ordertype to the exchange standard and returns a string

View File

@@ -238,7 +238,7 @@ func (e *EXMO) WithdrawCryptocurrency(currency, address, invoice string, amount
v.Set("currency", currency)
v.Set("address", address)
if common.StringToUpper(currency) == "XRP" {
if strings.ToUpper(currency) == "XRP" {
v.Set(invoice, invoice)
}

View File

@@ -11,6 +11,7 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/common/convert"
"github.com/thrasher-/gocryptotrader/common/crypto"
"github.com/thrasher-/gocryptotrader/currency"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
@@ -214,31 +215,31 @@ func (g *Gateio) GetSpotKline(arg KlinesRequestParams) ([]*KLineResponse, error)
for _, k := range rawKlineDatas {
otString, _ := strconv.ParseFloat(k[0].(string), 64)
ot, err := common.TimeFromUnixTimestampFloat(otString)
ot, err := convert.TimeFromUnixTimestampFloat(otString)
if err != nil {
return nil, fmt.Errorf("cannot parse Kline.OpenTime. Err: %s", err)
}
_vol, err := common.FloatFromString(k[1])
_vol, err := convert.FloatFromString(k[1])
if err != nil {
return nil, fmt.Errorf("cannot parse Kline.Volume. Err: %s", err)
}
_id, err := common.FloatFromString(k[0])
_id, err := convert.FloatFromString(k[0])
if err != nil {
return nil, fmt.Errorf("cannot parse Kline.Id. Err: %s", err)
}
_close, err := common.FloatFromString(k[2])
_close, err := convert.FloatFromString(k[2])
if err != nil {
return nil, fmt.Errorf("cannot parse Kline.Close. Err: %s", err)
}
_high, err := common.FloatFromString(k[3])
_high, err := convert.FloatFromString(k[3])
if err != nil {
return nil, fmt.Errorf("cannot parse Kline.High. Err: %s", err)
}
_low, err := common.FloatFromString(k[4])
_low, err := convert.FloatFromString(k[4])
if err != nil {
return nil, fmt.Errorf("cannot parse Kline.Low. Err: %s", err)
}
_open, err := common.FloatFromString(k[5])
_open, err := convert.FloatFromString(k[5])
if err != nil {
return nil, fmt.Errorf("cannot parse Kline.Open. Err: %s", err)
}

View File

@@ -118,7 +118,7 @@ func (g *Gateio) WsHandleData() {
}
if result.Error.Code != 0 {
if common.StringContains(result.Error.Message, "authentication") {
if strings.Contains(result.Error.Message, "authentication") {
g.Websocket.DataHandler <- fmt.Errorf("%v - WebSocket authentication failed ",
g.GetName())
g.API.AuthenticatedSupport = false
@@ -170,7 +170,7 @@ func (g *Gateio) WsHandleData() {
}
switch {
case common.StringContains(result.Method, "ticker"):
case strings.Contains(result.Method, "ticker"):
var ticker WebsocketTicker
var c string
err = common.JSONDecode(result.Params[1], &ticker)
@@ -197,7 +197,7 @@ func (g *Gateio) WsHandleData() {
LowPrice: ticker.Low,
}
case common.StringContains(result.Method, "trades"):
case strings.Contains(result.Method, "trades"):
var trades []WebsocketTrade
var c string
err = common.JSONDecode(result.Params[1], &trades)
@@ -224,7 +224,7 @@ func (g *Gateio) WsHandleData() {
}
}
case common.StringContains(result.Method, "depth"):
case strings.Contains(result.Method, "depth"):
var IsSnapshot bool
var c string
var data = make(map[string][][]string)
@@ -312,7 +312,7 @@ func (g *Gateio) WsHandleData() {
Exchange: g.GetName(),
}
case common.StringContains(result.Method, "kline"):
case strings.Contains(result.Method, "kline"):
var data []interface{}
err = common.JSONDecode(result.Params[0], &data)
if err != nil {

View File

@@ -133,7 +133,7 @@ func (g *Gemini) GetTicker(currencyPair string) (Ticker, error) {
ticker.Volume.Currency, _ = strconv.ParseFloat(resp.Volume[currencyPair[0:3]].(string), 64)
if common.StringContains(currencyPair, "USD") {
if strings.Contains(currencyPair, "USD") {
ticker.Volume.USD, _ = strconv.ParseFloat(resp.Volume["USD"].(string), 64)
} else {
if resp.Volume["ETH"] != nil {
@@ -377,7 +377,7 @@ func (g *Gemini) WithdrawCrypto(address, currency string, amount float64) (Withd
req["address"] = address
req["amount"] = strconv.FormatFloat(amount, 'f', -1, 64)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiWithdraw+common.StringToLower(currency), req, &response)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiWithdraw+strings.ToLower(currency), req, &response)
if err != nil {
return response, err
}

View File

@@ -296,8 +296,8 @@ func (h *HitBTC) SubmitOrder(p currency.Pair, side exchange.OrderSide, orderType
response, err := h.PlaceOrder(p.String(),
price,
amount,
common.StringToLower(orderType.ToString()),
common.StringToLower(side.ToString()))
strings.ToLower(orderType.ToString()),
strings.ToLower(side.ToString()))
if response.OrderNumber > 0 {
submitOrderResponse.OrderID = fmt.Sprintf("%v", response.OrderNumber)

View File

@@ -8,6 +8,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"
"github.com/gorilla/websocket"
@@ -126,7 +127,7 @@ func (h *HUOBI) WsHandleData() {
}
switch {
case common.StringContains(init.Channel, "depth"):
case strings.Contains(init.Channel, "depth"):
var depth WsDepth
err := common.JSONDecode(resp.Raw, &depth)
if err != nil {
@@ -134,11 +135,11 @@ func (h *HUOBI) WsHandleData() {
continue
}
data := common.SplitStrings(depth.Channel, ".")
data := strings.Split(depth.Channel, ".")
h.WsProcessOrderbook(&depth, data[1])
case common.StringContains(init.Channel, "kline"):
case strings.Contains(init.Channel, "kline"):
var kline WsKline
err := common.JSONDecode(resp.Raw, &kline)
if err != nil {
@@ -146,7 +147,7 @@ func (h *HUOBI) WsHandleData() {
continue
}
data := common.SplitStrings(kline.Channel, ".")
data := strings.Split(kline.Channel, ".")
h.Websocket.DataHandler <- exchange.KlineData{
Timestamp: time.Unix(0, kline.Timestamp),
@@ -160,7 +161,7 @@ func (h *HUOBI) WsHandleData() {
Volume: kline.Tick.Volume,
}
case common.StringContains(init.Channel, "trade"):
case strings.Contains(init.Channel, "trade"):
var trade WsTrade
err := common.JSONDecode(resp.Raw, &trade)
if err != nil {
@@ -168,7 +169,7 @@ func (h *HUOBI) WsHandleData() {
continue
}
data := common.SplitStrings(trade.Channel, ".")
data := strings.Split(trade.Channel, ".")
h.Websocket.DataHandler <- exchange.TradeData{
Exchange: h.GetName(),

View File

@@ -390,7 +390,7 @@ func (h *HUOBI) SubmitOrder(p currency.Pair, side exchange.OrderSide, orderType
var params = SpotNewOrderRequestParams{
Amount: amount,
Source: "api",
Symbol: common.StringToLower(p.String()),
Symbol: strings.ToLower(p.String()),
AccountID: int(accountID),
}

View File

@@ -8,6 +8,7 @@ import (
"net/http"
"net/url"
"strconv"
"strings"
"sync"
"time"
@@ -843,7 +844,7 @@ func (h *HUOBIHADAX) GetDepositWithdrawalHistory(associatedID, currency string,
vals.Set("from", associatedID)
vals.Set("size", strconv.FormatInt(size, 10))
vals.Set("currency", common.StringToLower(currency))
vals.Set("currency", strings.ToLower(currency))
err := h.SendAuthenticatedHTTPRequest(http.MethodGet,
huobiHadaxDepositAddress,

View File

@@ -8,6 +8,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"
"github.com/gorilla/websocket"
@@ -129,7 +130,7 @@ func (h *HUOBIHADAX) WsHandleData() {
}
switch {
case common.StringContains(init.Channel, "depth"):
case strings.Contains(init.Channel, "depth"):
var depth WsDepth
err := common.JSONDecode(resp.Raw, &depth)
if err != nil {
@@ -137,11 +138,11 @@ func (h *HUOBIHADAX) WsHandleData() {
continue
}
data := common.SplitStrings(depth.Channel, ".")
data := strings.Split(depth.Channel, ".")
h.WsProcessOrderbook(&depth, data[1])
case common.StringContains(init.Channel, "kline"):
case strings.Contains(init.Channel, "kline"):
var kline WsKline
err := common.JSONDecode(resp.Raw, &kline)
if err != nil {
@@ -149,7 +150,7 @@ func (h *HUOBIHADAX) WsHandleData() {
continue
}
data := common.SplitStrings(kline.Channel, ".")
data := strings.Split(kline.Channel, ".")
h.Websocket.DataHandler <- exchange.KlineData{
Timestamp: time.Unix(0, kline.Timestamp),
@@ -163,7 +164,7 @@ func (h *HUOBIHADAX) WsHandleData() {
Volume: kline.Tick.Volume,
}
case common.StringContains(init.Channel, "trade"):
case strings.Contains(init.Channel, "trade"):
var trade WsTrade
err := common.JSONDecode(resp.Raw, &trade)
if err != nil {
@@ -171,7 +172,7 @@ func (h *HUOBIHADAX) WsHandleData() {
continue
}
data := common.SplitStrings(trade.Channel, ".")
data := strings.Split(trade.Channel, ".")
h.Websocket.DataHandler <- exchange.TradeData{
Exchange: h.GetName(),

View File

@@ -351,7 +351,7 @@ func (h *HUOBIHADAX) SubmitOrder(p currency.Pair, side exchange.OrderSide, order
var params = SpotNewOrderRequestParams{
Amount: amount,
Source: "api",
Symbol: common.StringToLower(p.String()),
Symbol: strings.ToLower(p.String()),
AccountID: int(accountID),
}

View File

@@ -10,7 +10,6 @@ import (
"sync"
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/common/crypto"
"github.com/thrasher-/gocryptotrader/currency"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
@@ -751,8 +750,8 @@ func (k *Kraken) GetTradeVolume(feeinfo bool, symbol ...string) (TradeVolumeResp
func (k *Kraken) AddOrder(symbol, side, orderType string, volume, price, price2, leverage float64, args *AddOrderOptions) (AddOrderResponse, error) {
params := url.Values{
"pair": {symbol},
"type": {common.StringToLower(side)},
"ordertype": {common.StringToLower(orderType)},
"type": {strings.ToLower(side)},
"ordertype": {strings.ToLower(orderType)},
"volume": {strconv.FormatFloat(volume, 'f', -1, 64)},
}

View File

@@ -172,7 +172,7 @@ func (k *Kraken) FetchTradablePairs(asset assets.AssetType) ([]string, error) {
var products []string
for i := range pairs {
v := pairs[i]
if common.StringContains(v.Altname, ".d") {
if strings.Contains(v.Altname, ".d") {
continue
}
if v.Base[0] == 'X' {
@@ -214,8 +214,8 @@ func (k *Kraken) UpdateTicker(p currency.Pair, assetType assets.AssetType) (tick
for _, x := range pairs {
for y, z := range tickers {
if !common.StringContains(y, x.Base.Upper().String()) ||
!common.StringContains(y, x.Quote.Upper().String()) {
if !strings.Contains(y, x.Base.Upper().String()) ||
!strings.Contains(y, x.Quote.Upper().String()) {
continue
}
var tp ticker.Price

View File

@@ -52,7 +52,7 @@ func (l *LakeBTC) GetTicker() (map[string]Ticker, error) {
for k, v := range response {
var tick Ticker
key := common.StringToUpper(k)
key := strings.ToUpper(k)
if v.Ask != nil {
tick.Ask, _ = strconv.ParseFloat(v.Ask.(string), 64)
}
@@ -82,7 +82,7 @@ func (l *LakeBTC) GetOrderBook(currency string) (Orderbook, error) {
Bids [][]string `json:"bids"`
Asks [][]string `json:"asks"`
}
path := fmt.Sprintf("%s/%s?symbol=%s", l.API.Endpoints.URL, lakeBTCOrderbook, common.StringToLower(currency))
path := fmt.Sprintf("%s/%s?symbol=%s", l.API.Endpoints.URL, lakeBTCOrderbook, strings.ToLower(currency))
resp := Response{}
err := l.SendHTTPRequest(path, &resp)
if err != nil {
@@ -122,7 +122,7 @@ func (l *LakeBTC) GetOrderBook(currency string) (Orderbook, error) {
// GetTradeHistory returns the trade history for a given currency pair
func (l *LakeBTC) GetTradeHistory(currency string) ([]TradeHistory, error) {
path := fmt.Sprintf("%s/%s?symbol=%s", l.API.Endpoints.URL, lakeBTCTrades, common.StringToLower(currency))
path := fmt.Sprintf("%s/%s?symbol=%s", l.API.Endpoints.URL, lakeBTCTrades, strings.ToLower(currency))
var resp []TradeHistory
return resp, l.SendHTTPRequest(path, &resp)
}
@@ -172,7 +172,7 @@ func (l *LakeBTC) GetOrders(orders []int64) ([]Orders, error) {
var resp []Orders
return resp,
l.SendAuthenticatedHTTPRequest(lakeBTCGetOrders, common.JoinStrings(ordersStr, ","), &resp)
l.SendAuthenticatedHTTPRequest(lakeBTCGetOrders, strings.Join(ordersStr, ","), &resp)
}
// CancelExistingOrder cancels an order by ID number and returns an error
@@ -201,7 +201,7 @@ func (l *LakeBTC) CancelExistingOrders(orderIDs []string) error {
}
resp := Response{}
params := common.JoinStrings(orderIDs, ",")
params := strings.Join(orderIDs, ",")
err := l.SendAuthenticatedHTTPRequest(lakeBTCCancelOrder, params, &resp)
if err != nil {
return err
@@ -271,7 +271,7 @@ func (l *LakeBTC) SendAuthenticatedHTTPRequest(method, params string, result int
postData := make(map[string]interface{})
postData["method"] = method
postData["id"] = 1
postData["params"] = common.SplitStrings(params, ",")
postData["params"] = strings.Split(params, ",")
data, err := common.JSONEncode(postData)
if err != nil {

View File

@@ -133,7 +133,7 @@ func (l *LakeBTC) FetchTradablePairs(asset assets.AssetType) ([]string, error) {
var currencies []string
for x := range result {
currencies = append(currencies, common.StringToUpper(x))
currencies = append(currencies, strings.ToUpper(x))
}
return currencies, nil

View File

@@ -684,7 +684,7 @@ func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, params
headers := make(map[string]string)
headers["Apiauth-Key"] = l.API.Credentials.Key
headers["Apiauth-Nonce"] = n
headers["Apiauth-Signature"] = common.StringToUpper(crypto.HexEncodeToString(hmac))
headers["Apiauth-Signature"] = strings.ToUpper(crypto.HexEncodeToString(hmac))
headers["Content-Type"] = "application/x-www-form-urlencoded"
if l.Verbose {

View File

@@ -10,6 +10,7 @@ import (
"net/http"
"net/http/httputil"
"net/url"
"strings"
"sync"
"time"
@@ -327,7 +328,7 @@ func (r *Requester) DoRequest(req *http.Request, path string, body io.Reader, re
default:
switch {
case common.StringContains(resp.Header.Get("Content-Type"), "application/json"):
case strings.Contains(resp.Header.Get("Content-Type"), "application/json"):
reader = resp.Body
default:

View File

@@ -3,10 +3,10 @@ package ticker
import (
"errors"
"strconv"
"strings"
"sync"
"time"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency"
"github.com/thrasher-/gocryptotrader/exchanges/assets"
)
@@ -45,7 +45,7 @@ type Ticker struct {
// PriceToString returns the string version of a stored price field
func (t *Ticker) PriceToString(p currency.Pair, priceType string, tickerType assets.AssetType) string {
priceType = common.StringToLower(priceType)
priceType = strings.ToLower(priceType)
switch priceType {
case "last":

View File

@@ -389,7 +389,7 @@ func TestSubscriptionWithExistingEntry(t *testing.T) {
w.SetChannelSubscriber(placeholderSubscriber)
w.subscribeToChannels()
if len(w.subscribedChannels) != 1 {
t.Errorf("Subscription should not have occured")
t.Errorf("Subscription should not have occurred")
}
}
@@ -410,7 +410,7 @@ func TestUnsubscriptionWithExistingEntry(t *testing.T) {
w.SetChannelUnsubscriber(placeholderSubscriber)
w.unsubscribeToChannels()
if len(w.subscribedChannels) != 1 {
t.Errorf("Unsubscription should not have occured")
t.Errorf("Unsubscription should not have occurred")
}
}

View File

@@ -138,7 +138,7 @@ func (y *Yobit) FetchTradablePairs(asset assets.AssetType) ([]string, error) {
var currencies []string
for x := range info.Pairs {
currencies = append(currencies, common.StringToUpper(x))
currencies = append(currencies, strings.ToUpper(x))
}
return currencies, nil

View File

@@ -13,6 +13,7 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/common/convert"
"github.com/thrasher-/gocryptotrader/common/crypto"
"github.com/thrasher-/gocryptotrader/currency"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
@@ -66,7 +67,7 @@ func (z *ZB) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error) {
return 0, err
}
if result.Code != 1000 {
return 0, fmt.Errorf("unsucessful new order, message: %s code: %d", result.Message, result.Code)
return 0, fmt.Errorf("unsuccessful new order, message: %s code: %d", result.Message, result.Code)
}
newOrderID, err := strconv.ParseInt(result.ID, 10, 64)
if err != nil {
@@ -252,7 +253,7 @@ func (z *ZB) GetSpotKline(arg KlinesRequestParams) (KLineResponse, error) {
return res, errors.New("zb rawKlines unmarshal failed")
}
for _, k := range rawKlineDatas {
ot, err := common.TimeFromUnixTimestampFloat(k[0])
ot, err := convert.TimeFromUnixTimestampFloat(k[0])
if err != nil {
return res, errors.New("zb cannot parse Kline.OpenTime")
}

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"net/url"
"strings"
"time"
"github.com/gorilla/websocket"
@@ -89,7 +90,7 @@ func (z *ZB) WsHandleData() {
continue
}
switch {
case common.StringContains(result.Channel, "markets"):
case strings.Contains(result.Channel, "markets"):
if !result.Success {
z.Websocket.DataHandler <- fmt.Errorf("zb_websocket.go error - unsuccessful market response %s", wsErrCodes[result.Code])
continue
@@ -102,8 +103,8 @@ func (z *ZB) WsHandleData() {
continue
}
case common.StringContains(result.Channel, "ticker"):
cPair := common.SplitStrings(result.Channel, "_")
case strings.Contains(result.Channel, "ticker"):
cPair := strings.Split(result.Channel, "_")
var ticker WsTicker
@@ -123,7 +124,7 @@ func (z *ZB) WsHandleData() {
LowPrice: ticker.Data.Low,
}
case common.StringContains(result.Channel, "depth"):
case strings.Contains(result.Channel, "depth"):
var depth WsDepth
err := common.JSONDecode(resp.Raw, &depth)
if err != nil {
@@ -149,7 +150,7 @@ func (z *ZB) WsHandleData() {
})
}
channelInfo := common.SplitStrings(result.Channel, "_")
channelInfo := strings.Split(result.Channel, "_")
cPair := currency.NewPairFromString(channelInfo[0])
var newOrderBook orderbook.Base
@@ -172,7 +173,7 @@ func (z *ZB) WsHandleData() {
Exchange: z.GetName(),
}
case common.StringContains(result.Channel, "trades"):
case strings.Contains(result.Channel, "trades"):
var trades WsTrades
err := common.JSONDecode(resp.Raw, &trades)
if err != nil {
@@ -183,7 +184,7 @@ func (z *ZB) WsHandleData() {
// Most up to date trade
t := trades.Data[len(trades.Data)-1]
channelInfo := common.SplitStrings(result.Channel, "_")
channelInfo := strings.Split(result.Channel, "_")
cPair := currency.NewPairFromString(channelInfo[0])
z.Websocket.DataHandler <- exchange.TradeData{

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"strconv"
"strings"
"sync"
"time"
@@ -179,7 +180,7 @@ func (z *ZB) UpdateTicker(p currency.Pair, assetType assets.AssetType) (ticker.P
}
for _, x := range z.GetEnabledPairs(assetType) {
currencySplit := common.SplitStrings(z.FormatExchangeCurrency(x, assetType).String(), "_")
currencySplit := strings.Split(z.FormatExchangeCurrency(x, assetType).String(), "_")
currency := currencySplit[0] + currencySplit[1]
var tp ticker.Price
tp.Pair = x
@@ -312,7 +313,7 @@ func (z *ZB) SubmitOrder(p currency.Pair, side exchange.OrderSide, _ exchange.Or
var params = SpotNewOrderRequestParams{
Amount: amount,
Price: price,
Symbol: common.StringToLower(p.String()),
Symbol: strings.ToLower(p.String()),
Type: oT,
}
response, err := z.SpotNewOrder(params)