Skip to content

Commit 722702b

Browse files
committed
Adds Moving Average Forecasting method
1 parent 7e803c9 commit 722702b

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Forecasting/MovingAverage.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pandas as pd
2+
data = pd.read_csv("data/bucketed/trades.csv.gz", parse_dates=['timestamp'])
3+
4+
5+
class MovingAverage:
6+
def __init__(self, n):
7+
self.n = n
8+
9+
def predict(self, data):
10+
pred = []
11+
for i in range(self.n, data.shape[0]):
12+
pred.append(data[i-self.n:i].mean())
13+
return pred
14+
15+
16+
mav = MovingAverage(5)
17+
mav.predict(data['close'][:100])

Forecasting/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)