Time-Series Simulation

Overview

MCH Timeseries contains functions to create simulated times series with MCHammer. Current implementation supports GBM only. Other methods will be added

Functions

MCHammer.GBMMfitFunction
GBMMfit(HistoricalData, PeriodsToForecast)

GBMMfit uses a vector of historical data to calculate the log returns and use the mean and standard deviation to project a random walk. It the uses the last datapoint in the set as the starting point for the new forecast.

HistoricalData: Vector containing historical data

PeriodsToForecast: integer >1

source
Random.seed!(1)
historical = rand(Normal(10,2.5),1000)
GBMMfit(historical, 12)

# output
12×1 Array{Float64,2}:
 6.6992003689078325
 7.062760356166932
 7.103000620460403
 7.420415139367789
 8.514400412609032
 3.943937898162356
 4.146251875790493
 5.262045352529825
 0.7692838668172376
 1.2648073358011491
 1.5912440333414342
 2.1886864479965875
MCHammer.GBMMFunction
GBMM(LastValue, ReturnsMean, ReturnsStd, PeriodsToForecast)

GBMM produces a random wlak using the last data point and requires a mean and standard deviation to be provided.

LastValue: The most recent data point on which to base your random walk.

ReturnsMean and ReturnsStd : Historical Mean and Standard Deviation of Returns

PeriodsToForecast is an integer >1

source
Random.seed!(1)

GBMM(100000, 0.05,0.05,12)

# output

12×1 Array{Float64,2}:
 106486.4399226773
 113846.7611813516
 116137.16176312814
 121883.36579797923
 122864.3632374885
 130918.80622439094
 152488.25443945627
 142827.4651618234
 153753.52041326065
 164757.82535740297
 177804.24203041938
 195258.14301210243

How to simulate a random walk

ts_trials =[]
dr = collect(Date(2019,1,01):Dates.Month(1):Date(2019,12,31))

#To setup a TimeSeries simulation with MCHammer
for i = 1:1000
     Monthly_Sales = GBMM(100000, 0.05,0.05,12)
     Monthly_Expenses = GBMM(50000, 0.03,0.02,12)
     MonthlyCOGS = Monthly_Sales .* 0.3
     MonthlyProfit = Monthly_Sales - Monthly_Expenses - MonthlyCOGS
     push!(ts_trials, MonthlyProfit)
end

#You can graph the result using trend_chrt()
trend_chrt(ts_trials, dr)
timestamp Jan 1, 2019 Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan 1, 2018 2019 2020 2021 Jan 1, 2018 2019 2020 2021 Jan 1, 2018 2019 2020 2021 LowerBound p50 UpperBound variable h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? -1.5×10⁵ -1.0×10⁵ -5.0×10⁴ 0 5.0×10⁴ 1.0×10⁵ 1.5×10⁵ 2.0×10⁵ 2.5×10⁵ -1.00×10⁵ -9.50×10⁴ -9.00×10⁴ -8.50×10⁴ -8.00×10⁴ -7.50×10⁴ -7.00×10⁴ -6.50×10⁴ -6.00×10⁴ -5.50×10⁴ -5.00×10⁴ -4.50×10⁴ -4.00×10⁴ -3.50×10⁴ -3.00×10⁴ -2.50×10⁴ -2.00×10⁴ -1.50×10⁴ -1.00×10⁴ -5.00×10³ 0 5.00×10³ 1.00×10⁴ 1.50×10⁴ 2.00×10⁴ 2.50×10⁴ 3.00×10⁴ 3.50×10⁴ 4.00×10⁴ 4.50×10⁴ 5.00×10⁴ 5.50×10⁴ 6.00×10⁴ 6.50×10⁴ 7.00×10⁴ 7.50×10⁴ 8.00×10⁴ 8.50×10⁴ 9.00×10⁴ 9.50×10⁴ 1.00×10⁵ 1.05×10⁵ 1.10×10⁵ 1.15×10⁵ 1.20×10⁵ 1.25×10⁵ 1.30×10⁵ 1.35×10⁵ 1.40×10⁵ 1.45×10⁵ 1.50×10⁵ 1.55×10⁵ 1.60×10⁵ 1.65×10⁵ 1.70×10⁵ 1.75×10⁵ 1.80×10⁵ 1.85×10⁵ 1.90×10⁵ 1.95×10⁵ 2.00×10⁵ -1×10⁵ 0 1×10⁵ 2×10⁵ -1.0×10⁵ -9.0×10⁴ -8.0×10⁴ -7.0×10⁴ -6.0×10⁴ -5.0×10⁴ -4.0×10⁴ -3.0×10⁴ -2.0×10⁴ -1.0×10⁴ 0 1.0×10⁴ 2.0×10⁴ 3.0×10⁴ 4.0×10⁴ 5.0×10⁴ 6.0×10⁴ 7.0×10⁴ 8.0×10⁴ 9.0×10⁴ 1.0×10⁵ 1.1×10⁵ 1.2×10⁵ 1.3×10⁵ 1.4×10⁵ 1.5×10⁵ 1.6×10⁵ 1.7×10⁵ 1.8×10⁵ 1.9×10⁵ 2.0×10⁵ value