lg_changes
This commit is contained in:
parent
facf7fb0c6
commit
a04e8878fb
@ -2,7 +2,7 @@
|
|||||||
"security_type": "EQUITY",
|
"security_type": "EQUITY",
|
||||||
"data_directory": "./data/equity",
|
"data_directory": "./data/equity",
|
||||||
"datafiles": [
|
"datafiles": [
|
||||||
"202506*.mktdata.ohlcv.db",
|
"20250618.mktdata.ohlcv.db",
|
||||||
],
|
],
|
||||||
"db_table_name": "md_1min_bars",
|
"db_table_name": "md_1min_bars",
|
||||||
"exchange_id": "ALPACA",
|
"exchange_id": "ALPACA",
|
||||||
@ -19,8 +19,8 @@
|
|||||||
"dis-equilibrium_close_trshld": 1.0,
|
"dis-equilibrium_close_trshld": 1.0,
|
||||||
"training_minutes": 120,
|
"training_minutes": 120,
|
||||||
"funding_per_pair": 2000.0,
|
"funding_per_pair": 2000.0,
|
||||||
"fit_method_class": "pt_trading.sliding_fit.SlidingFit",
|
# "fit_method_class": "pt_trading.sliding_fit.SlidingFit",
|
||||||
# "fit_method_class": "pt_trading.static_fit.StaticFit",
|
"fit_method_class": "pt_trading.static_fit.StaticFit",
|
||||||
"exclude_instruments": ["CAN"],
|
"exclude_instruments": ["CAN"],
|
||||||
"close_outstanding_positions": false
|
"close_outstanding_positions": false
|
||||||
|
|
||||||
|
|||||||
26
configuration/equity_lg.cfg
Normal file
26
configuration/equity_lg.cfg
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"security_type": "EQUITY",
|
||||||
|
"data_directory": "./data/equity",
|
||||||
|
"datafiles": [
|
||||||
|
"20250602.mktdata.ohlcv.db",
|
||||||
|
],
|
||||||
|
"db_table_name": "md_1min_bars",
|
||||||
|
"exchange_id": "ALPACA",
|
||||||
|
"instrument_id_pfx": "STOCK-",
|
||||||
|
"trading_hours": {
|
||||||
|
"begin_session": "9:30:00",
|
||||||
|
"end_session": "16:00:00",
|
||||||
|
"timezone": "America/New_York"
|
||||||
|
},
|
||||||
|
"price_column": "close",
|
||||||
|
"min_required_points": 30,
|
||||||
|
"zero_threshold": 1e-10,
|
||||||
|
"dis-equilibrium_open_trshld": 2.0,
|
||||||
|
"dis-equilibrium_close_trshld": 1.0,
|
||||||
|
"training_minutes": 120,
|
||||||
|
"funding_per_pair": 2000.0,
|
||||||
|
"fit_method_class": "pt_trading.fit_methods.StaticFit",
|
||||||
|
"exclude_instruments": ["CAN"]
|
||||||
|
}
|
||||||
|
# "fit_method_class": "pt_trading.fit_methods.SlidingFit",
|
||||||
|
# "fit_method_class": "pt_trading.fit_methods.StaticFit",
|
||||||
115
lg_notes.md
Normal file
115
lg_notes.md
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
07.11.2025
|
||||||
|
pairs_trading/configuration <---- directory for config
|
||||||
|
equity_lg.cfg <-------- copy of equity.cfg
|
||||||
|
How to run a Program: TRIANGLEsquare ----> triangle EQUITY backtest
|
||||||
|
Results are in > results (timestamp table for all runs)
|
||||||
|
table "...timestamp... .pt_backtest_results.equity.db"
|
||||||
|
going to table using sqlite
|
||||||
|
> sqlite3 '/home/coder/results/20250721_175750.pt_backtest_results.equity.db'
|
||||||
|
|
||||||
|
sqlite> .databases
|
||||||
|
main: /home/coder/results/20250717_180122.pt_backtest_results.equity.db r/w
|
||||||
|
sqlite> .tables
|
||||||
|
config outstanding_positions pt_bt_results
|
||||||
|
|
||||||
|
sqlite> PRAGMA table_info('pt_bt_results');
|
||||||
|
0|date|DATE|0||0
|
||||||
|
1|pair|TEXT|0||0
|
||||||
|
2|symbol|TEXT|0||0
|
||||||
|
3|open_time|DATETIME|0||0
|
||||||
|
4|open_side|TEXT|0||0
|
||||||
|
5|open_price|REAL|0||0
|
||||||
|
6|open_quantity|INTEGER|0||0
|
||||||
|
7|open_disequilibrium|REAL|0||0
|
||||||
|
8|close_time|DATETIME|0||0
|
||||||
|
9|close_side|TEXT|0||0
|
||||||
|
10|close_price|REAL|0||0
|
||||||
|
11|close_quantity|INTEGER|0||0
|
||||||
|
12|close_disequilibrium|REAL|0||0
|
||||||
|
13|symbol_return|REAL|0||0
|
||||||
|
14|pair_return|REAL|0||0
|
||||||
|
|
||||||
|
select count(*) as cnt from pt_bt_results;
|
||||||
|
8
|
||||||
|
|
||||||
|
select * from pt_bt_results;
|
||||||
|
|
||||||
|
select
|
||||||
|
date, close_time, pair, symbol, symbol_return, pair_return
|
||||||
|
from pt_bt_results ;
|
||||||
|
|
||||||
|
select date, sum(symbol_return) as daily_return
|
||||||
|
from pt_bt_results where date = '2025-06-18' group by date;
|
||||||
|
|
||||||
|
.quit
|
||||||
|
|
||||||
|
sqlite3 '/home/coder/results/20250717_172435.pt_backtest_results.equity.db'
|
||||||
|
|
||||||
|
sqlite> select date, sum(symbol_return) as daily_return
|
||||||
|
from pt_bt_results group by date;
|
||||||
|
|
||||||
|
2025-06-02|1.29845390060828
|
||||||
|
...
|
||||||
|
2025-06-18|-43.5084977104115 <========== ????? ==========>
|
||||||
|
2025-06-20|11.8605547517183
|
||||||
|
|
||||||
|
|
||||||
|
select
|
||||||
|
date, close_time, pair, symbol, symbol_return, pair_return
|
||||||
|
from pt_bt_results ;
|
||||||
|
|
||||||
|
select date, close_time, pair, symbol, symbol_return, pair_return
|
||||||
|
from pt_bt_results where date = '2025-06-18';
|
||||||
|
|
||||||
|
|
||||||
|
./scripts/load_equity_pair_intraday.sh -A NVDA -B QQQ -d 20250701 -T ./intraday_md
|
||||||
|
|
||||||
|
to inspect exactly what sources, formats, and processing steps you can open the script with:
|
||||||
|
head -n 50 ./scripts/load_equity_pair_intraday.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
✓ Data file found: /home/coder/pairs_trading/data/crypto/20250605.mktdata.ohlcv.db
|
||||||
|
|
||||||
|
sqlite3 '/home/coder/results/20250722_201930.pt_backtest_results.crypto.db'
|
||||||
|
|
||||||
|
sqlite3 '/home/coder/results/xxxxxxxx_yyyyyy.pt_backtest_results.pseudo.db'
|
||||||
|
|
||||||
|
11111111
|
||||||
|
=== At your terminal, run these commands:
|
||||||
|
sqlite3 '/home/coder/results/20250722_201930.pt_backtest_results.crypto.db'
|
||||||
|
=== Then inside the SQLite prompt:
|
||||||
|
.mode csv
|
||||||
|
.headers on
|
||||||
|
.output results_20250722.csv
|
||||||
|
SELECT * FROM pt_bt_results;
|
||||||
|
.output stdout
|
||||||
|
.quit
|
||||||
|
|
||||||
|
cd /home/coder/
|
||||||
|
|
||||||
|
# === mode csv formats output as CSV
|
||||||
|
# === headers on includes column names
|
||||||
|
# === output my_table.csv directs output to that file
|
||||||
|
# === Run your SELECT query, then revert output
|
||||||
|
# === Open my_table.csv in Excel directly
|
||||||
|
|
||||||
|
# ======== Using scp (Secure Copy)
|
||||||
|
# === On your local machine, open a terminal and run:
|
||||||
|
scp cvtt@953f6e8df266:/home/coder/results_20250722.csv ~/Downloads/
|
||||||
|
|
||||||
|
|
||||||
|
# ===== convert cvs pandas dataframe ====== -->
|
||||||
|
import pandas as pd
|
||||||
|
# Replace with the actual path to your CSV file
|
||||||
|
file_path = '/home/coder/results_20250722.csv'
|
||||||
|
# Read the CSV file into a DataFrame
|
||||||
|
df = pd.read_csv(file_path)
|
||||||
|
# Show the first few rows
|
||||||
|
print(df.head())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
16
research/notebooks/pt_pair_backtest.ipynb
Normal file
16
research/notebooks/pt_pair_backtest.ipynb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"name": "python",
|
||||||
|
"version": "3.12.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user