Skip to content

Commit

Permalink
Merge pull request #33 from jhonabreul/refactor-subscription-validation
Browse files Browse the repository at this point in the history
Use Globals for credentials access for subscription validation
  • Loading branch information
jhonabreul authored Feb 21, 2024
2 parents fe2c707 + 57a98a2 commit 8f4d06d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions QuantConnect.BinanceBrokerage/BinanceBrokerage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,9 @@ protected void Initialize(string wssUrl, string restApiUrl, string apiKey, strin
{
throw new InvalidOperationException("Binance.US doesn't support SPOT Testnet trading.");
}

ValidateSubscription();

base.Initialize(wssUrl, new WebSocketClientWrapper(), null, apiKey, apiSecret);
_job = job;
_algorithm = algorithm;
Expand Down Expand Up @@ -577,8 +580,6 @@ protected void Initialize(string wssUrl, string restApiUrl, string apiKey, strin
Log.Trace("Daily websocket restart: connect");
Connect();
};

ValidateSubscription();
}

/// <summary>
Expand Down Expand Up @@ -733,10 +734,10 @@ private static void ValidateSubscription()
{
try
{
var productId = 176;
var userId = Config.GetInt("job-user-id");
var token = Config.Get("api-access-token");
var organizationId = Config.Get("job-organization-id", null);
const int productId = 176;
var userId = Globals.UserId;
var token = Globals.UserToken;
var organizationId = Globals.OrganizationID;
// Verify we can authenticate with this user and token
var api = new ApiConnection(userId, token);
if (!api.Connected)
Expand Down

0 comments on commit 8f4d06d

Please sign in to comment.