You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and I'm tring to calculate AccuDist and have "sufficient statistics" as a value of type Tprice (in this case it's Float64 but in general it can be different)
I did
""" AccuDist{T}()The AccuDist type implements an Accumulation and Distribution indicator."""mutable struct AccuDist{T} <:OnlineStat{T}
value::Union{Missing,Float64}
n::IntfunctionAccuDist{T}() where {T}
new{T}(missing, 0)
endend
and would like to do something like
mutable struct AccuDist{T, S} <:OnlineStat{T, S}
value::Union{Missing, S}
n::IntfunctionAccuDist{T, S}() where {T, S}
new{T, S}(missing, 0)
endend=#function OnlineStatsBase._fit!(ind::AccuDist, candle::OHLCV)
ind.n +=1if candle.high != candle.low
# Calculate MFI and MFV
mfi =
((candle.close - candle.low) - (candle.high - candle.close)) /
(candle.high - candle.low)
mfv = mfi * candle.volume
else# In case high and low are equal (division by zero), return previous value if exists, otherwise return missing
ind.value =value(ind)
returnendif!has_output_value(ind)
ind.value = mfv
else
ind.value =value(ind) + mfv
endend
Unfortunatly I have to use
value::Union{Missing,Float64}
I'd like to be able to do
value::Union{Missing,Tprice}
How can I inherit OnlineStatsBase with OHLCV{Missing, Float64, Float64} as a single observation value and type Tprice as a sufficient statistics.
Maybe doc can slightly be improved on this side (and I could provide PR after understanding how to tackle that.
Hello,
I'm working on https://github.com/femtotrader/IncTA.jl/tree/OnlineStatsBase and I'm looking for a way to pass a candlestick as a single observation value.
My single observation value looks like
and I'm tring to calculate AccuDist and have "sufficient statistics" as a value of type Tprice (in this case it's Float64 but in general it can be different)
I did
and would like to do something like
Unfortunatly I have to use
I'd like to be able to do
How can I inherit OnlineStatsBase with OHLCV{Missing, Float64, Float64} as a single observation value and type Tprice as a sufficient statistics.
Maybe doc can slightly be improved on this side (and I could provide PR after understanding how to tackle that.
Especially in README example
value is type of Float64 but it could be more general I think (type of y, or an other type)
Some help from Julia guys experienced with types and inheritance could greatly help
Kind regards
The text was updated successfully, but these errors were encountered: