timeseries-julia-python

random julia and python scripts analyzing stock timeseries data

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

sample2.jl

(575B)


      1 #!/usr/bin/julia
      2 
      3 using Plots
      4 using Random
      5 using Dates
      6 
      7 function run_sample()
      8 	theme(:dark)
      9 
     10 	# Generate some toy sample data
     11 	Random.seed!(1)
     12 	n = 250
     13 	Open = 100.0 .+ cumsum(randn(n))
     14 	High = Open .+ rand(n)
     15 	Low = Open .- rand(n)
     16 	Close = 100.0 .+ cumsum(randn(n))
     17 	for i = 1:n
     18 		if Close[i] > High[i]
     19 			Close[i] = High[i]
     20 		elseif Close[i] < Low[i]
     21 			Close[i] = Low[i]
     22 		end
     23 	end
     24 	OHLC = [Open High Low Close]
     25 	HLC = [High Low Close]
     26 	HL = [High Low]
     27 	t = collect(today():Day(1):today()+Day(n-1))
     28 	println("Plotting...?")
     29 	plot(t, Close, lw=2, label="Random Walk")
     30 end