timeseries-julia-python

random julia and python scripts analyzing stock timeseries data

git clone https://9o.is/git/timeseries-julia-python.git

time_series.jl

(663B)


      1 using TimeSeries
      2 import TimeSeries.collapse
      3 
      4 function collapse(ta::TimeArray, period::Function, timestamp::Function, aggregates::AbstractDict{Symbol,Function})
      5 	collapsed = [collapse(ta[symbol], period, timestamp, get(aggregates, symbol, first)) for symbol in colnames(ta)]
      6 	merge(collapsed..., method = :outer)
      7 end
      8 
      9 function collapse_ohlc(ta::TimeArray, period::Function, timestamp::Function)
     10 	aggregates = Dict(:Open => first, :High => maximum, :Low => minimum, :Close => last)
     11 	collapse(ta, period, timestamp, aggregates)
     12 end
     13 
     14 function collapse_ohlc_weekly(ta::TimeArray, timestamp::Function = firstdayofweek ∘ first)
     15 	collapse_ohlc(ta, week, timestamp)
     16 end