Skip to content

Commit

Permalink
Merge pull request #22 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 19adf35 + 5f50e7f commit 003a55a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/gh-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ on:
jobs:
build:
runs-on: ubuntu-20.04
container:
image: quantconnect/lean:foundation
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2

- name: Free space
run: df -h && rm -rf /opt/hostedtoolcache* && df -h

- name: Checkout Lean Same Branch
id: lean-same-branch
Expand All @@ -33,8 +35,14 @@ jobs:
- name: Move Lean
run: mv Lean ../Lean

- name: Build
run: dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 QuantConnect.SamcoBrokerage.sln

- name: Run Tests
run: dotnet test ./QuantConnect.SamcoBrokerage.Tests/bin/Release/QuantConnect.SamcoBrokerage.Tests.dll
- name: Build and Run
uses: addnab/docker-run-action@v3
with:
image: quantconnect/lean:foundation
options: --workdir /__w/Lean.Brokerages.Samco/Lean.Brokerages.Samco -v /home/runner/work:/__w
shell: bash
run: |
# Build
dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 QuantConnect.SamcoBrokerage.sln
# Run Tests
dotnet test ./QuantConnect.SamcoBrokerage.Tests/bin/Release/QuantConnect.SamcoBrokerage.Tests.dll
2 changes: 1 addition & 1 deletion QuantConnect.SamcoBrokerage.Tests/SamcoBrokerageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected override IBrokerage CreateBrokerage(IOrderProvider orderProvider, ISec
var algorithm = new Mock<IAlgorithm>();
algorithm.Setup(a => a.Transactions).Returns(transactions);
algorithm.Setup(a => a.BrokerageModel).Returns(new SamcoBrokerageModel());
algorithm.Setup(a => a.Portfolio).Returns(new SecurityPortfolioManager(securities, transactions));
algorithm.Setup(a => a.Portfolio).Returns(new SecurityPortfolioManager(securities, transactions, new AlgorithmSettings()));

var apiSecret = Config.Get("samco-client-password");
var apiKey = Config.Get("samco-client-id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void GetExchangeWithListingID(string listingID, string expectedExchange)
}

[TestCase("tcs")]
[TestCase("hdfc")]
[TestCase("ltts")]
public void IsKnownBrokerageSymbol(string symbol)
{
Assert.IsTrue(_symbolMapper.IsKnownBrokerageSymbol(symbol));
Expand Down
8 changes: 4 additions & 4 deletions QuantConnect.SamcoBrokerage/SamcoBrokerage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,10 +1142,10 @@ private static void ValidateSubscription()
{
try
{
var productId = 173;
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 = 173;
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 003a55a

Please sign in to comment.