Skip to content

Commit

Permalink
WIP Moments
Browse files Browse the repository at this point in the history
  • Loading branch information
femtotrader committed Apr 23, 2024
1 parent 0fdf942 commit 7cbd0f8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ version = "1.0.0-DEV"
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
OnlineStatsBase = "925886fa-5bf2-5e8e-b522-a9147a512338"
Rocket = "df971d30-c9d6-4b37-b8ff-e965b2cb3a40"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

[compat]
julia = "1.6.7"
Expand Down
30 changes: 30 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,35 @@ const weights = [0.4, 0.4, 0.2]

end

@testset "Moments" begin
using Statistics, StatsBase

source = from(TSLA)
_ret = SimpleAssetReturn{Float64}()
_moments = Moments()

mapped_source =
source |>
map(Union{Missing,Float64}, price -> (fit!(_ret, price);
value(_ret))) |>
filter(!ismissing) |>
map(Any, r -> (fit!(_moments, r);))

function observer(value)
println(value)
println((mean=Statistics.mean(value), std=0.0, skewness=StatsBase.skewness(value), kurtosis=StatsBase.kurtosis(value)))
println("")
end
subscribe!(mapped_source, observer)

#moments =
@test moments.mean = 0.0431772
@test moments.std = 0.1496
@test moments.skewness = 1.3688
@test moments.kurtosis = 2.1968
#@test all(isapprox.(drawdowns, expected_drawdowns, atol = ATOL))

end


end

0 comments on commit 7cbd0f8

Please sign in to comment.