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.
|
|
|
import pandas as pd # type: ignore
|
|
|
|
|
|
|
|
from ..interfaces import Broker
|
|
|
|
|
|
|
|
|
|
|
|
class Backtest(Broker):
|
|
|
|
"""
|
|
|
|
Backtest Broker
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, f_name: str, start=0, **kwargs) -> None:
|
|
|
|
"""Read the csv file and store it into a dataframe"""
|
|
|
|
self.data = pd.read_csv(f_name, **kwargs).fillna(method="ffill")
|
|
|
|
self.curcor = start
|
|
|
|
|
|
|
|
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()
|