This commit is contained in:
Oleg Sheynin 2025-07-23 02:56:00 +00:00
parent b7292c11f3
commit e0138907be
4 changed files with 461 additions and 609 deletions

View File

@ -38,7 +38,6 @@ CONFIG = EQT_CONFIG # For equity data
``` ```
Each configuration dictionary specifies: Each configuration dictionary specifies:
- `security_type`: "CRYPTO" or "EQUITY".
- `data_directory`: Path to the data files. - `data_directory`: Path to the data files.
- `datafiles`: A list of database files to process. You can comment/uncomment specific files to include/exclude them from the backtest. - `datafiles`: A list of database files to process. You can comment/uncomment specific files to include/exclude them from the backtest.
- `db_table_name`: The name of the table within the SQLite database. - `db_table_name`: The name of the table within the SQLite database.

46
configuration/zscore.cfg Normal file
View File

@ -0,0 +1,46 @@
{
"instrument_type_specifics": {
"CRYPTO": {
"data_directory": "./data/crypto",
"datafiles": [
"20250602.mktdata.ohlcv.db"
],
"db_table_name": "md_1min_bars",
"exchange_id": "BNBSPOT",
"instrument_id_pfx": "PAIR-",
},
"EQUITY": {
"data_directory": "./data/equity",
"datafiles": [
"20250602.mktdata.ohlcv.db"
],
"db_table_name": "md_1min_bars",
"exchange_id": "BNBSPOT",
"instrument_id_pfx": "STOCK-",
}
},
# ====== Funding ======
"funding_per_pair": 2000.0,
# ====== Trading Parameters ======
"price_column": "close",
"dis-equilibrium_open_trshld": 2.0,
"dis-equilibrium_close_trshld": 0.5,
"training_minutes": 120,
"fit_method_class": "pt_trading.z-score_rolling_fit.ZScoreRollingFit",
# ====== Stop Conditions ======
"stop_close_conditions": {
"profit": 2.0,
"loss": -0.5
}
# ====== End of Session Closeout ======
"close_outstanding_positions": true,
# "close_outstanding_positions": false,
"trading_hours": {
"begin_session": "9:30:00",
"end_session": "22:30:00",
"timezone": "America/New_York"
}
}

View File

@ -42,14 +42,9 @@ def load_market_data(datafile: str, config: Dict) -> pd.DataFrame:
'"' + config["instrument_id_pfx"] + instrument + '"' '"' + config["instrument_id_pfx"] + instrument + '"'
for instrument in config["instruments"] for instrument in config["instruments"]
] ]
security_type = config["security_type"]
exchange_id = config["exchange_id"] exchange_id = config["exchange_id"]
query = "select" query = "select"
if security_type == "CRYPTO":
query += " strftime('%Y-%m-%d %H:%M:%S', tstamp_ns/1000000000, 'unixepoch') as tstamp"
query += ", tstamp as time_ns"
else:
query += " tstamp" query += " tstamp"
query += ", tstamp_ns as time_ns" query += ", tstamp_ns as time_ns"

File diff suppressed because one or more lines are too long