@@ -37,6 +37,7 @@ type OrderBookBestPriceVolumeSignal struct {
3737 RatioThreshold fixedpoint.Value `json:"ratioThreshold"`
3838 MinVolume fixedpoint.Value `json:"minVolume"`
3939 MinQuoteVolume fixedpoint.Value `json:"minQuoteVolume"`
40+ MinDelta fixedpoint.Value `json:"minDelta"`
4041
4142 Window int `json:"window"`
4243 SmoothingWindow int `json:"smoothingWindow"`
@@ -100,12 +101,12 @@ func (s *OrderBookBestPriceVolumeSignal) CalculateSignal(ctx context.Context) (f
100101 return 0.0 , nil
101102 }
102103
103- bidVolume := bid .Volume
104- askVolume := ask .Volume
104+ bidVolume := bid .Price . Mul ( bid . Volume )
105+ askVolume := ask .Price . Mul ( ask . Volume )
105106
106107 if s .bidVolumeSeries != nil {
107- s .bidVolumeSeries .PushAndEmit (bid .Volume .Float64 ())
108- s .askVolumeSeries .PushAndEmit (ask .Volume .Float64 ())
108+ s .bidVolumeSeries .PushAndEmit (bid .Price . Mul ( bid . Volume ) .Float64 ())
109+ s .askVolumeSeries .PushAndEmit (ask .Price . Mul ( ask . Volume ) .Float64 ())
109110
110111 bidVolume = fixedpoint .NewFromFloat (s .bidVolumeIndicator .(types.Series ).Index (0 ))
111112 askVolume = fixedpoint .NewFromFloat (s .askVolumeIndicator .(types.Series ).Index (0 ))
@@ -119,6 +120,8 @@ func (s *OrderBookBestPriceVolumeSignal) CalculateSignal(ctx context.Context) (f
119120 signal := 0.0
120121 if bidVolume .Compare (s .MinVolume ) < 0 && askVolume .Compare (s .MinVolume ) < 0 {
121122 signal = 0.0
123+ } else if bidVolume .Sub (askVolume ).Abs ().Compare (s .MinDelta ) < 0 {
124+ signal = 0.0
122125 } else if bidRatio .Compare (s .RatioThreshold ) >= 0 {
123126 numerator := bidRatio .Sub (s .RatioThreshold )
124127 signal = numerator .Div (denominator ).Float64 ()
0 commit comments