tonne commited on
Commit
f0d7454
1 Parent(s): 7a0be88
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -66,8 +66,26 @@ class TS:
66
  name = f"{self.symbol}_pred"
67
  ))
68
  return fig
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
 
 
 
 
 
71
 
72
  st.title("Vietnam Trading by Time Series")
73
  model = st.selectbox("model", ["Prophet", "ARIMA"])
@@ -80,6 +98,6 @@ with st.spinner('Wait for it...'):
80
  if model == "Prophet":
81
  fig = ts.prophet(period = period)
82
  elif model == "ARIMA":
83
- fig = ts.prophet(period = period)
84
  st.success('Done!')
85
  st.plotly_chart(fig, use_container_width=True)
 
66
  name = f"{self.symbol}_pred"
67
  ))
68
  return fig
69
+ def arima(self, period = 3):
70
+ df = self.get_data()
71
+ df.index = df.ds
72
+ model = ARIMA(df.y, order = (1, 0, 7))
73
+ model = model.fit()
74
+ print(len(df))
75
+ future = pd.DataFrame()
76
+ predictions = model.forecast(period)
77
+ future["y"] = predictions
78
+ print(df.index.max())
79
+ future.index = pd.date_range(start = df.index.max() + timedelta(days = 1), end = df.index.max() + timedelta(days = period))
80
+
81
+ return self.viz(df, future)
82
+
83
 
84
 
85
+ # ts = TS(symbol = "FPT")
86
+ # data = ts.arima()
87
+ # print(data.index.min(), data.index.max())
88
+
89
 
90
  st.title("Vietnam Trading by Time Series")
91
  model = st.selectbox("model", ["Prophet", "ARIMA"])
 
98
  if model == "Prophet":
99
  fig = ts.prophet(period = period)
100
  elif model == "ARIMA":
101
+ fig = ts.arima(period = period)
102
  st.success('Done!')
103
  st.plotly_chart(fig, use_container_width=True)