From 01e2ab1499ec69de37d768dcea9b98f70f611993 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Wed, 29 Jan 2020 16:27:06 +1100 Subject: [PATCH] GCTCLI: Destination var/arg check usage fixes (#421) * GCTCLI param and linter fixes * Linter fixes * Add more basic validation and address codelingo nits * Add arg number support to cancelOrder and more validity checks --- cmd/gctcli/commands.go | 218 ++++++++++++++++------- exchanges/binance/binance.go | 2 +- exchanges/bitfinex/bitfinex.go | 2 +- exchanges/bitflyer/bitflyer.go | 2 +- exchanges/bithumb/bithumb.go | 2 +- exchanges/bitmex/bitmex.go | 2 +- exchanges/bitstamp/bitstamp.go | 2 +- exchanges/bittrex/bittrex.go | 2 +- exchanges/btcmarkets/btcmarkets.go | 2 +- exchanges/btse/btse.go | 2 +- exchanges/coinbene/coinbene.go | 2 +- exchanges/coinut/coinut.go | 2 +- exchanges/exmo/exmo.go | 2 +- exchanges/gateio/gateio.go | 3 +- exchanges/gemini/gemini.go | 2 +- exchanges/hitbtc/hitbtc.go | 2 +- exchanges/huobi/huobi.go | 2 +- exchanges/itbit/itbit.go | 2 +- exchanges/kraken/kraken.go | 2 +- exchanges/lakebtc/lakebtc.go | 2 +- exchanges/lbank/lbank.go | 2 +- exchanges/localbitcoins/localbitcoins.go | 2 +- exchanges/okcoin/okcoin.go | 2 +- exchanges/okex/okex.go | 2 +- exchanges/poloniex/poloniex.go | 2 +- exchanges/withdraw/withdraw_types.go | 6 +- exchanges/yobit/yobit.go | 2 +- exchanges/zb/zb.go | 2 +- 28 files changed, 182 insertions(+), 95 deletions(-) diff --git a/cmd/gctcli/commands.go b/cmd/gctcli/commands.go index e6f0f8d7..94989487 100644 --- a/cmd/gctcli/commands.go +++ b/cmd/gctcli/commands.go @@ -894,15 +894,18 @@ func addPortfolioAddress(c *cli.Context) error { } if c.IsSet("description") { - description = c.String("asset") + description = c.String("description") } else { description = c.Args().Get(2) } if c.IsSet("balance") { balance = c.Float64("balance") - } else { - balance, _ = strconv.ParseFloat(c.Args().Get(3), 64) + } else if c.Args().Get(3) != "" { + balance, err = strconv.ParseFloat(c.Args().Get(3), 64) + if err != nil { + return err + } } client := gctrpc.NewGoCryptoTraderClient(conn) @@ -973,7 +976,7 @@ func removePortfolioAddress(c *cli.Context) error { } if c.IsSet("description") { - description = c.String("asset") + description = c.String("description") } else { description = c.Args().Get(2) } @@ -1044,7 +1047,7 @@ func getForexRates(_ *cli.Context) error { var getOrdersCommand = cli.Command{ Name: "getorders", Usage: "gets the open orders", - ArgsUsage: " ", + ArgsUsage: " ", Action: getOrders, Flags: []cli.Flag{ cli.StringFlag{ @@ -1052,7 +1055,7 @@ var getOrdersCommand = cli.Command{ Usage: "the exchange to get orders for", }, cli.StringFlag{ - Name: "asset_type", + Name: "asset", Usage: "the asset type to get orders for", }, cli.StringFlag{ @@ -1077,8 +1080,8 @@ func getOrders(c *cli.Context) error { return errInvalidExchange } - if c.IsSet("asset_type") { - assetType = c.String("asset_type") + if c.IsSet("asset") { + assetType = c.String("asset") } else { assetType = c.Args().Get(1) } @@ -1187,7 +1190,7 @@ func getOrder(c *cli.Context) error { var submitOrderCommand = cli.Command{ Name: "submitorder", Usage: "submit order submits an exchange order", - ArgsUsage: " ", + ArgsUsage: " ", Action: submitOrder, Flags: []cli.Flag{ cli.StringFlag{ @@ -1203,7 +1206,7 @@ var submitOrderCommand = cli.Command{ Usage: "the order side to use (BUY OR SELL)", }, cli.StringFlag{ - Name: "order_type", + Name: "type", Usage: "the order type (MARKET OR LIMIT)", }, cli.Float64Flag{ @@ -1261,22 +1264,43 @@ func submitOrder(c *cli.Context) error { orderSide = c.Args().Get(2) } - if c.IsSet("order_type") { - orderType = c.String("order_type") + if orderSide == "" { + return errors.New("order side must be set") + } + + if c.IsSet("type") { + orderType = c.String("type") } else { orderType = c.Args().Get(3) } - if c.IsSet("amount") { - amount = c.Float64("amount") - } else { - amount, _ = strconv.ParseFloat(c.Args().Get(4), 64) + if orderType == "" { + return errors.New("order type must be set") } + if c.IsSet("amount") { + amount = c.Float64("amount") + } else if c.Args().Get(4) != "" { + var err error + amount, err = strconv.ParseFloat(c.Args().Get(4), 64) + if err != nil { + return err + } + } + + if amount == 0 { + return errors.New("amount must be set") + } + + // price is optional for market orders if c.IsSet("price") { price = c.Float64("price") - } else { - price, _ = strconv.ParseFloat(c.Args().Get(5), 64) + } else if c.Args().Get(5) != "" { + var err error + price, err = strconv.ParseFloat(c.Args().Get(5), 64) + if err != nil { + return err + } } if c.IsSet("client_id") { @@ -1376,10 +1400,22 @@ func simulateOrder(c *cli.Context) error { orderSide = c.Args().Get(2) } + if orderSide == "" { + return errors.New("side must be set") + } + if c.IsSet("amount") { amount = c.Float64("amount") - } else { - amount, _ = strconv.ParseFloat(c.Args().Get(3), 64) + } else if c.Args().Get(3) != "" { + var err error + amount, err = strconv.ParseFloat(c.Args().Get(3), 64) + if err != nil { + return err + } + } + + if amount == 0 { + return errors.New("amount must be set") } conn, err := setupClient() @@ -1470,10 +1506,18 @@ func whaleBomb(c *cli.Context) error { orderSide = c.Args().Get(2) } + if orderSide == "" { + return errors.New("order side must be set") + } + if c.IsSet("price") { price = c.Float64("price") - } else { - price, _ = strconv.ParseFloat(c.Args().Get(3), 64) + } else if c.Args().Get(3) != "" { + var err error + price, err = strconv.ParseFloat(c.Args().Get(3), 64) + if err != nil { + return err + } } conn, err := setupClient() @@ -1505,7 +1549,7 @@ func whaleBomb(c *cli.Context) error { var cancelOrderCommand = cli.Command{ Name: "cancelorder", Usage: "cancel order cancels an exchange order", - ArgsUsage: " ", + ArgsUsage: " ", Action: cancelOrder, Flags: []cli.Flag{ cli.StringFlag{ @@ -1525,7 +1569,7 @@ var cancelOrderCommand = cli.Command{ Usage: "the currency pair to cancel the order for", }, cli.StringFlag{ - Name: "asset_type", + Name: "asset", Usage: "the asset type", }, cli.Float64Flag{ @@ -1563,22 +1607,32 @@ func cancelOrder(c *cli.Context) error { return errInvalidExchange } + if c.IsSet("account_id") { + accountID = c.String("account_id") + } else { + accountID = c.Args().Get(1) + } + if c.IsSet("order_id") { orderID = c.String("order_id") } else { orderID = c.Args().Get(2) } - if c.IsSet("account_id") { - accountID = c.String("account_id") + if orderID == "" { + return errors.New("an order ID must be set") } if c.IsSet("pair") { currencyPair = c.String("pair") + } else { + currencyPair = c.Args().Get(3) } - if c.IsSet("asset_type") { - assetType = c.String("asset_type") + if c.IsSet("asset") { + assetType = c.String("asset") + } else { + assetType = c.Args().Get(4) } assetType = strings.ToLower(assetType) @@ -1588,12 +1642,17 @@ func cancelOrder(c *cli.Context) error { if c.IsSet("wallet_address") { walletAddress = c.String("wallet_address") + } else { + walletAddress = c.Args().Get(5) } - if c.IsSet("order_side") { - orderSide = c.String("order_side") + if c.IsSet("side") { + orderSide = c.String("side") + } else { + orderSide = c.Args().Get(6) } + // pair is optional, but if it's set, do a validity check var p currency.Pair if len(currencyPair) > 0 { if !validPair(currencyPair) { @@ -1702,7 +1761,7 @@ func getEvents(_ *cli.Context) error { var addEventCommand = cli.Command{ Name: "addevent", Usage: "adds an event", - ArgsUsage: " ", + ArgsUsage: " ", Action: addEvent, Flags: []cli.Flag{ cli.StringFlag{ @@ -1738,7 +1797,7 @@ var addEventCommand = cli.Command{ Usage: "the currency pair", }, cli.StringFlag{ - Name: "asset_type", + Name: "asset", Usage: "the asset type", }, cli.StringFlag{ @@ -1771,6 +1830,10 @@ func addEvent(c *cli.Context) error { return fmt.Errorf("exchange name is required") } + if !validExchange(exchangeName) { + return errInvalidExchange + } + if c.IsSet("item") { item = c.String("item") } else { @@ -1805,8 +1868,12 @@ func addEvent(c *cli.Context) error { return fmt.Errorf("currency pair is required") } - if c.IsSet("asset_type") { - assetType = c.String("asset_type") + if !validPair(currencyPair) { + return errInvalidPair + } + + if c.IsSet("asset") { + assetType = c.String("asset") } assetType = strings.ToLower(assetType) @@ -1820,10 +1887,6 @@ func addEvent(c *cli.Context) error { return fmt.Errorf("action is required") } - if !validPair(currencyPair) { - return errInvalidPair - } - conn, err := setupClient() if err != nil { return err @@ -1880,12 +1943,16 @@ func removeEvent(c *cli.Context) error { var eventID int64 if c.IsSet("event_id") { eventID = c.Int64("event_id") - } else { - evtID, err := strconv.Atoi(c.Args().Get(0)) + } else if c.Args().Get(0) != "" { + var err error + eventID, err = strconv.ParseInt(c.Args().Get(0), 10, 64) if err != nil { - return fmt.Errorf("unable to strconv input to int. Err: %s", err) + return err } - eventID = int64(evtID) + } + + if eventID == 0 { + return errors.New("event id must be specified") } conn, err := setupClient() @@ -1990,10 +2057,14 @@ func getCryptocurrencyDepositAddress(c *cli.Context) error { if c.IsSet("cryptocurrency") { cryptocurrency = c.String("cryptocurrency") - } else { + } else if c.Args().Get(1) != "" { cryptocurrency = c.Args().Get(1) } + if cryptocurrency == "" { + return errors.New("cryptocurrency must be set") + } + conn, err := setupClient() if err != nil { return err @@ -2083,6 +2154,10 @@ func getLoggerDetails(c *cli.Context) error { logger = c.Args().First() } + if logger == "" { + return errors.New("a logger must be specified") + } + conn, err := setupClient() if err != nil { return err @@ -2135,12 +2210,20 @@ func setLoggerDetails(c *cli.Context) error { logger = c.Args().First() } + if logger == "" { + return errors.New("a logger must be specified") + } + if c.IsSet("level") { level = c.String("level") } else { level = c.Args().Get(1) } + if level == "" { + return errors.New("level must be specified") + } + conn, err := setupClient() if err != nil { return err @@ -2408,7 +2491,7 @@ func disableExchangePair(c *cli.Context) error { var getOrderbookStreamCommand = cli.Command{ Name: "getorderbookstream", Usage: "gets the orderbook stream for a specific currency pair and exchange", - ArgsUsage: " ", + ArgsUsage: " ", Action: getOrderbookStream, Flags: []cli.Flag{ cli.StringFlag{ @@ -2616,7 +2699,7 @@ func getExchangeOrderbookStream(c *cli.Context) error { var getTickerStreamCommand = cli.Command{ Name: "gettickerstream", Usage: "gets the ticker stream for a specific currency pair and exchange", - ArgsUsage: " ", + ArgsUsage: " ", Action: getTickerStream, Flags: []cli.Flag{ cli.StringFlag{ @@ -2868,7 +2951,7 @@ func getAuditEvent(c *cli.Context) error { if !c.IsSet("limit") { if c.Args().Get(3) != "" { - limitStr, err := strconv.ParseInt(c.Args().Get(3), 10, 32) + limitStr, err := strconv.ParseInt(c.Args().Get(3), 10, 64) if err == nil { limit = int(limitStr) } @@ -3351,6 +3434,7 @@ func gctScriptUpload(c *cli.Context) error { return nil } +var candleRangeSize, candleGranularity int64 var getHistoricCandlesCommand = cli.Command{ Name: "gethistoriccandles", Usage: "gets historical candles for the specified granularity up to range size time from now.", @@ -3365,13 +3449,17 @@ var getHistoricCandlesCommand = cli.Command{ Name: "pair", Usage: "the currency pair to get the candles for", }, - cli.IntFlag{ - Name: "rangesize, r", - Usage: "the amount of time to go back from now to fetch candles in the given granularity", + cli.Int64Flag{ + Name: "rangesize, r", + Usage: "the amount of time to go back from now to fetch candles in the given granularity", + Value: 10, + Destination: &candleRangeSize, }, - cli.IntFlag{ - Name: "granularity, g", - Usage: "value is in seconds and can be one of the following {60, 300, 900, 3600, 21600, 86400}", + cli.Int64Flag{ + Name: "granularity, g", + Usage: "value is in seconds and can be one of the following {60, 300, 900, 3600, 21600, 86400}", + Value: 86400, + Destination: &candleGranularity, }, }, } @@ -3403,26 +3491,24 @@ func getHistoricCandles(c *cli.Context) error { } p := currency.NewPairDelimiter(currencyPair, pairDelimiter) - var rangesize int64 if c.IsSet("rangesize") { - rangesize = c.Int64("rangesize") - } else { - rs, err := strconv.Atoi(c.Args().Get(2)) + candleRangeSize = c.Int64("rangesize") + } else if c.Args().Get(2) != "" { + var err error + candleRangeSize, err = strconv.ParseInt(c.Args().Get(2), 10, 64) if err != nil { - return fmt.Errorf("unable to strconv input to int. Err: %s", err) + return err } - rangesize = int64(rs) } - var granularity int64 if c.IsSet("granularity") { - granularity = c.Int64("granularity") - } else { - gr, err := strconv.Atoi(c.Args().Get(3)) + candleGranularity = c.Int64("granularity") + } else if c.Args().Get(3) != "" { + var err error + candleGranularity, err = strconv.ParseInt(c.Args().Get(3), 10, 64) if err != nil { - return fmt.Errorf("unable to strconv input to int. Err: %s", err) + return err } - granularity = int64(gr) } conn, err := setupClient() @@ -3440,8 +3526,8 @@ func getHistoricCandles(c *cli.Context) error { Base: p.Base.String(), Quote: p.Quote.String(), }, - Rangesize: rangesize, - Granularity: granularity, + Rangesize: candleRangeSize, + Granularity: candleGranularity, }) if err != nil { diff --git a/exchanges/binance/binance.go b/exchanges/binance/binance.go index 2869099a..fabc05d3 100644 --- a/exchanges/binance/binance.go +++ b/exchanges/binance/binance.go @@ -72,7 +72,7 @@ type Binance struct { validIntervals []TimeInterval } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (b *Binance) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/bitfinex/bitfinex.go b/exchanges/bitfinex/bitfinex.go index 0dbf285e..aaa127aa 100644 --- a/exchanges/bitfinex/bitfinex.go +++ b/exchanges/bitfinex/bitfinex.go @@ -91,7 +91,7 @@ type Bitfinex struct { WebsocketSubdChannels map[int]WebsocketChanInfo } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (b *Bitfinex) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/bitflyer/bitflyer.go b/exchanges/bitflyer/bitflyer.go index 7bacc7d4..313aec59 100644 --- a/exchanges/bitflyer/bitflyer.go +++ b/exchanges/bitflyer/bitflyer.go @@ -71,7 +71,7 @@ type Bitflyer struct { exchange.Base } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (b *Bitflyer) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/bithumb/bithumb.go b/exchanges/bithumb/bithumb.go index f9bb94c0..f8517d23 100644 --- a/exchanges/bithumb/bithumb.go +++ b/exchanges/bithumb/bithumb.go @@ -56,7 +56,7 @@ type Bithumb struct { exchange.Base } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (b *Bithumb) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/bitmex/bitmex.go b/exchanges/bitmex/bitmex.go index dbae21a5..e183e07f 100644 --- a/exchanges/bitmex/bitmex.go +++ b/exchanges/bitmex/bitmex.go @@ -910,7 +910,7 @@ func calculateTradingFee(purchasePrice, amount float64, isMaker bool) float64 { return fee * purchasePrice * amount } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (b *Bitmex) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/bitstamp/bitstamp.go b/exchanges/bitstamp/bitstamp.go index c53a398b..834aeef2 100644 --- a/exchanges/bitstamp/bitstamp.go +++ b/exchanges/bitstamp/bitstamp.go @@ -64,7 +64,7 @@ type Bitstamp struct { WebsocketConn *wshandler.WebsocketConnection } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (b *Bitstamp) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/bittrex/bittrex.go b/exchanges/bittrex/bittrex.go index 8d49567b..7e6cdb5d 100644 --- a/exchanges/bittrex/bittrex.go +++ b/exchanges/bittrex/bittrex.go @@ -63,7 +63,7 @@ type Bittrex struct { exchange.Base } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (b *Bittrex) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/btcmarkets/btcmarkets.go b/exchanges/btcmarkets/btcmarkets.go index c167ed37..82809ccb 100644 --- a/exchanges/btcmarkets/btcmarkets.go +++ b/exchanges/btcmarkets/btcmarkets.go @@ -82,7 +82,7 @@ type BTCMarkets struct { WebsocketConn *wshandler.WebsocketConnection } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (b *BTCMarkets) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/btse/btse.go b/exchanges/btse/btse.go index 9b4f481a..c2b2a479 100644 --- a/exchanges/btse/btse.go +++ b/exchanges/btse/btse.go @@ -326,7 +326,7 @@ func parseOrderTime(timeStr string) (time.Time, error) { return time.Parse(btseTimeLayout, timeStr) } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (b *BTSE) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/coinbene/coinbene.go b/exchanges/coinbene/coinbene.go index 85086be8..dcd56549 100644 --- a/exchanges/coinbene/coinbene.go +++ b/exchanges/coinbene/coinbene.go @@ -1074,7 +1074,7 @@ func (c *Coinbene) SendAuthHTTPRequest(method, path, epPath string, isSwap bool, return json.Unmarshal(resp, result) } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (c *Coinbene) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrFunctionNotSupported } diff --git a/exchanges/coinut/coinut.go b/exchanges/coinut/coinut.go index c29b43f8..8d9531fe 100644 --- a/exchanges/coinut/coinut.go +++ b/exchanges/coinut/coinut.go @@ -56,7 +56,7 @@ type COINUT struct { instrumentMap instrumentMap } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (c *COINUT) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/exmo/exmo.go b/exchanges/exmo/exmo.go index 554ef625..29de8937 100644 --- a/exchanges/exmo/exmo.go +++ b/exchanges/exmo/exmo.go @@ -49,7 +49,7 @@ type EXMO struct { exchange.Base } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (e *EXMO) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/gateio/gateio.go b/exchanges/gateio/gateio.go index 2115559b..6d572373 100644 --- a/exchanges/gateio/gateio.go +++ b/exchanges/gateio/gateio.go @@ -48,8 +48,7 @@ type Gateio struct { exchange.Base } -// GetHistoriCandles -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (g *Gateio) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/gemini/gemini.go b/exchanges/gemini/gemini.go index 744c1b0c..3ad64f9b 100644 --- a/exchanges/gemini/gemini.go +++ b/exchanges/gemini/gemini.go @@ -446,7 +446,7 @@ func calculateTradingFee(notionVolume *NotionalVolume, purchasePrice, amount flo return volumeFee * amount * purchasePrice } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (g *Gemini) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrFunctionNotSupported } diff --git a/exchanges/hitbtc/hitbtc.go b/exchanges/hitbtc/hitbtc.go index ba0d2b76..33e1c33d 100644 --- a/exchanges/hitbtc/hitbtc.go +++ b/exchanges/hitbtc/hitbtc.go @@ -51,7 +51,7 @@ type HitBTC struct { WebsocketConn *wshandler.WebsocketConnection } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (h *HitBTC) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/huobi/huobi.go b/exchanges/huobi/huobi.go index 783bcd9f..430d0717 100644 --- a/exchanges/huobi/huobi.go +++ b/exchanges/huobi/huobi.go @@ -70,7 +70,7 @@ type HUOBI struct { AuthenticatedWebsocketConn *wshandler.WebsocketConnection } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (h *HUOBI) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/itbit/itbit.go b/exchanges/itbit/itbit.go index 84d41816..59e68db9 100644 --- a/exchanges/itbit/itbit.go +++ b/exchanges/itbit/itbit.go @@ -40,7 +40,7 @@ type ItBit struct { exchange.Base } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (i *ItBit) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/kraken/kraken.go b/exchanges/kraken/kraken.go index 665b2fce..74134815 100644 --- a/exchanges/kraken/kraken.go +++ b/exchanges/kraken/kraken.go @@ -64,7 +64,7 @@ type Kraken struct { wsRequestMtx sync.Mutex } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (k *Kraken) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/lakebtc/lakebtc.go b/exchanges/lakebtc/lakebtc.go index 92f6e06b..8aa7a0ce 100644 --- a/exchanges/lakebtc/lakebtc.go +++ b/exchanges/lakebtc/lakebtc.go @@ -41,7 +41,7 @@ type LakeBTC struct { WebsocketConn } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (l *LakeBTC) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/lbank/lbank.go b/exchanges/lbank/lbank.go index d105f2e0..76622669 100644 --- a/exchanges/lbank/lbank.go +++ b/exchanges/lbank/lbank.go @@ -581,7 +581,7 @@ func (l *Lbank) SendAuthHTTPRequest(method, endpoint string, vals url.Values, re l.HTTPRecording) } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (l *Lbank) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrFunctionNotSupported } diff --git a/exchanges/localbitcoins/localbitcoins.go b/exchanges/localbitcoins/localbitcoins.go index f71381ed..f9509223 100644 --- a/exchanges/localbitcoins/localbitcoins.go +++ b/exchanges/localbitcoins/localbitcoins.go @@ -113,7 +113,7 @@ type LocalBitcoins struct { exchange.Base } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (l *LocalBitcoins) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrFunctionNotSupported } diff --git a/exchanges/okcoin/okcoin.go b/exchanges/okcoin/okcoin.go index 2352cf89..2e1c88e9 100644 --- a/exchanges/okcoin/okcoin.go +++ b/exchanges/okcoin/okcoin.go @@ -22,7 +22,7 @@ type OKCoin struct { okgroup.OKGroup } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (o *OKCoin) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrFunctionNotSupported } diff --git a/exchanges/okex/okex.go b/exchanges/okex/okex.go index 6020a264..32c8ebf3 100644 --- a/exchanges/okex/okex.go +++ b/exchanges/okex/okex.go @@ -47,7 +47,7 @@ type OKEX struct { okgroup.OKGroup } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (o *OKEX) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrFunctionNotSupported } diff --git a/exchanges/poloniex/poloniex.go b/exchanges/poloniex/poloniex.go index 91946905..b8c68f65 100644 --- a/exchanges/poloniex/poloniex.go +++ b/exchanges/poloniex/poloniex.go @@ -60,7 +60,7 @@ type Poloniex struct { WebsocketConn *wshandler.WebsocketConnection } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (p *Poloniex) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/withdraw/withdraw_types.go b/exchanges/withdraw/withdraw_types.go index c5ba9094..de2dffb8 100644 --- a/exchanges/withdraw/withdraw_types.go +++ b/exchanges/withdraw/withdraw_types.go @@ -11,15 +11,17 @@ const ( ErrStrAmountMustBeGreaterThanZero = "amount must be greater than 0" // ErrStrAddressisInvalid message to return when address is invalid for crypto request ErrStrAddressisInvalid = "address is not valid" - // ErrStrAddressNotSet message to returh when address is empty + // ErrStrAddressNotSet message to return when address is empty ErrStrAddressNotSet = "address cannot be empty" // ErrStrNoCurrencySet message to return when no currency is set ErrStrNoCurrencySet = "currency not set" ) var ( + // ErrRequestCannotBeNil message to return when a request is nil ErrRequestCannotBeNil = errors.New("request cannot be nil") - ErrInvalidRequest = errors.New("invalid request type") + // ErrInvalidRequest message to return when a request is invalid + ErrInvalidRequest = errors.New("invalid request type") ) // GenericInfo stores genric withdraw request info diff --git a/exchanges/yobit/yobit.go b/exchanges/yobit/yobit.go index f6b3ee79..80e6265b 100644 --- a/exchanges/yobit/yobit.go +++ b/exchanges/yobit/yobit.go @@ -43,7 +43,7 @@ type Yobit struct { exchange.Base } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (y *Yobit) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented } diff --git a/exchanges/zb/zb.go b/exchanges/zb/zb.go index 89ac80ad..3bc9e897 100644 --- a/exchanges/zb/zb.go +++ b/exchanges/zb/zb.go @@ -48,7 +48,7 @@ type ZB struct { exchange.Base } -// GetHistoriCandles returns _rangesize_ number of candles for the given _granularity_ and _pair_ starting from the latest available +// GetHistoricCandles returns rangesize number of candles for the given granularity and pair starting from the latest available func (z *ZB) GetHistoricCandles(pair currency.Pair, rangesize, granularity int64) ([]exchange.Candle, error) { return nil, common.ErrNotYetImplemented }