Files
AlphaFlow-MT5-ML-DL-Trading…/backtests/__pycache__/vectorbt_backtest.cpython-311.pyc
T

41 lines
2.6 KiB
Plaintext
Raw Normal View History

2025-03-02 22:25:33 +01:00
§
ˆl³g ãó,ddlZddlZddlZ ddZdS)é'Ú4Hçc óž||}| |¦«} | | ¦«}
|dkr4tj|
|kdtj|
| kdd¦«¦«} ntj|
¦«} |j|jdf} t| ¦«t| ¦«kr6tj| dgt| ¦«t| ¦«z
z¦«} tj
| | j¬¦«}
|   |
dd¬¦«\} }
tj
 | |
dk|
dk||¬ ¦«}|S)
a`
Runs a vectorbt backtest for a given pre-trained model.
Parameters
----------
model : fitted scikit-learn model
Already fitted model (e.g. RandomForestRegressor).
X : pd.DataFrame
The full feature DataFrame (or the portion you want to backtest).
selected_features : list
List of feature names used by the model.
data : pd.DataFrame
Original DataFrame containing at least a 'close' column.
scaler : fitted scaler
The StandardScaler (or other) used to scale features.
init_cash : float
Starting capital for the backtest.
freq : str
Frequency for vectorbt (e.g. '4H', '1D').
threshold : float
Minimum absolute predicted return to place a trade (optional).
Returns
-------
pf : vbt.Portfolio
The resulting vectorbt portfolio object.
rééÿÿÿÿrÚclose)ÚindexÚinner)ÚjoinÚaxis)ÚentriesÚexitsÚ init_cashÚfreq)Ú transformÚpredictÚnpÚwhereÚsignÚlocr