OracleDataFrame
Reference information for the OracleDataFrame
class.
anterior.source.OracleDataFrame
DataFrame that inherits all the methods and attributes of a pandas or polars DataFrame, but only returns and modifies data before/after the current date depending on specification.
PARAMETER | DESCRIPTION |
---|---|
df |
The DataFrame to use as the data source.
TYPE:
|
date_col |
The name of the column containing dates. Defaults to the index.
TYPE:
|
past |
If True, the OracleDataFrame will return only the data before the current date. If False, it will return only the data after the current date.
TYPE:
|
Examples:
OracleDataFrame vs regular DataFrame
from pandas import DataFrame
from anterior import BackTester, RetroDataFrame
data = ... # data between 2010 to 2024
df = DataFrame(data)
oracle_df = RetroDataFrame(data, past=True)
bt = BackTester()
@bt.on(year=2020, month=1, day=1)
def update()
df.iloc[:-5] # returns the last 5 rows of the entire dataset
oracle_df.iloc[:-5] # returns the last 5 rows of the dataset before 2020-01-01
bt.run("2010-01-01", "2024-01-01")
from polars import DataFrame
from anterior import BackTester, RetroDataFrame
data = ... # data between 2010 to 2024
df = DataFrame(data)
oracle_df = RetroDataFrame(data, past=False)
bt = BackTester()
@bt.on(year=2020, month=1, day=1)
def update()
df.iloc[:5] # returns the first 5 rows of the entire dataset
oracle_df.iloc[:5] # returns the first 5 rows of the dataset after 2020-01-01
bt.run("2010-01-01", "2024-01-01")
pd_from_csv
classmethod
Create an OracleDataFrame from a CSV file inheriting all the methods and attributes of a Pandas DataFrame.
PARAMETER | DESCRIPTION |
---|---|
path |
The path to the CSV file.
TYPE:
|
date_col |
The name of the column containing dates. Defaults to the index.
DEFAULT:
|
past |
If True, the OracleDataFrame will return only the data before the current date. If False, it will return only the data after the current date.
TYPE:
|
kwargs |
Additional keyword arguments to pass to `pd.read
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
OracleDataFrame
|
The OracleDataFrame created from the CSV file. |
pl_from_csv
classmethod
Create an OracleDataFrame from a CSV file inheriting all the methods and attributes of a Polars DataFrame.
PARAMETER | DESCRIPTION |
---|---|
path |
The path to the CSV file.
TYPE:
|
date_col |
The name of the column containing dates. Defaults to the index.
DEFAULT:
|
past |
If True, the OracleDataFrame will return only the data before the current date. If False, it will return only the data after the current date.
TYPE:
|
kwargs |
Additional keyword arguments to pass to `pl.read
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
OracleDataFrame
|
The OracleDataFrame created from the CSV file. |