Browse Source

feat: predictors

pull/14/head
QuentinN42 1 year ago
parent
commit
f3bff066ae
Signed by: number42 GPG Key ID: 2CD7D563712B3A50
  1. 0
      auto_trading/predictor/__init__.py
  2. 17
      auto_trading/predictor/mean_agg.py
  3. 15
      auto_trading/predictor/random_predictor.py

0
auto_trading/predictor/__init__.py

17
auto_trading/predictor/mean_agg.py

@ -0,0 +1,17 @@
import pandas as pd
import numpy as np
from ..interfaces import Predictor
class MeanAggregator(Predictor):
"""Aggregate multiples predictors."""
def __init__(self, predictors):
"""Initialize MeanAggregator."""
self.predictors = predictors
def predict(self, data: pd.DataFrame) -> dict:
"""Predict from others predictors."""
return pd.DataFrame([cls.predict(data) for cls in self.predictors]).mean().to_dict()

15
auto_trading/predictor/random_predictor.py

@ -0,0 +1,15 @@
from random import random
import pandas as pd
from ..interfaces import Predictor
class RandomPredictor(Predictor):
def predict(self, data: pd.DataFrame) -> dict:
"""It's just random"""
return {
k: random()*2-1
for k in data.columns
}
Loading…
Cancel
Save