feat: expose minfied when converting trade list to dataframe
This commit is contained in:
@@ -517,13 +517,16 @@ def load_backtest_analysis_data(
|
||||
return None
|
||||
|
||||
|
||||
def trade_list_to_dataframe(trades: list[Trade] | list[LocalTrade]) -> pd.DataFrame:
|
||||
def trade_list_to_dataframe(
|
||||
trades: list[Trade] | list[LocalTrade], *, minified: bool = True
|
||||
) -> pd.DataFrame:
|
||||
"""
|
||||
Convert list of Trade objects to pandas Dataframe
|
||||
:param trades: List of trade objects
|
||||
:param minified: Whether to use minified version of trade JSON
|
||||
:return: Dataframe with BT_DATA_COLUMNS
|
||||
"""
|
||||
df = pd.DataFrame.from_records([t.to_json(True) for t in trades], columns=BT_DATA_COLUMNS)
|
||||
df = pd.DataFrame.from_records([t.to_json(minified) for t in trades], columns=BT_DATA_COLUMNS)
|
||||
if len(df) > 0:
|
||||
df["close_date"] = pd.to_datetime(df["close_timestamp"], unit="ms", utc=True)
|
||||
df["open_date"] = pd.to_datetime(df["open_timestamp"], unit="ms", utc=True)
|
||||
|
||||
Reference in New Issue
Block a user