engine/exchanges: Add GetCurrencyTradeURL wrapper func/gRPC endpoint (#1521)

* beginning the concept

* expands testing and implementations

* test standardisation, expansion

* more

* finish remainder, add rpc func

* lint

* grammar? I barely know her!

* wow i forgot something wow wow wow wow

* rm SendPayload

* enFixio!

* improve binance long-dated support

* update test design, update wrapper funcs

* adds kraken futures, adds bybit support

* fixes SIMPLE bugs

* s is for sucks

* fixed option url x2

* fixed silly test
This commit is contained in:
Scott
2024-05-03 17:01:17 +10:00
committed by GitHub
parent 0676c78bec
commit f1ff951199
83 changed files with 3922 additions and 2265 deletions

View File

@@ -4562,3 +4562,90 @@ func getMarginRatesHistory(c *cli.Context) error {
jsonOutput(result)
return nil
}
var getCurrencyTradeURLCommand = &cli.Command{
Name: "getcurrencytradeurl",
Usage: "returns the trading url of the instrument",
ArgsUsage: "<exchange> <asset> <pair>",
Action: getCurrencyTradeURL,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "exchange",
Aliases: []string{"e"},
Usage: "the exchange to retrieve margin rates from",
},
&cli.StringFlag{
Name: "asset",
Aliases: []string{"a"},
Usage: "the asset type of the currency pair",
},
&cli.StringFlag{
Name: "pair",
Aliases: []string{"p"},
Usage: "the currency pair",
},
},
}
func getCurrencyTradeURL(c *cli.Context) error {
if c.NArg() == 0 && c.NumFlags() == 0 {
return cli.ShowSubcommandHelp(c)
}
var exchangeName string
if c.IsSet("exchange") {
exchangeName = c.String("exchange")
} else {
exchangeName = c.Args().First()
}
var assetType string
if c.IsSet("asset") {
assetType = c.String("asset")
} else {
assetType = c.Args().Get(1)
}
if !validAsset(assetType) {
return errInvalidAsset
}
var cp string
if c.IsSet("pair") {
cp = c.String("pair")
} else {
cp = c.Args().Get(2)
}
if !validPair(cp) {
return errInvalidPair
}
p, err := currency.NewPairDelimiter(cp, pairDelimiter)
if err != nil {
return err
}
conn, cancel, err := setupClient(c)
if err != nil {
return err
}
defer closeConn(conn, cancel)
client := gctrpc.NewGoCryptoTraderServiceClient(conn)
result, err := client.GetCurrencyTradeURL(c.Context,
&gctrpc.GetCurrencyTradeURLRequest{
Exchange: exchangeName,
Asset: assetType,
Pair: &gctrpc.CurrencyPair{
Delimiter: p.Delimiter,
Base: p.Base.String(),
Quote: p.Quote.String(),
},
})
if err != nil {
return err
}
jsonOutput(result)
return nil
}

View File

@@ -218,6 +218,7 @@ func main() {
technicalAnalysisCommand,
getMarginRatesHistoryCommand,
orderbookCommand,
getCurrencyTradeURLCommand,
}
ctx, cancel := context.WithCancel(context.Background())