mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-05 23:16:53 +00:00
Expose auth validator functionality for wrapper (#416)
* expose auth validator functionality for wrapper * Add REST validation after keys set, package account types for future syncing * Add transient error checking for initial creddemtial validation * fix command types * Addressed nits from glorious person * Amalgamate body within error when not between 2xx status, added btcmarket specific auth error check * nit fix for glorious person * Format fix * removed unused code * check transient first then validate if its an exchange specific authentication error, all others will be disregarded * Addressed glorious nits * Addressed glorious nits * Moved account processing to updateaccountinfo func and added in fetch account info * Add GRPC Account streaming (NOTE: could not complete until sync item added) * RM exchange check * Address xtda nits * RM comment code * Fix linter issues * used most recent protoc version * lbank linter issues fixed * Addressed nits and changed len check to range in for loops * Fixed timeout issue * thrasher nits addressed * add string holdings
This commit is contained in:
@@ -770,6 +770,67 @@ func getAccountInfo(c *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var getAccountInfoStreamCommand = cli.Command{
|
||||
Name: "getaccountinfostream",
|
||||
Usage: "gets the account info stream for a specific exchange",
|
||||
ArgsUsage: "<exchange>",
|
||||
Action: getAccountInfoStream,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "exchange",
|
||||
Usage: "the exchange to get the account info stream from",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func getAccountInfoStream(c *cli.Context) error {
|
||||
if c.NArg() == 0 && c.NumFlags() == 0 {
|
||||
cli.ShowCommandHelp(c, "getaccountinfostream")
|
||||
return nil
|
||||
}
|
||||
|
||||
var exchangeName string
|
||||
|
||||
if c.IsSet("exchange") {
|
||||
exchangeName = c.String("exchange")
|
||||
} else {
|
||||
exchangeName = c.Args().First()
|
||||
}
|
||||
|
||||
if !validExchange(exchangeName) {
|
||||
return errInvalidExchange
|
||||
}
|
||||
|
||||
conn, err := setupClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
client := gctrpc.NewGoCryptoTraderClient(conn)
|
||||
result, err := client.GetAccountInfoStream(context.Background(),
|
||||
&gctrpc.GetAccountInfoRequest{Exchange: exchangeName})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for {
|
||||
resp, err := result.Recv()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = clearScreen()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Account balance stream for %s:\n\n", exchangeName)
|
||||
|
||||
fmt.Printf("%+v", resp)
|
||||
}
|
||||
}
|
||||
|
||||
var getConfigCommand = cli.Command{
|
||||
Name: "getconfig",
|
||||
Usage: "gets the config",
|
||||
|
||||
@@ -102,6 +102,7 @@ func main() {
|
||||
getOrderbookCommand,
|
||||
getOrderbooksCommand,
|
||||
getAccountInfoCommand,
|
||||
getAccountInfoStreamCommand,
|
||||
getConfigCommand,
|
||||
getPortfolioCommand,
|
||||
getPortfolioSummaryCommand,
|
||||
|
||||
Reference in New Issue
Block a user