Skip to content

Commit

Permalink
Merge pull request #16 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 c3f730c + f48a648 commit da283bf
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions QuantConnect.BybitBrokerage/BybitBrokerage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ private void Initialize(string baseWssUrl, string restApiUrl, string apiKey, str
return;
}

ValidateSubscription();

_privateWebSocketUrl = $"{baseWssUrl}/v5/private";
var basePublicWebSocketUrl = $"{baseWssUrl}/v5/public";

Expand Down Expand Up @@ -266,8 +268,6 @@ private void Initialize(string baseWssUrl, string restApiUrl, string apiKey, str
return client;
});
}

ValidateSubscription();
}

private Dictionary<Symbol, int> FetchSymbolWeights(BybitApi client, BybitProductCategory category)
Expand Down Expand Up @@ -503,10 +503,10 @@ private static void ValidateSubscription()
{
try
{
var productId = 305;
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 = 305;
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 All @@ -517,10 +517,10 @@ private static void ValidateSubscription()
var information = new Dictionary<string, object>()
{
{"productId", productId},
{"machineName", System.Environment.MachineName},
{"userName", System.Environment.UserName},
{"domainName", System.Environment.UserDomainName},
{"os", System.Environment.OSVersion}
{"machineName", Environment.MachineName},
{"userName", Environment.UserName},
{"domainName", Environment.UserDomainName},
{"os", Environment.OSVersion}
};
// IP and Mac Address Information
try
Expand Down

0 comments on commit da283bf

Please sign in to comment.