Skip to content

Commit

Permalink
Fix using default value for orderbook depth in SetJob
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonabreul committed Feb 27, 2024
1 parent 4266d48 commit ae1aabe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using QuantConnect.Data;
using QuantConnect.Logging;
using QuantConnect.Data.Market;
using QuantConnect.Configuration;

namespace QuantConnect.Tests.Brokerages.Kraken
{
Expand Down Expand Up @@ -78,5 +79,24 @@ public void StreamsData(Symbol symbol, Resolution resolution, int waitMillisecon

cancelationToken.Cancel();
}

[Test]
public void SetJobUsesOrderBookDepthDefaultValue()
{
using var brokerage = new KrakenBrokerage();

var packet = new Packets.LiveNodePacket()
{
BrokerageData =
{
{ "kraken-api-key", Config.Get("kraken-api-key") },
{ "kraken-api-secret", Config.Get("kraken-api-secret") },
{ "kraken-verification-tier", Config.Get("kraken-verification-tier") }
}
};

Assert.DoesNotThrow(() => brokerage.SetJob(packet));
Assert.IsTrue(brokerage.IsConnected);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -427,18 +427,20 @@ private void SetWebsocketToken()
/// <param name="job">Job we're subscribing for</param>
public void SetJob(LiveNodePacket job)
{
if (!job.BrokerageData.TryGetValue("kraken-orderbook-depth", out var orderDepth))
var orderDepth = 10;
if (job.BrokerageData.TryGetValue("kraken-orderbook-depth", out var orderDepthStr))
{
throw new ArgumentException($"KrakenBrokerage.SetJob(): missing value -- kraken-orderbook-depth");
orderDepth = orderDepthStr.ToInt32();
}

var aggregator = Composer.Instance.GetExportedValueByTypeName<IDataAggregator>(
Config.Get("data-aggregator", "QuantConnect.Lean.Engine.DataFeeds.AggregationManager"), forceTypeNameOnExisting: false);

Initialize(
job.BrokerageData["kraken-api-key"],
job.BrokerageData["kraken-api-secret"],
job.BrokerageData["kraken-verification-tier"],
orderDepth.ToInt32(),
orderDepth,
null,
aggregator,
job);
Expand Down

0 comments on commit ae1aabe

Please sign in to comment.