QuantConnect/lean-cli

Lean CLI skips input for brokerage api key & secret

Closed this issue ยท 6 comments

Expected Behavior

When executing 'lean live', the CLI asks for the brokerage's API Key & Secret, after selecting a brokerage & data provider from the menu.

Actual Behavior

When executing 'lean live', the CLI does NOT ask for the brokerage's API Key & Secret, after selecting a brokerage & data provider from the menu.

The consequence is that the connection to the exchange cannot be made and Lean exits with an error.

Potential Solution

Ask for the brokerage's API Key & Secret after selecting brokerage & data provider.

Reproducing the Problem

  • Do a clean install of the lean CLI.
  • Use 'lean live ' to start a project.
  • Select either Kraken or Bybit from the brokerage menu (not sure if it also skips for other exchanges)
    It will now show

Configure credentials for Kraken
Create an API key by logging in and accessing the Kraken API Management page (https://www.kraken.com/u/security/api).

....but will not actually give a prompt to input the key & secret, as it did before and should do.

System Information

Ubuntu 22.04 TLS

Checklist

  • [V] I have completely filled out this template
  • [V] I have confirmed that this issue exists on the current master branch
  • [V] I have confirmed that this is not a duplicate issue by searching git repo
  • [V] I have provided detailed steps to reproduce the issue

Log

lean_cli_log_excerpt_24022024.log

Please close as this turns out to be a Lean Engine issue, not a CLI issue.

Hey @symbion6! Thank you for the report, we will look into it, this is a lean-cli issue ๐Ÿ‘. FYI we are currently working on a lean CLI refactor handling modules and configurations, so we will fix this issue at it

Thanks @Martin-Molinero! How can we pass the api key & secret in the meantime?
I've tried using the cli params, like this:

lean live myprojectname --brokerage Kraken --data-provider-live Kraken --kraken-api-key mykey --kraken-api-secret mysecret --kraken-verification-tier Intermediate

This result in the following error:

20240226 12:54:31.760 TRACE:: WebSocketClientWrapper connection task started: wss://ws-auth.kraken.com
20240226 12:54:31.766 TRACE:: WebSocketClientWrapper.HandleConnection(wss://ws-auth.kraken.com): Connecting...
20240226 12:54:33.927 TRACE:: WebSocketClientWrapper.OnOpen(): Connection opened (IsOpen:True, State:Open): wss://ws-auth.kraken.com
20240226 12:54:33.928 TRACE:: BaseWebsocketsBrokerage(): WebSocket.Open. Subscribing
20240226 12:54:33.976 ERROR:: WebSocketClientWrapper.OnError(): WebSocketClientWrapper.OnError(): (IsOpen:True, State:Open): wss://ws-auth.kraken.com: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an
illegal character among the padding characters.
at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
at System.Convert.FromBase64String(String s)
at QuantConnect.Brokerages.Kraken.KrakenBrokerage.a(String A_0, Int64 A_1, String A_2)
at QuantConnect.Brokerages.Kraken.KrakenBrokerage.a(String A_0, String A_1, IDictionary`2 A_2, Method A_3, Boolean A_4)
at QuantConnect.Brokerages.Kraken.KrakenBrokerage.b()
at QuantConnect.Brokerages.Kraken.KrakenBrokerage.a()
at QuantConnect.Brokerages.Kraken.KrakenBrokerage.a(Object A_0, EventArgs A_1)
at QuantConnect.Brokerages.WebSocketClientWrapper.OnOpen() in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Brokerages/WebSocketClientWrapper.cs:line 202
at QuantConnect.Brokerages.WebSocketClientWrapper.HandleConnection() in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Brokerages/WebSocketClientWrapper.cs:line 238

For Bybit (using the specific bybit parameters --bybit-api-key and --bybit-api-secret and --bybit-vip-level set to VIP0), it exits after this error:

During the algorithm initialization, the following exception has occurred: Error getting cash balance from
brokerage

Anything that can help us getting our bot back online would be great. We cannot start it at the moment :-(

Hey @symbion6!

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters

Seen this issue in kraken when using invalid keys, suggest double checking ur providing the correct key and secret, secret is the long one.

Error getting cash balance from
brokerage

Would nee to see the entire log but this also seems like invalid key/secret configuration for bybit too

Closing for now, believe there's no issue, please reopen if it's still happening and provide more details so we can fix it asap ๐Ÿ‘