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.GBMMfit
— FunctionGBMMfit(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
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.GBMM
— FunctionGBMM(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
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)