Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions VisualHFT.Plugins/MarketConnectors.Binance/BinancePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class BinancePlugin : BasePluginDataRetriever
private BinanceRestClient _restClient;

// ✅ FIX: Use ConcurrentDictionary for thread safety
private readonly ConcurrentDictionary<string, VisualHFT.Model.OrderBook> _localOrderBooks =
internal readonly ConcurrentDictionary<string, VisualHFT.Model.OrderBook> _localOrderBooks =
new ConcurrentDictionary<string, VisualHFT.Model.OrderBook>();

private HelperCustomQueue<IBinanceEventOrderBook> _eventBuffers;
Expand Down Expand Up @@ -577,7 +577,7 @@ private void eventBuffers_onErrorAction(Exception ex)
Task.Run(async () => await HandleConnectionLost(_error, ex));
}

private void tradesBuffers_onReadAction(IBinanceTrade eventData)
internal void tradesBuffers_onReadAction(IBinanceTrade eventData)
{
var _symbol = GetNormalizedSymbol(eventData.Symbol);
// Get a Trade object from the pool.
Expand All @@ -589,7 +589,11 @@ private void tradesBuffers_onReadAction(IBinanceTrade eventData)
trade.Timestamp = eventData.TradeTime.ToLocalTime();
trade.ProviderId = _settings.Provider.ProviderID;
trade.ProviderName = _settings.Provider.ProviderName;
trade.IsBuy = eventData.BuyerIsMaker;
// IsBuy means the AGGRESSOR bought. The stream reports the opposite fact: BuyerIsMaker is
// the "m" flag, true when the buyer was the resting maker - which makes the seller the
// aggressor. Negate it, or every aggressive sell on this venue is reported as a buy and
// every study that reads trade side reads this venue backwards.
trade.IsBuy = !eventData.BuyerIsMaker;
trade.MarketMidPrice = _localOrderBooks[_symbol].MidPrice;

RaiseOnDataReceived(trade);
Expand Down
10 changes: 10 additions & 0 deletions VisualHFT.Plugins/Studies.VPIN/Model/PlugInSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ public class PlugInSettings : ISetting
{
public double BucketVolSize { get; set; }
public int? NumberOfBuckets { get; set; } // Rolling window size (nullable for backward compat)

/// <summary>
/// Selects the corrected form of the metric: trades classified by the tick rule instead of
/// against the order-book mid, no value published until a full window of buckets has closed,
/// and no value published while the bucket volume is too small to hold enough prints for the
/// imbalance to describe the flow. Off by default, so a settings file written before this
/// option existed keeps the behaviour it already had.
/// </summary>
public bool UseCorrectedForm { get; set; }

public string Symbol { get; set; }
public Provider Provider { get; set; }
public AggregationLevel AggregationLevel { get; set; }
Expand Down
Loading
Loading