linter: Enable gofumpt and run against codebase (#1848)

* linter: Enable gofumpt and run against codebase

* Address shazbert's nits

* gofumpt: Fix issues after rebase
This commit is contained in:
Adrian Gallagher
2025-03-18 10:23:16 +11:00
committed by GitHub
parent 748ed71455
commit f5faca2eb2
189 changed files with 1541 additions and 1104 deletions

View File

@@ -595,7 +595,8 @@ func fillData(exchName, checkType string, data interface{}) (ExchangeInfo, error
TokenData: tempData.TokenData,
TokenDataEnd: tempData.TokenDataEnd,
Val: tempData.Val,
Path: tempData.Path},
Path: tempData.Path,
},
},
}, nil
default:
@@ -1235,7 +1236,8 @@ func sendGetReq(path string, result interface{}) error {
Method: http.MethodGet,
Path: path,
Result: result,
Verbose: verbose}
Verbose: verbose,
}
return requester.SendPayload(context.Background(), request.Unset, func() (*request.Item, error) {
return item, nil
}, request.UnauthenticatedRequest)
@@ -1253,7 +1255,8 @@ func sendAuthReq(method, path string, result interface{}) error {
Method: method,
Path: path,
Result: result,
Verbose: verbose}
Verbose: verbose,
}
return requester.SendPayload(context.Background(), request.Unset, func() (*request.Item, error) {
return item, nil
}, request.AuthenticatedRequest)

View File

@@ -131,14 +131,16 @@ func TestCheckExistingExchanges(t *testing.T) {
func TestCheckChangeLog(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{TokenData: "h1",
data := HTMLScrapingData{
TokenData: "h1",
Key: "id",
Val: "revision-history",
TokenDataEnd: "table",
TextTokenData: "td",
DateFormat: "2006/01/02",
RegExp: `^20(\d){2}/(\d){2}/(\d){2}$`,
Path: "https://docs.gemini.com/rest-api/#revision-history"}
Path: "https://docs.gemini.com/rest-api/#revision-history",
}
if _, err := checkChangeLog(&data); err != nil {
t.Error(err)
}
@@ -162,7 +164,8 @@ func TestAdd(t *testing.T) {
func TestHTMLScrapeGemini(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{TokenData: "h1",
data := HTMLScrapingData{
TokenData: "h1",
Key: "id",
Val: "revision-history",
TokenDataEnd: "table",
@@ -170,7 +173,8 @@ func TestHTMLScrapeGemini(t *testing.T) {
DateFormat: "2006/01/02",
RegExp: "^20(\\d){2}/(\\d){2}/(\\d){2}$",
CheckString: "2019/11/15",
Path: "https://docs.gemini.com/rest-api/#revision-history"}
Path: "https://docs.gemini.com/rest-api/#revision-history",
}
_, err := htmlScrapeDefault(&data)
if err != nil {
t.Error(err)
@@ -179,7 +183,8 @@ func TestHTMLScrapeGemini(t *testing.T) {
func TestHTMLScrapeHuobi(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{TokenData: "h1",
data := HTMLScrapingData{
TokenData: "h1",
Key: "id",
Val: "change-log",
TokenDataEnd: "h2",
@@ -187,7 +192,8 @@ func TestHTMLScrapeHuobi(t *testing.T) {
DateFormat: "2006.01.02 15:04",
RegExp: "^20(\\d){2}.(\\d){2}.(\\d){2} (\\d){2}:(\\d){2}$",
CheckString: "2019.12.27 19:00",
Path: "https://huobiapi.github.io/docs/spot/v1/en/#change-log"}
Path: "https://huobiapi.github.io/docs/spot/v1/en/#change-log",
}
_, err := htmlScrapeDefault(&data)
if err != nil {
t.Error(err)
@@ -196,7 +202,8 @@ func TestHTMLScrapeHuobi(t *testing.T) {
func TestHTMLScrapeCoinbasepro(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{TokenData: "h1",
data := HTMLScrapingData{
TokenData: "h1",
Key: "id",
Val: "changelog",
TokenDataEnd: "ul",
@@ -204,7 +211,8 @@ func TestHTMLScrapeCoinbasepro(t *testing.T) {
DateFormat: "01/02/06",
RegExp: "^(\\d){1,2}/(\\d){1,2}/(\\d){2}$",
CheckString: "12/16/19",
Path: "https://docs.pro.coinbase.com/#changelog"}
Path: "https://docs.pro.coinbase.com/#changelog",
}
_, err := htmlScrapeDefault(&data)
if err != nil {
t.Error(err)
@@ -213,9 +221,11 @@ func TestHTMLScrapeCoinbasepro(t *testing.T) {
func TestHTMLScrapeBitfinex(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{DateFormat: "2006-01-02",
RegExp: `section-v-(2\d{3}-\d{1,2}-\d{1,2})`,
Path: "https://docs.bitfinex.com/docs/changelog"}
data := HTMLScrapingData{
DateFormat: "2006-01-02",
RegExp: `section-v-(2\d{3}-\d{1,2}-\d{1,2})`,
Path: "https://docs.bitfinex.com/docs/changelog",
}
_, err := htmlScrapeBitfinex(&data)
if err != nil {
t.Error(err)
@@ -224,14 +234,16 @@ func TestHTMLScrapeBitfinex(t *testing.T) {
func TestHTMLScrapeBitmex(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{TokenData: "h4",
data := HTMLScrapingData{
TokenData: "h4",
Key: "id",
Val: "",
TokenDataEnd: "",
TextTokenData: "",
DateFormat: "Jan-2-2006",
RegExp: `([A-Z]{1}[a-z]{2}-\d{1,2}-2\d{3})`,
Path: "https://www.bitmex.com/static/md/en-US/apiChangelog"}
Path: "https://www.bitmex.com/static/md/en-US/apiChangelog",
}
if _, err := htmlScrapeBitmex(&data); err != nil {
t.Error(err)
}
@@ -239,8 +251,10 @@ func TestHTMLScrapeBitmex(t *testing.T) {
func TestHTMLScrapeHitBTC(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{RegExp: `newest version \d{1}.\d{1}`,
Path: "https://api.hitbtc.com/"}
data := HTMLScrapingData{
RegExp: `newest version \d{1}.\d{1}`,
Path: "https://api.hitbtc.com/",
}
if _, err := htmlScrapeHitBTC(&data); err != nil {
t.Error(err)
}
@@ -248,8 +262,10 @@ func TestHTMLScrapeHitBTC(t *testing.T) {
func TestHTMLScrapeBTSE(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{RegExp: `^version: \d{1}.\d{1}.\d{1}`,
Path: "https://api.btcmarkets.net/openapi/info/index.yaml"}
data := HTMLScrapingData{
RegExp: `^version: \d{1}.\d{1}.\d{1}`,
Path: "https://api.btcmarkets.net/openapi/info/index.yaml",
}
if _, err := htmlScrapeBTSE(&data); err != nil {
t.Error(err)
}
@@ -257,8 +273,10 @@ func TestHTMLScrapeBTSE(t *testing.T) {
func TestHTMLScrapeBTCMarkets(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{RegExp: `^version: \d{1}.\d{1}.\d{1}`,
Path: "https://api.btcmarkets.net/openapi/info/index.yaml"}
data := HTMLScrapingData{
RegExp: `^version: \d{1}.\d{1}.\d{1}`,
Path: "https://api.btcmarkets.net/openapi/info/index.yaml",
}
if _, err := htmlScrapeBTCMarkets(&data); err != nil {
t.Error(err)
}
@@ -266,11 +284,13 @@ func TestHTMLScrapeBTCMarkets(t *testing.T) {
func TestHTMLScrapeBitflyer(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{TokenData: "p",
data := HTMLScrapingData{
TokenData: "p",
TokenDataEnd: "h3",
TextTokenData: "code",
RegExp: `^https://api.bitflyer.com/v\d{1}/$`,
Path: "https://lightning.bitflyer.com/docs?lang=en"}
Path: "https://lightning.bitflyer.com/docs?lang=en",
}
if _, err := htmlScrapeBitflyer(&data); err != nil {
t.Error(err)
}
@@ -278,8 +298,10 @@ func TestHTMLScrapeBitflyer(t *testing.T) {
func TestHTMLScrapeANX(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{RegExp: `ANX Exchange API v\d{1}`,
Path: "https://anxv3.docs.apiary.io/#reference/quickstart-catalog"}
data := HTMLScrapingData{
RegExp: `ANX Exchange API v\d{1}`,
Path: "https://anxv3.docs.apiary.io/#reference/quickstart-catalog",
}
if _, err := htmlScrapeANX(&data); err != nil {
t.Error(err)
}
@@ -287,14 +309,16 @@ func TestHTMLScrapeANX(t *testing.T) {
func TestHTMLPoloniex(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{TokenData: "h1",
data := HTMLScrapingData{
TokenData: "h1",
Key: "id",
Val: "changelog",
TokenDataEnd: "div",
TextTokenData: "h2",
DateFormat: "2006-01-02",
RegExp: `(2\d{3}-\d{1,2}-\d{1,2})`,
Path: "https://docs.poloniex.com/#changelog"}
Path: "https://docs.poloniex.com/#changelog",
}
if _, err := htmlScrapePoloniex(&data); err != nil {
t.Error(err)
}
@@ -302,8 +326,10 @@ func TestHTMLPoloniex(t *testing.T) {
func TestHTMLScrapeExmo(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{RegExp: `Last updated on [\s\S]*, 20\d{2}`,
Path: "https://exmo.com/en/api/"}
data := HTMLScrapingData{
RegExp: `Last updated on [\s\S]*, 20\d{2}`,
Path: "https://exmo.com/en/api/",
}
if _, err := htmlScrapeExmo(&data); err != nil {
t.Error(err)
}
@@ -311,8 +337,10 @@ func TestHTMLScrapeExmo(t *testing.T) {
func TestHTMLBitstamp(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{RegExp: `refer to the v\d{1} API for future references.`,
Path: "https://www.bitstamp.net/api/"}
data := HTMLScrapingData{
RegExp: `refer to the v\d{1} API for future references.`,
Path: "https://www.bitstamp.net/api/",
}
if _, err := htmlScrapeBitstamp(&data); err != nil {
t.Error(err)
}
@@ -320,11 +348,13 @@ func TestHTMLBitstamp(t *testing.T) {
func TestHTMLKraken(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{TokenData: "h3",
data := HTMLScrapingData{
TokenData: "h3",
TokenDataEnd: "p",
TextTokenData: "p",
RegExp: `URL: https://api.kraken.com/\d{1}/private/Balance`,
Path: "https://www.kraken.com/features/api"}
Path: "https://www.kraken.com/features/api",
}
if _, err := htmlScrapeKraken(&data); err != nil {
t.Error(err)
}
@@ -332,13 +362,15 @@ func TestHTMLKraken(t *testing.T) {
func TestHTMLAlphaPoint(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{TokenData: "h1",
data := HTMLScrapingData{
TokenData: "h1",
Key: "id",
Val: "introduction",
TokenDataEnd: "blockquote",
TextTokenData: "h3",
RegExp: `revised-calls-\d{1}-\d{1}-\d{1}-gt-\d{1}-\d{1}-\d{1}`,
Path: "https://alphapoint.github.io/slate/#introduction"}
Path: "https://alphapoint.github.io/slate/#introduction",
}
if _, err := htmlScrapeAlphaPoint(&data); err != nil {
t.Error(err)
}
@@ -346,9 +378,11 @@ func TestHTMLAlphaPoint(t *testing.T) {
func TestHTMLYobit(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{TokenData: "h2",
Key: "id",
Path: "https://www.yobit.net/en/api/"}
data := HTMLScrapingData{
TokenData: "h2",
Key: "id",
Path: "https://www.yobit.net/en/api/",
}
if _, err := htmlScrapeYobit(&data); err != nil {
t.Error(err)
}
@@ -356,12 +390,14 @@ func TestHTMLYobit(t *testing.T) {
func TestHTMLScrapeOk(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{TokenData: "a",
data := HTMLScrapingData{
TokenData: "a",
Key: "href",
Val: "./#change-change",
TokenDataEnd: "./#change-",
RegExp: `./#change-\d{8}`,
Path: "https://www.okx.com/docs/en/"}
Path: "https://www.okx.com/docs/en/",
}
if _, err := htmlScrapeOk(&data); err != nil {
t.Error(err)
}
@@ -375,10 +411,14 @@ func TestUpdate(t *testing.T) {
exchCheck = *configData.Exchanges[x].Data.HTMLData
}
}
info := ExchangeInfo{Name: "Exmo",
info := ExchangeInfo{
Name: "Exmo",
CheckType: "HTML String Check",
Data: &CheckData{HTMLData: &HTMLScrapingData{RegExp: `Last updated on [\s\S]*, 20\d{2}`,
Path: "https://exmo.com/en/api/"},
Data: &CheckData{
HTMLData: &HTMLScrapingData{
RegExp: `Last updated on [\s\S]*, 20\d{2}`,
Path: "https://exmo.com/en/api/",
},
},
}
updatedExchs := update("Exmo", configData.Exchanges, info)

View File

@@ -13,9 +13,7 @@ import (
"github.com/urfave/cli/v2"
)
var (
dbConn *database.Instance
)
var dbConn *database.Instance
func load(c *cli.Context) error {
var conf config.Config

View File

@@ -122,7 +122,6 @@ func addSingleExchange(c *cli.Context) error {
err = exchangeDB.Insert(exchangeDB.Details{
Name: exchangeName,
})
if err != nil {
return err
}

View File

@@ -38,7 +38,8 @@ const (
var (
// DefaultExcludedDirectories defines the basic directory exclusion list for GCT
DefaultExcludedDirectories = []string{".github",
DefaultExcludedDirectories = []string{
".github",
".git",
"node_modules",
".vscode",
@@ -335,7 +336,8 @@ func main() {
dirList,
tmpl,
contributors,
&config})
&config,
})
fmt.Println("\nDocumentation Generation Tool - Finished")
}

View File

@@ -34,9 +34,7 @@ type exchange struct {
FIX bool
}
var (
errInvalidExchangeName = errors.New("invalid exchange name")
)
var errInvalidExchangeName = errors.New("invalid exchange name")
func main() {
var newExchangeName string
@@ -260,7 +258,7 @@ func runCommand(dir, param string) error {
func newFile(path string) {
_, err := os.Stat(path)
if os.IsNotExist(err) {
var file, err = os.Create(path)
file, err := os.Create(path)
if err != nil {
log.Fatal(err)
}

View File

@@ -682,7 +682,7 @@ func getPairFromPairs(t *testing.T, p currency.Pairs) (currency.Pair, error) {
// isFiat helps determine fiat currency without using currency.storage
func isFiat(t *testing.T, c string) bool {
t.Helper()
var fiats = []string{
fiats := []string{
currency.USD.Item.Lower,
currency.AUD.Item.Lower,
currency.EUR.Item.Lower,

View File

@@ -18,8 +18,10 @@ import (
"github.com/urfave/cli/v2"
)
var startTime, endTime, orderingDirection string
var limit int
var (
startTime, endTime, orderingDirection string
limit int
)
var getInfoCommand = &cli.Command{
Name: "getinfo",
@@ -38,7 +40,6 @@ func getInfo(c *cli.Context) error {
result, err := client.GetInfo(c.Context,
&gctrpc.GetInfoRequest{},
)
if err != nil {
return err
}
@@ -64,7 +65,6 @@ func getSubsystems(c *cli.Context) error {
result, err := client.GetSubsystems(c.Context,
&gctrpc.GetSubsystemsRequest{},
)
if err != nil {
return err
}
@@ -114,7 +114,6 @@ func enableSubsystem(c *cli.Context) error {
Subsystem: subsystemName,
},
)
if err != nil {
return err
}
@@ -164,7 +163,6 @@ func disableSubsystem(c *cli.Context) error {
Subsystem: subsystemName,
},
)
if err != nil {
return err
}
@@ -190,7 +188,6 @@ func getRPCEndpoints(c *cli.Context) error {
result, err := client.GetRPCEndpoints(c.Context,
&gctrpc.GetRPCEndpointsRequest{},
)
if err != nil {
return err
}
@@ -216,7 +213,6 @@ func getCommunicationRelayers(c *cli.Context) error {
result, err := client.GetCommunicationRelayers(c.Context,
&gctrpc.GetCommunicationRelayersRequest{},
)
if err != nil {
return err
}
@@ -256,7 +252,6 @@ func getExchanges(c *cli.Context) error {
Enabled: enabledOnly,
},
)
if err != nil {
return err
}
@@ -302,7 +297,6 @@ func enableExchange(c *cli.Context) error {
Exchange: exchangeName,
},
)
if err != nil {
return err
}
@@ -348,7 +342,6 @@ func disableExchange(c *cli.Context) error {
Exchange: exchangeName,
},
)
if err != nil {
return err
}
@@ -394,7 +387,6 @@ func getExchangeOTPCode(c *cli.Context) error {
Exchange: exchangeName,
},
)
if err != nil {
return err
}
@@ -419,7 +411,6 @@ func getExchangeOTPCodes(c *cli.Context) error {
client := gctrpc.NewGoCryptoTraderServiceClient(conn)
result, err := client.GetExchangeOTPCodes(c.Context,
&gctrpc.GetExchangeOTPsRequest{})
if err != nil {
return err
}
@@ -465,7 +456,6 @@ func getExchangeInfo(c *cli.Context) error {
Exchange: exchangeName,
},
)
if err != nil {
return err
}
@@ -554,7 +544,6 @@ func getTicker(c *cli.Context) error {
AssetType: assetType,
},
)
if err != nil {
return err
}
@@ -951,7 +940,6 @@ func addPortfolioAddress(c *cli.Context) error {
ColdStorage: coldstorage,
},
)
if err != nil {
return err
}
@@ -1022,7 +1010,6 @@ func removePortfolioAddress(c *cli.Context) error {
Description: description,
},
)
if err != nil {
return err
}
@@ -3240,7 +3227,6 @@ func getTickerStream(c *cli.Context) error {
AssetType: assetType,
},
)
if err != nil {
return err
}
@@ -3308,7 +3294,6 @@ func getExchangeTickerStream(c *cli.Context) error {
&gctrpc.GetExchangeTickerStreamRequest{
Exchange: exchangeName,
})
if err != nil {
return err
}
@@ -3430,7 +3415,6 @@ func getAuditEvent(c *cli.Context) error {
Limit: int32(limit), //nolint:gosec // TODO: SQL boiler's QueryMode limit only accepts the int type
OrderBy: orderingDirection,
})
if err != nil {
return err
}
@@ -3439,118 +3423,120 @@ func getAuditEvent(c *cli.Context) error {
return nil
}
var uuid, filename, path string
var gctScriptCommand = &cli.Command{
Name: "script",
Usage: "execute scripting management command",
ArgsUsage: "<command> <args>",
Subcommands: []*cli.Command{
{
Name: "execute",
Usage: "execute script filename",
ArgsUsage: "<filename> <path>",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "filename",
Usage: "the script filename",
Destination: &filename,
},
&cli.StringFlag{
Name: "path",
Usage: "the directory of the script file",
Destination: &path,
var (
uuid, filename, path string
gctScriptCommand = &cli.Command{
Name: "script",
Usage: "execute scripting management command",
ArgsUsage: "<command> <args>",
Subcommands: []*cli.Command{
{
Name: "execute",
Usage: "execute script filename",
ArgsUsage: "<filename> <path>",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "filename",
Usage: "the script filename",
Destination: &filename,
},
&cli.StringFlag{
Name: "path",
Usage: "the directory of the script file",
Destination: &path,
},
},
Action: gctScriptExecute,
},
Action: gctScriptExecute,
},
{
Name: "query",
Usage: "query running virtual machine",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "uuid",
Usage: "the unique id of the script in memory",
Destination: &uuid,
{
Name: "query",
Usage: "query running virtual machine",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "uuid",
Usage: "the unique id of the script in memory",
Destination: &uuid,
},
},
Action: gctScriptQuery,
},
Action: gctScriptQuery,
},
{
Name: "read",
Usage: "read script",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Usage: "the script name",
Destination: &uuid,
{
Name: "read",
Usage: "read script",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Usage: "the script name",
Destination: &uuid,
},
},
Action: gctScriptRead,
},
Action: gctScriptRead,
},
{
Name: "status",
Usage: "get status of running scripts",
Action: gctScriptStatus,
},
{
Name: "list",
Usage: "lists all scripts in default scriptpath",
Action: gctScriptList,
},
{
Name: "stop",
Usage: "terminate running script",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "uuid",
Usage: "the unique id of the script in memory",
Destination: &uuid,
},
{
Name: "status",
Usage: "get status of running scripts",
Action: gctScriptStatus,
},
Action: gctScriptStop,
},
{
Name: "stopall",
Usage: "terminate running script",
Action: gctScriptStopAll,
},
{
Name: "upload",
Usage: "upload a new script/archive",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "path",
Usage: "<path> to single script or zip collection",
Destination: &filename,
},
&cli.BoolFlag{
Name: "overwrite",
Usage: "<true/false>",
},
&cli.BoolFlag{
Name: "archived",
Usage: "<true/false>",
},
{
Name: "list",
Usage: "lists all scripts in default scriptpath",
Action: gctScriptList,
},
Action: gctScriptUpload,
},
{
Name: "autoload",
Usage: "add or remove script from autoload list",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "command",
Usage: "<add/remove>",
},
&cli.StringFlag{
Name: "script",
Usage: "<script name>",
{
Name: "stop",
Usage: "terminate running script",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "uuid",
Usage: "the unique id of the script in memory",
Destination: &uuid,
},
},
Action: gctScriptStop,
},
{
Name: "stopall",
Usage: "terminate running script",
Action: gctScriptStopAll,
},
{
Name: "upload",
Usage: "upload a new script/archive",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "path",
Usage: "<path> to single script or zip collection",
Destination: &filename,
},
&cli.BoolFlag{
Name: "overwrite",
Usage: "<true/false>",
},
&cli.BoolFlag{
Name: "archived",
Usage: "<true/false>",
},
},
Action: gctScriptUpload,
},
{
Name: "autoload",
Usage: "add or remove script from autoload list",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "command",
Usage: "<add/remove>",
},
&cli.StringFlag{
Name: "script",
Usage: "<script name>",
},
},
Action: gctScriptAutoload,
},
Action: gctScriptAutoload,
},
},
}
}
)
func gctScriptAutoload(c *cli.Context) error {
if c.NArg() == 0 && c.NumFlags() == 0 {
@@ -3592,7 +3578,6 @@ func gctScriptAutoload(c *cli.Context) error {
Script: script,
Status: status,
})
if err != nil {
return err
}
@@ -3632,7 +3617,6 @@ func gctScriptExecute(c *cli.Context) error {
Path: path,
},
})
if err != nil {
return err
}
@@ -3652,7 +3636,6 @@ func gctScriptStatus(c *cli.Context) error {
executeCommand, err := client.GCTScriptStatus(c.Context,
&gctrpc.GCTScriptStatusRequest{})
if err != nil {
return err
}
@@ -3671,7 +3654,6 @@ func gctScriptList(c *cli.Context) error {
executeCommand, err := client.GCTScriptListAll(c.Context,
&gctrpc.GCTScriptListAllRequest{})
if err != nil {
return err
}
@@ -3702,7 +3684,6 @@ func gctScriptStop(c *cli.Context) error {
&gctrpc.GCTScriptStopRequest{
Script: &gctrpc.GCTScript{Uuid: uuid},
})
if err != nil {
return err
}
@@ -3721,7 +3702,6 @@ func gctScriptStopAll(c *cli.Context) error {
executeCommand, err := client.GCTScriptStopAll(c.Context,
&gctrpc.GCTScriptStopAllRequest{})
if err != nil {
return err
}
@@ -3754,7 +3734,6 @@ func gctScriptRead(c *cli.Context) error {
Name: uuid,
},
})
if err != nil {
return err
}
@@ -3787,7 +3766,6 @@ func gctScriptQuery(c *cli.Context) error {
Uuid: uuid,
},
})
if err != nil {
return err
}
@@ -3856,7 +3834,6 @@ func gctScriptUpload(c *cli.Context) error {
Archived: archived,
Overwrite: overwrite,
})
if err != nil {
return err
}
@@ -3869,46 +3846,48 @@ const klineMessage = `interval in seconds. supported values are: 15, 60(1min), 1
900(15min) 1800(30min), 3600(1h), 7200(2h), 14400(4h), 21600(6h), 28800(8h), 43200(12h),
86400(1d), 259200(3d) 604800(1w), 1209600(2w), 1296000(15d), 2592000(1M), 31536000(1Y)`
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.",
ArgsUsage: "<exchange> <pair> <asset> <rangesize> <granularity>",
Action: getHistoricCandles,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "exchange",
Aliases: []string{"e"},
Usage: "the exchange to get the candles from",
var (
candleRangeSize, candleGranularity int64
getHistoricCandlesCommand = &cli.Command{
Name: "gethistoriccandles",
Usage: "gets historical candles for the specified granularity up to range size time from now",
ArgsUsage: "<exchange> <pair> <asset> <rangesize> <granularity>",
Action: getHistoricCandles,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "exchange",
Aliases: []string{"e"},
Usage: "the exchange to get the candles from",
},
&cli.StringFlag{
Name: "pair",
Usage: "the currency pair to get the candles for",
},
&cli.StringFlag{
Name: "asset",
Usage: "the asset type of the currency pair",
},
&cli.Int64Flag{
Name: "rangesize",
Aliases: []string{"r"},
Usage: "the amount of time to go back from now to fetch candles in the given granularity",
Value: 10,
Destination: &candleRangeSize,
},
&cli.Int64Flag{
Name: "granularity",
Aliases: []string{"g"},
Usage: klineMessage,
Value: 86400,
Destination: &candleGranularity,
},
&cli.BoolFlag{
Name: "fillmissingdatawithtrades, fill",
Usage: "will create candles for missing intervals using stored trade data <true/false>",
},
},
&cli.StringFlag{
Name: "pair",
Usage: "the currency pair to get the candles for",
},
&cli.StringFlag{
Name: "asset",
Usage: "the asset type of the currency pair",
},
&cli.Int64Flag{
Name: "rangesize",
Aliases: []string{"r"},
Usage: "the amount of time to go back from now to fetch candles in the given granularity",
Value: 10,
Destination: &candleRangeSize,
},
&cli.Int64Flag{
Name: "granularity",
Aliases: []string{"g"},
Usage: klineMessage,
Value: 86400,
Destination: &candleGranularity,
},
&cli.BoolFlag{
Name: "fillmissingdatawithtrades, fill",
Usage: "will create candles for missing intervals using stored trade data <true/false>",
},
},
}
}
)
func getHistoricCandles(c *cli.Context) error {
if c.NArg() == 0 && c.NumFlags() == 0 {

View File

@@ -148,7 +148,8 @@ func stateGetDeposit(c *cli.Context) error {
&gctrpc.CurrencyStateDepositRequest{
Exchange: exchange,
Code: code,
Asset: a},
Asset: a,
},
)
if err != nil {
return err
@@ -195,7 +196,8 @@ func stateGetWithdrawal(c *cli.Context) error {
&gctrpc.CurrencyStateWithdrawRequest{
Exchange: exchange,
Code: code,
Asset: a},
Asset: a,
},
)
if err != nil {
return err
@@ -242,7 +244,8 @@ func stateGetTrading(c *cli.Context) error {
&gctrpc.CurrencyStateTradingRequest{
Exchange: exchange,
Code: code,
Asset: a},
Asset: a,
},
)
if err != nil {
return err
@@ -289,7 +292,8 @@ func stateGetPairTrading(c *cli.Context) error {
&gctrpc.CurrencyStateTradingPairRequest{
Exchange: exchange,
Pair: pair,
Asset: a},
Asset: a,
},
)
if err != nil {
return err

View File

@@ -49,7 +49,8 @@ func setupClient(c *cli.Context) (*grpc.ClientConn, context.CancelFunc, error) {
return nil, nil, err
}
opts := []grpc.DialOption{grpc.WithTransportCredentials(creds),
opts := []grpc.DialOption{
grpc.WithTransportCredentials(creds),
grpc.WithPerRPCCredentials(auth.BasicAuth{
Username: username,
Password: password,

View File

@@ -131,7 +131,6 @@ func getNominal(c *cli.Context) error {
Sell: isSelling,
NominalPercentage: percentage,
})
if err != nil {
return err
}
@@ -217,7 +216,6 @@ func getImpact(c *cli.Context) error {
Sell: isSelling,
ImpactPercentage: percentage,
})
if err != nil {
return err
}
@@ -341,7 +339,6 @@ func getMovement(c *cli.Context) error {
Amount: amount,
Purchase: c.Bool("purchase"),
})
if err != nil {
return err
}
@@ -447,7 +444,6 @@ func getOrderbook(c *cli.Context) error {
AssetType: assetType,
},
)
if err != nil {
return err
}
@@ -594,7 +590,6 @@ func getOrderbookStream(c *cli.Context) error {
AssetType: assetType,
},
)
if err != nil {
return err
}
@@ -731,7 +726,6 @@ func getExchangeOrderbookStream(c *cli.Context) error {
&gctrpc.GetExchangeOrderbookStreamRequest{
Exchange: exchangeName,
})
if err != nil {
return err
}