Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Molinero committed Oct 18, 2023
1 parent 3ec8fa5 commit c28110e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
32 changes: 10 additions & 22 deletions QuantConnect.KrakenBrokerage/KrakenBrokerage.DataQueueHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,44 +308,32 @@ private void ProcessOrderBookUpdate(Symbol symbol, JToken book)

if (book["a"] != null)
{
foreach (var ask in book["a"])
foreach (var rawAsk in book["a"])
{
var bidAsk = ask.ToObject<KrakenBidAsk>();
if (bidAsk.UpdateType == "r")
var ask = rawAsk.ToObject<KrakenBidAsk>();
if (ask.Volume == 0)
{
// republish
continue;
}

if (bidAsk.Volume == 0)
{
orderBook.RemoveAskRow(bidAsk.Price);
orderBook.RemoveAskRow(ask.Price);
}
else
{
orderBook.UpdateAskRow(bidAsk.Price, bidAsk.Volume);
orderBook.UpdateAskRow(ask.Price, ask.Volume);
}
}
}

if (book["b"] != null)
{
foreach (var bid in book["b"])
foreach (var rawBid in book["b"])
{
var bidAsk = bid.ToObject<KrakenBidAsk>();
if(bidAsk.UpdateType == "r")
{
// republish
continue;
}

if (bidAsk.Volume == 0)
var bid = rawBid.ToObject<KrakenBidAsk>();
if (bid.Volume == 0)
{
orderBook.RemoveBidRow(bidAsk.Price);
orderBook.RemoveBidRow(bid.Price);
}
else
{
orderBook.UpdateBidRow(bidAsk.Price, bidAsk.Volume);
orderBook.UpdateBidRow(bid.Price, bid.Volume);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion QuantConnect.KrakenBrokerage/Models/KrakenBidAsk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class KrakenBidAsk
public decimal Timestamp { get; set; }

/// <summary>
/// Update type
/// Update type. 'r' when price levels are pulled into scope by another price level being deleted
/// </summary>
public string UpdateType { get; set; }
}
Expand Down

0 comments on commit c28110e

Please sign in to comment.