You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
588 B

1 year ago
import pandas as pd # type: ignore
1 year ago
from ..interfaces import Broker
class Backtest(Broker):
"""
Backtest Broker
"""
def __init__(self, f_name: str, start=0, **kwargs) -> None:
1 year ago
"""Read the csv file and store it into a dataframe"""
self.data = pd.read_csv(f_name, **kwargs).fillna(method="ffill")
self.curcor = start
1 year ago
def __bool__(self):
return self.curcor < len(self.data)
def next(self):
"""Return the next row of the dataframe"""
self.curcor += 1
return self.data.iloc[:self.curcor].copy()