Skip to content

Commit 5fbb1f3

Browse files
Tidy up, few more comments also fixed bug to get bars without being explicitly subscribed to tick.
1 parent 2a958c7 commit 5fbb1f3

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

QuantConnect.DataBento/DataBentoDataProvider.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,12 @@ private void Initialize()
132132
Log.Trace($"DataBentoProvider.SubscribeImpl(): Client is connected, attempting async subscribe for {symbol}");
133133
Task.Run(async () =>
134134
{
135-
var success = _client.Subscribe(config.Symbol, config.Resolution, config.TickType);
135+
// If the requested resolution is higher than tick, we subscribe to ticks and let the aggregator handle it.
136+
var resolutionToSubscribe = config.Resolution > Resolution.Tick ? Resolution.Tick : config.Resolution;
137+
var success = _client.Subscribe(config.Symbol, resolutionToSubscribe, config.TickType);
136138
if (success)
137139
{
138-
Log.Trace($"DataBentoProvider.SubscribeImpl(): Successfully subscribed to {config.Symbol}");
140+
Log.Trace($"DataBentoProvider.SubscribeImpl(): Successfully subscribed to {config.Symbol} at {resolutionToSubscribe} resolution");
139141

140142
// Start session after first successful subscription
141143
lock (_sessionLock)

QuantConnect.DataBento/DataBentoRawLiveClient.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,19 @@ public bool Subscribe(Symbol symbol, Resolution resolution, TickType tickType)
215215

216216
try
217217
{
218+
// Get the databento symbol form LEAN symbol
219+
// Get schema from the resolution
218220
var databentoSymbol = MapSymbolToDataBento(symbol);
219221
var schema = GetSchema(resolution, tickType);
220222

221223
// subscribe
222224
var subscribeMessage = $"schema={schema}|stype_in=parent|symbols={databentoSymbol}";
223225
Log.Trace($"DatabentoRawClient.Subscribe(): Subscribing with message: {subscribeMessage}");
224226

227+
// Send subscribe message
225228
_writer.WriteLine(subscribeMessage);
226229

230+
// Store subscription
227231
_subscriptions.TryAdd(symbol, (resolution, tickType));
228232
Log.Trace($"DatabentoRawClient.Subscribe(): Subscribed to {symbol} ({databentoSymbol}) at {resolution} resolution for {tickType}");
229233

@@ -404,7 +408,7 @@ private async Task ProcessSingleMessage(string message)
404408
await HandleMBPMessage(root, headerElement);
405409
return;
406410
}
407-
else if (rtype == 0 || rtype == 32)
411+
else if (rtype == 0)
408412
{
409413
// Trade messages - Trade ticks
410414
await HandleTradeTickMessage(root, headerElement);
@@ -596,7 +600,7 @@ private async Task HandleMBPMessage(JsonElement root, JsonElement header)
596600
}
597601

598602
/// <summary>
599-
/// Handles trade tick messages (actual executed transactions)
603+
/// Handles trade tick messages. Aggressor fills
600604
/// </summary>
601605
private async Task HandleTradeTickMessage(JsonElement root, JsonElement header)
602606
{

0 commit comments

Comments
 (0)