Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c5ed951b2a | |||
| c77377f67e | |||
| 8ccebf81f5 | |||
| dc38176529 | |||
| 3f29717b64 | |||
| ecc1c1de5d |
+1
-3
@@ -3,10 +3,8 @@ __pycache__/
|
||||
__OLD__/
|
||||
.specstory/
|
||||
.history/
|
||||
.cursorindexingignore
|
||||
.vscode/
|
||||
data
|
||||
cvttpy
|
||||
# SpecStory explanation file
|
||||
.specstory/.what-is-this.md
|
||||
results/
|
||||
tmp/
|
||||
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
PYTHONPATH=/home/oleg/develop
|
||||
Vendored
-133
@@ -1,133 +0,0 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
|
||||
{
|
||||
"name": "Python Debugger: Current File",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"python": "/home/oleg/.pyenv/python3.12-venv/bin/python",
|
||||
"program": "${file}",
|
||||
"console": "integratedTerminal",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder}/lib:${workspaceFolder}/.."
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "-------- VECM --------",
|
||||
},
|
||||
{
|
||||
"name": "CRYPTO VECM BACKTEST (optimized)",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"python": "/home/oleg/.pyenv/python3.12-venv/bin/python",
|
||||
"program": "${workspaceFolder}/research/backtest.py",
|
||||
"args": [
|
||||
"--config=http://cloud16.cvtt.vpn:6789/apps/pairs_trading/backtest",
|
||||
"--instruments=CRYPTO:BNBSPOT:PAIR-ADA-USDT,CRYPTO:BNBSPOT:PAIR-SOL-USDT",
|
||||
"--date_pattern=20250911",
|
||||
"--result_db=${workspaceFolder}/research/results/crypto/%T.vecm-opt.ADA-SOL.20250605.crypto_results.db",
|
||||
],
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder}/..",
|
||||
"CONFIG_SERVICE": "cloud16.cvtt.vpn:6789",
|
||||
"MODEL_CONFIG": "vecm-opt"
|
||||
},
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
// {
|
||||
// "name": "EQUITY VECM (rolling)",
|
||||
// "type": "debugpy",
|
||||
// "request": "launch",
|
||||
// "python": "/home/oleg/.pyenv/python3.12-venv/bin/python",
|
||||
// "program": "${workspaceFolder}/research/backtest.py",
|
||||
// "args": [
|
||||
// "--config=${workspaceFolder}/configuration/vecm.cfg",
|
||||
// "--instruments=COIN:EQUITY:ALPACA,MSTR:EQUITY:ALPACA",
|
||||
// "--date_pattern=20250605",
|
||||
// "--result_db=${workspaceFolder}/research/results/equity/%T.vecm.COIN-MSTR.20250605.equity_results.db",
|
||||
// ],
|
||||
// "env": {
|
||||
// "PYTHONPATH": "${workspaceFolder}/lib"
|
||||
// },
|
||||
// "console": "integratedTerminal"
|
||||
// },
|
||||
// {
|
||||
// "name": "EQUITY-CRYPTO VECM (rolling)",
|
||||
// "type": "debugpy",
|
||||
// "request": "launch",
|
||||
// "python": "/home/oleg/.pyenv/python3.12-venv/bin/python",
|
||||
// "program": "${workspaceFolder}/research/backtest.py",
|
||||
// "args": [
|
||||
// "--config=${workspaceFolder}/configuration/vecm.cfg",
|
||||
// "--instruments=COIN:EQUITY:ALPACA,BTC-USDT:CRYPTO:BNBSPOT",
|
||||
// "--date_pattern=20250605",
|
||||
// "--result_db=${workspaceFolder}/research/results/intermarket/%T.vecm.COIN-BTC.20250601.equity_results.db",
|
||||
// ],
|
||||
// "env": {
|
||||
// "PYTHONPATH": "${workspaceFolder}/lib"
|
||||
// },
|
||||
// "console": "integratedTerminal"
|
||||
// },
|
||||
{
|
||||
"name": "-------- B a t c h e s --------",
|
||||
},
|
||||
{
|
||||
"name": "CRYPTO OLS Batch (rolling)",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"python": "/home/oleg/.pyenv/python3.12-venv/bin/python",
|
||||
"program": "${workspaceFolder}/research/backtest.py",
|
||||
"args": [
|
||||
"--config=${workspaceFolder}/configuration/ols.cfg",
|
||||
"--instruments=ADA-USDT:CRYPTO:BNBSPOT,SOL-USDT:CRYPTO:BNBSPOT",
|
||||
"--date_pattern=2025060*",
|
||||
"--result_db=${workspaceFolder}/research/results/crypto/%T.ols.ADA-SOL.2025060-.crypto_results.db",
|
||||
],
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder}/lib"
|
||||
},
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
"name": "CRYPTO VECM Batch (rolling)",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"python": "/home/oleg/.pyenv/python3.12-venv/bin/python",
|
||||
"program": "${workspaceFolder}/research/backtest.py",
|
||||
"args": [
|
||||
"--config=${workspaceFolder}/configuration/vecm.cfg",
|
||||
"--instruments=ADA-USDT:CRYPTO:BNBSPOT,SOL-USDT:CRYPTO:BNBSPOT",
|
||||
"--date_pattern=2025060*",
|
||||
"--result_db=${workspaceFolder}/research/results/crypto/%T.vecm.ADA-SOL.2025060-.crypto_results.db",
|
||||
],
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder}/lib"
|
||||
},
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
"name": "-------- Viz Test --------",
|
||||
},
|
||||
{
|
||||
"name": "Viz Test",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"python": "/home/oleg/.pyenv/python3.12-venv/bin/python",
|
||||
"program": "${workspaceFolder}/tests/viz_test.py",
|
||||
"args": [
|
||||
"--config=${workspaceFolder}/configuration/ols.cfg",
|
||||
"--instruments=ADA-USDT:CRYPTO:BNBSPOT,SOL-USDT:CRYPTO:BNBSPOT",
|
||||
"--date_pattern=20250605",
|
||||
],
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder}/lib"
|
||||
},
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": ".."
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"workbench.colorTheme": "Dracula Theme"
|
||||
}
|
||||
}
|
||||
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"python.testing.pytestEnabled": true,
|
||||
"python.testing.unittestEnabled": false,
|
||||
"python.testing.pytestArgs": [
|
||||
"unittests"
|
||||
],
|
||||
"python.testing.cwd": "${workspaceFolder}",
|
||||
"python.testing.autoTestDiscoverOnSaveEnabled": true,
|
||||
"python.testing.pytestPath": "python3",
|
||||
"python.analysis.extraPaths": [
|
||||
"${workspaceFolder}",
|
||||
"${workspaceFolder}/..",
|
||||
"${workspaceFolder}/unittests"
|
||||
],
|
||||
"python.envFile": "${workspaceFolder}/.env",
|
||||
"python.testing.debugPort": 3000,
|
||||
"python.testing.promptToConfigure": false,
|
||||
"python.defaultInterpreterPath": "/home/oleg/.pyenv/python3.12-venv/bin/python"
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
# Agent Instructions
|
||||
|
||||
## Repository purpose
|
||||
|
||||
This repository analyzes test results with Jupyter notebooks and Python or
|
||||
Bash scripts. Inputs are commonly SQLite databases containing time-series data
|
||||
and JSON columns, but analyses may use other test-result formats.
|
||||
|
||||
Ignore `__SAV__/`. It is unrelated legacy material, is not part of the active
|
||||
project, and must not be read, edited, moved, or used as a source of conventions
|
||||
unless the user explicitly requests it.
|
||||
|
||||
## Active layout
|
||||
|
||||
- `notebooks/`: exploratory and report-oriented Jupyter notebooks.
|
||||
- `scripts/`: reusable Python and Bash analysis utilities.
|
||||
- `data/`: local input data. Contents are ignored except for `.gitkeep`.
|
||||
- `results/`: generated tables, figures, exports, and reports. Contents are
|
||||
ignored except for `.gitkeep`.
|
||||
- `requirements.txt`: Python dependencies needed to reproduce repository work.
|
||||
|
||||
Keep reusable logic in `scripts/` and use notebooks to orchestrate analysis,
|
||||
explain decisions, and present results. Do not create a separate `analysis/`
|
||||
tree.
|
||||
|
||||
## Python environment
|
||||
|
||||
The intended virtual environment is `~/.pyenv/python3.12-venv`.
|
||||
|
||||
```bash
|
||||
source ~/.pyenv/python3.12-venv/bin/activate
|
||||
python -m pip install -r requirements.txt
|
||||
```
|
||||
|
||||
Agents may install packages in this environment when needed. Whenever a package
|
||||
is installed for repository work, update `requirements.txt` in the same change
|
||||
with a suitable direct dependency declaration. Use `python -m pip`, not bare
|
||||
`pip`, in documented commands.
|
||||
|
||||
Do not create an in-repository virtual environment unless the user asks for
|
||||
one.
|
||||
|
||||
## Data handling
|
||||
|
||||
- Treat files in `data/` as local, potentially large, and potentially
|
||||
sensitive.
|
||||
- Do not commit SQLite databases, raw test results, or generated results.
|
||||
- Do not modify source data in place. Write transformed data and exports under
|
||||
`results/`.
|
||||
- Use parameterized SQL for values. Do not construct SQL by interpolating
|
||||
untrusted data.
|
||||
- Parse JSON columns defensively and preserve missing, malformed, and unexpected
|
||||
values unless the analysis explicitly defines another policy.
|
||||
- State assumptions about timestamps, time zones, ordering, units, and duplicate
|
||||
observations in the notebook or script that relies on them.
|
||||
- Avoid loading entire databases into memory when a filtered query or chunked
|
||||
read is practical.
|
||||
|
||||
## Notebook conventions
|
||||
|
||||
- A notebook must run from a fresh kernel, top to bottom, without relying on
|
||||
hidden interactive state.
|
||||
- Set random seeds where nondeterminism affects results.
|
||||
- Keep data paths relative to the repository root and avoid machine-specific
|
||||
absolute paths.
|
||||
- Move logic that is reused or substantial enough to test into `scripts/`.
|
||||
- Clear cell outputs before committing notebooks. Never commit embedded source
|
||||
data, credentials, or bulky generated output.
|
||||
- Keep concise Markdown context near analyses: purpose, input assumptions,
|
||||
method, and interpretation.
|
||||
|
||||
## Scripts
|
||||
|
||||
- Python scripts should expose reusable functions and use a guarded CLI entry
|
||||
point when executable.
|
||||
- Bash scripts must start with `#!/usr/bin/env bash` and use
|
||||
`set -euo pipefail`.
|
||||
- Prefer explicit CLI arguments over hard-coded paths or parameters.
|
||||
- Fail with actionable error messages when required data, tables, columns, or
|
||||
configuration are missing.
|
||||
|
||||
## Verification
|
||||
|
||||
Verification should be proportional to the change. At minimum:
|
||||
|
||||
- Run `pytest` for Python script changes.
|
||||
- Add or update tests for reusable parsing, transformation, query, and
|
||||
calculation logic.
|
||||
- Execute changed notebooks from a fresh kernel with `nbmake`.
|
||||
- Run changed Bash scripts against a safe fixture or exercise their
|
||||
non-destructive validation/help path.
|
||||
- Clear notebook outputs after execution and before committing.
|
||||
|
||||
Useful commands:
|
||||
|
||||
```bash
|
||||
python -m pytest
|
||||
python -m pytest --nbmake notebooks
|
||||
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace path/to/notebook.ipynb
|
||||
```
|
||||
|
||||
If verification cannot be run, report exactly what was skipped and why.
|
||||
|
||||
## Release rules
|
||||
|
||||
- Update `CHANGELOG.md` for every release with the release version, release
|
||||
date, Git tag, and a concise summary of notable changes.
|
||||
- Use release headers in `YYYY-MM-DD vMAJOR.MINOR.PATCH` form.
|
||||
- Use version numbers in `MAJOR.MINOR.PATCH` form. Start this repository at
|
||||
`0.0.1`.
|
||||
- Use Git tags in `vMAJOR.MINOR.PATCH` form, matching the changelog version
|
||||
exactly. For example, version `0.0.1` must be tagged as `v0.0.1`.
|
||||
- Create the Git tag only after the changelog and any release-related version
|
||||
changes are complete.
|
||||
- Do not push release commits or tags unless the user explicitly requests it.
|
||||
|
||||
## Mandatory background review
|
||||
|
||||
Changes to Python scripts, Bash scripts, or notebook code cells require approval
|
||||
from a separate background reviewer agent before the implementing agent may
|
||||
declare the work complete.
|
||||
|
||||
The implementing agent must:
|
||||
|
||||
1. Finish the implementation and run the relevant verification.
|
||||
2. Ask a separate background agent to review the diff for correctness,
|
||||
reproducibility, data safety, and test coverage.
|
||||
3. Address every material finding, rerun affected checks, and request follow-up
|
||||
review when the fix materially changes the code.
|
||||
4. Report the reviewer outcome in the final response.
|
||||
|
||||
The reviewer must inspect the actual diff and relevant surrounding files; a
|
||||
self-review does not satisfy this requirement. Documentation-only,
|
||||
configuration-only, dependency-only, and ignore-rule-only changes do not
|
||||
require background approval unless they also alter Python, Bash, or notebook
|
||||
code cells.
|
||||
|
||||
If no background reviewer is available, complete all other work but do not
|
||||
claim reviewer approval. End the handoff with the exact status:
|
||||
|
||||
`review pending`
|
||||
|
||||
## Change discipline
|
||||
|
||||
- Preserve user changes and avoid unrelated cleanup.
|
||||
- Do not edit or commit generated files from `data/` or `results/`.
|
||||
- Do not push or commit unless the user explicitly requests it. The `master`
|
||||
branch being unprotected does not imply permission to push directly.
|
||||
- Keep changes focused and explain any new assumptions or dependencies.
|
||||
@@ -0,0 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project are documented in this file.
|
||||
|
||||
## 2026-07-25 v0.0.1
|
||||
|
||||
- Established the initial repository structure and project guidance.
|
||||
@@ -0,0 +1,2 @@
|
||||
## 2026-02-09 (v0.0.9)
|
||||
- related to the changes made in *cvttpy_tools 1.4.7*
|
||||
@@ -0,0 +1 @@
|
||||
0.0.9
|
||||
@@ -13,19 +13,19 @@ from statsmodels.tsa.stattools import adfuller, coint # type: ignore
|
||||
from statsmodels.tsa.vector_ar.vecm import coint_johansen # type: ignore
|
||||
|
||||
|
||||
from cvttpy_tools.app import App
|
||||
from cvttpy_tools.base import NamedObject
|
||||
from cvttpy_tools.config import Config, CvttAppConfig
|
||||
from cvttpy_tools.logger import Log
|
||||
from cvttpy_tools.timeutils import NanoPerSec, SecPerHour, current_nanoseconds
|
||||
from cvttpy_tools.web.rest_client import RESTSender
|
||||
from cvttpy_tools.web.rest_service import RestService
|
||||
from cvttpy_tools.base.app import App
|
||||
from cvttpy_tools.base.base import NamedObject
|
||||
from cvttpy_tools.base.config import Config, CvttAppConfig
|
||||
from cvttpy_tools.base.logger import Log
|
||||
from cvttpy_tools.base.timeutils import NanoPerSec, SecPerHour, current_nanoseconds
|
||||
from cvttpy_tools.comm.web.rest_service import RestService
|
||||
|
||||
from cvttpy_trading.trading.exchange_config import ExchangeAccounts
|
||||
from cvttpy_trading.trading.instrument import ExchangeInstrument
|
||||
from cvttpy_trading.trading.mkt_data.md_summary import MdTradesAggregate, MdSummary
|
||||
|
||||
from pairs_trading.apps.pair_selector.renderer import HtmlRenderer
|
||||
from pairs_trading.lib.live.rest import RESTSender
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -3,9 +3,9 @@ from __future__ import annotations
|
||||
from typing import Any, Dict, List
|
||||
|
||||
|
||||
from cvttpy_tools.app import App
|
||||
from cvttpy_tools.base import NamedObject
|
||||
from cvttpy_tools.config import CvttAppConfig
|
||||
from cvttpy_tools.base.app import App
|
||||
from cvttpy_tools.base.base import NamedObject
|
||||
from cvttpy_tools.base.config import CvttAppConfig
|
||||
|
||||
|
||||
class HtmlRenderer(NamedObject):
|
||||
@@ -4,13 +4,13 @@ import asyncio
|
||||
from typing import Callable, Coroutine, Dict, List
|
||||
import aiohttp.web as web
|
||||
|
||||
from cvttpy_tools.app import App
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.base import NamedObject
|
||||
from cvttpy_tools.config import CvttAppConfig
|
||||
from cvttpy_tools.logger import Log
|
||||
from cvttpy_tools.base.app import App
|
||||
from cvttpy_tools.base.config import Config
|
||||
from cvttpy_tools.base.base import NamedObject
|
||||
from cvttpy_tools.base.config import CvttAppConfig
|
||||
from cvttpy_tools.base.logger import Log
|
||||
from cvttpy_tools.settings.cvtt_types import BookIdT
|
||||
from cvttpy_tools.web.rest_service import RestService
|
||||
from cvttpy_tools.comm.web.rest_service import RestService
|
||||
|
||||
# ---
|
||||
from cvttpy_trading.trading.instrument import ExchangeInstrument
|
||||
@@ -5,19 +5,19 @@ from typing import Dict, Any, List, Optional, Set
|
||||
|
||||
import requests
|
||||
|
||||
from cvttpy_tools.base import NamedObject
|
||||
from cvttpy_tools.logger import Log
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.timer import Timer
|
||||
from cvttpy_tools.timeutils import NanosT, current_seconds
|
||||
from cvttpy_tools.base.base import NamedObject
|
||||
from cvttpy_tools.base.logger import Log
|
||||
from cvttpy_tools.base.config import Config
|
||||
from cvttpy_tools.base.timer import Timer
|
||||
from cvttpy_tools.base.timeutils import NanosT, current_seconds
|
||||
from cvttpy_tools.settings.cvtt_types import InstrumentIdT, IntervalSecT
|
||||
from cvttpy_tools.web.rest_client import RESTSender
|
||||
# ---
|
||||
from cvttpy_trading.trading.instrument import ExchangeInstrument
|
||||
from cvttpy_trading.trading.accounting.exch_account import ExchangeAccountNameT
|
||||
from cvttpy_trading.trading.mkt_data.md_summary import MdTradesAggregate, MdSummary, MdSummaryCallbackT
|
||||
from cvttpy_trading.trading.exchange_config import ExchangeAccounts
|
||||
# ---
|
||||
from pairs_trading.lib.live.rest import RESTSender
|
||||
|
||||
|
||||
# class MdSummary(HistMdBar):
|
||||
@@ -1,14 +1,14 @@
|
||||
```python
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict
|
||||
from typing import Dict, Optional
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
||||
from cvttpy_tools.base import NamedObject
|
||||
from cvttpy_tools.base.base import NamedObject
|
||||
|
||||
class RESTSender(NamedObject):
|
||||
# Synchronous request sernder
|
||||
session_: requests.Session
|
||||
base_url_: str
|
||||
|
||||
@@ -26,35 +26,35 @@ class RESTSender(NamedObject):
|
||||
except requests.exceptions.RequestException:
|
||||
return False
|
||||
|
||||
def send_post(self, endpoint: str, post_body: Dict) -> requests.Response:
|
||||
|
||||
while not self.is_ready():
|
||||
print("Waiting for FrontGateway to start...")
|
||||
time.sleep(5)
|
||||
def send_post(
|
||||
self, endpoint: str, post_body: Dict, headers: Optional[Dict[str, str]] = None
|
||||
) -> requests.Response:
|
||||
|
||||
if not headers:
|
||||
headers = {"Content-Type": "application/json"}
|
||||
url = f"{self.base_url_}/{endpoint}"
|
||||
try:
|
||||
return self.session_.request(
|
||||
method="POST",
|
||||
url=url,
|
||||
json=post_body,
|
||||
headers={"Content-Type": "application/json"},
|
||||
headers=headers,
|
||||
)
|
||||
except requests.exceptions.RequestException as excpt:
|
||||
raise ConnectionError(
|
||||
f"Failed to send status={excpt.response.status_code} {excpt.response.text}" # type: ignore
|
||||
) from excpt
|
||||
|
||||
def send_get(self, endpoint: str) -> requests.Response:
|
||||
while not self.is_ready():
|
||||
print("Waiting for FrontGateway to start...")
|
||||
time.sleep(5)
|
||||
|
||||
def send_get(
|
||||
self, endpoint: str, headers: Optional[Dict[str, str]] = None
|
||||
) -> requests.Response:
|
||||
if not headers:
|
||||
headers = {}
|
||||
url = f"{self.base_url_}/{endpoint}"
|
||||
try:
|
||||
return self.session_.request(method="GET", url=url)
|
||||
return self.session_.request(method="GET", url=url, headers=headers)
|
||||
except requests.exceptions.RequestException as excpt:
|
||||
raise ConnectionError(
|
||||
f"Failed to send status={excpt.response.status_code} {excpt.response.text}" # type: ignore
|
||||
) from excpt
|
||||
```
|
||||
|
||||
@@ -3,14 +3,14 @@ from enum import Enum
|
||||
import requests
|
||||
|
||||
# import aiohttp
|
||||
from cvttpy_tools.base import NamedObject
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.logger import Log
|
||||
from cvttpy_tools.web.rest_client import RESTSender
|
||||
from cvttpy_tools.base.base import NamedObject
|
||||
from cvttpy_tools.base.config import Config
|
||||
from cvttpy_tools.base.logger import Log
|
||||
# ---
|
||||
from cvttpy_trading.trading.trading_instructions import TradingInstructions
|
||||
# ---
|
||||
from pairs_trading.apps.pair_trader import PairTrader
|
||||
from pairs_trading.lib.live.rest import RESTSender
|
||||
|
||||
|
||||
class TradingInstructionsSender(NamedObject):
|
||||
+5
-5
@@ -5,12 +5,12 @@ from typing import Any, Dict, List, Optional
|
||||
import pandas as pd
|
||||
|
||||
# ---
|
||||
from cvttpy_tools.base import NamedObject
|
||||
from cvttpy_tools.app import App
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.base.base import NamedObject
|
||||
from cvttpy_tools.base.app import App
|
||||
from cvttpy_tools.base.config import Config
|
||||
from cvttpy_tools.settings.cvtt_types import IntervalSecT
|
||||
from cvttpy_tools.timeutils import NanosT, SecPerHour, current_nanoseconds, NanoPerSec, format_nanos_utc
|
||||
from cvttpy_tools.logger import Log
|
||||
from cvttpy_tools.base.timeutils import NanosT, SecPerHour, current_nanoseconds, NanoPerSec, format_nanos_utc
|
||||
from cvttpy_tools.base.logger import Log
|
||||
|
||||
# ---
|
||||
from cvttpy_trading.trading.instrument import ExchangeInstrument
|
||||
@@ -8,7 +8,7 @@ from typing import Any, Dict, Optional, cast
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.base.config import Config
|
||||
|
||||
@dataclass
|
||||
class DataWindowParams:
|
||||
@@ -6,8 +6,8 @@ from typing import Any, Dict, List, Optional
|
||||
import pandas as pd
|
||||
|
||||
# ---
|
||||
from cvttpy_tools.base import NamedObject
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.base.base import NamedObject
|
||||
from cvttpy_tools.base.config import Config
|
||||
from cvttpy_tools.settings.cvtt_types import JsonDictT
|
||||
|
||||
# ---
|
||||
@@ -4,7 +4,7 @@ from abc import ABC, abstractmethod
|
||||
from typing import Any, Dict, cast
|
||||
|
||||
# ---
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.base.config import Config
|
||||
# ---
|
||||
from pairs_trading.lib.pt_strategy.prediction import Prediction
|
||||
from pairs_trading.lib.pt_strategy.trading_pair import TradingPair
|
||||
@@ -4,7 +4,7 @@ from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
import pandas as pd
|
||||
# ---
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.base.config import Config
|
||||
# ---
|
||||
from cvttpy_trading.trading.instrument import ExchangeInstrument
|
||||
# ---
|
||||
@@ -5,7 +5,7 @@ from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
import pandas as pd
|
||||
# ---
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.base.config import Config
|
||||
# ---
|
||||
from cvttpy_trading.trading.instrument import ExchangeInstrument
|
||||
# ---
|
||||
@@ -8,8 +8,8 @@ from typing import Any, Dict, List
|
||||
import pandas as pd
|
||||
|
||||
# ---
|
||||
from cvttpy_tools.base import NamedObject
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.base.base import NamedObject
|
||||
from cvttpy_tools.base.config import Config
|
||||
# ---
|
||||
from cvttpy_trading.trading.instrument import ExchangeInstrument
|
||||
# ---
|
||||
@@ -2,7 +2,7 @@ import hjson
|
||||
from typing import Dict
|
||||
from datetime import datetime
|
||||
# ---
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.base.config import Config
|
||||
|
||||
|
||||
def load_config(config_path: str) -> Config:
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
import glob
|
||||
from typing import Dict, List, Tuple
|
||||
# ---
|
||||
from cvttpy_tools.config import Config
|
||||
from cvttpy_tools.base.config import Config
|
||||
# ---
|
||||
from cvttpy_trading.trading.instrument import ExchangeInstrument
|
||||
|
||||
@@ -4,9 +4,9 @@ import os
|
||||
from typing import Any, Dict, List, Tuple
|
||||
|
||||
# ---
|
||||
from cvttpy_tools.app import App
|
||||
from cvttpy_tools.base import NamedObject
|
||||
from cvttpy_tools.config import CvttAppConfig
|
||||
from cvttpy_tools.base.app import App
|
||||
from cvttpy_tools.base.base import NamedObject
|
||||
from cvttpy_tools.base.config import CvttAppConfig
|
||||
|
||||
# ---
|
||||
from cvttpy_trading.trading.instrument import ExchangeInstrument
|
||||
+1
-1
@@ -182,7 +182,7 @@
|
||||
"import os\n",
|
||||
"import importlib\n",
|
||||
"\n",
|
||||
"from cvttpy_tools.config import Config\n",
|
||||
"from cvttpy_tools.base.config import Config\n",
|
||||
"\n",
|
||||
"def load_config_from_file() -> Optional[Dict]:\n",
|
||||
" global DB_TABLE_NAME\n",
|
||||
@@ -1,43 +0,0 @@
|
||||
{
|
||||
"market_data_loading": {
|
||||
"CRYPTO": {
|
||||
"data_directory": "./data/crypto",
|
||||
"db_table_name": "md_1min_bars",
|
||||
"instrument_id_pfx": "PAIR-",
|
||||
},
|
||||
"EQUITY": {
|
||||
"data_directory": "./data/equity",
|
||||
"db_table_name": "md_1min_bars",
|
||||
"instrument_id_pfx": "STOCK-",
|
||||
}
|
||||
},
|
||||
|
||||
# ====== Funding ======
|
||||
"funding_per_pair": 2000.0,
|
||||
# ====== Trading Parameters ======
|
||||
"stat_model_price": "close",
|
||||
"execution_price": {
|
||||
"column": "vwap",
|
||||
"shift": 1,
|
||||
},
|
||||
"dis-equilibrium_open_trshld": 2.0,
|
||||
"dis-equilibrium_close_trshld": 0.5,
|
||||
"training_size": 120,
|
||||
"model_class": "pairs_trading.lib.pt_strategy.models.OLSModel",
|
||||
"model_data_policy_class": "pairs_trading.lib.pt_strategy.model_data_policy.ExpandingWindowDataPolicy",
|
||||
|
||||
# ====== 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": {
|
||||
"timezone": "America/New_York",
|
||||
"begin_session": "7:30:00",
|
||||
"end_session": "18:30:00",
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"market_data_loading": {
|
||||
"CRYPTO": {
|
||||
"data_directory": "./data/crypto",
|
||||
"db_table_name": "md_1min_bars",
|
||||
"instrument_id_pfx": "PAIR-",
|
||||
},
|
||||
"EQUITY": {
|
||||
"data_directory": "./data/equity",
|
||||
"db_table_name": "md_1min_bars",
|
||||
"instrument_id_pfx": "STOCK-",
|
||||
}
|
||||
},
|
||||
|
||||
# ====== Funding ======
|
||||
"funding_per_pair": 2000.0,
|
||||
# ====== Trading Parameters ======
|
||||
"stat_model_price": "close",
|
||||
"execution_price": {
|
||||
"column": "vwap",
|
||||
"shift": 1,
|
||||
},
|
||||
"dis-equilibrium_open_trshld": 1.75,
|
||||
"dis-equilibrium_close_trshld": 0.9,
|
||||
"model_class": "pairs_trading.lib.pt_strategy.models.OLSModel",
|
||||
|
||||
# "model_data_policy_class": "pairs_trading.lib.pt_strategy.model_data_policy.EGOptimizedWndDataPolicy",
|
||||
# "model_data_policy_class": "pairs_trading.lib.pt_strategy.model_data_policy.ADFOptimizedWndDataPolicy",
|
||||
"model_data_policy_class": "pairs_trading.lib.pt_strategy.model_data_policy.JohansenOptdWndDataPolicy",
|
||||
"min_training_size": 60,
|
||||
"max_training_size": 150,
|
||||
|
||||
# ====== 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": {
|
||||
"timezone": "America/New_York",
|
||||
"begin_session": "7:30:00",
|
||||
"end_session": "18:30:00",
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"market_data_loading": {
|
||||
"CRYPTO": {
|
||||
"data_directory": "./data/crypto",
|
||||
"db_table_name": "md_1min_bars",
|
||||
"instrument_id_pfx": "PAIR-",
|
||||
},
|
||||
"EQUITY": {
|
||||
"data_directory": "./data/equity",
|
||||
"db_table_name": "md_1min_bars",
|
||||
"instrument_id_pfx": "STOCK-",
|
||||
}
|
||||
},
|
||||
|
||||
# ====== Funding ======
|
||||
"funding_per_pair": 2000.0,
|
||||
# ====== Trading Parameters ======
|
||||
"stat_model_price": "close",
|
||||
"execution_price": {
|
||||
"column": "vwap",
|
||||
"shift": 1,
|
||||
},
|
||||
"dis-equilibrium_open_trshld": 1.75,
|
||||
"dis-equilibrium_close_trshld": 0.9,
|
||||
"model_class": "pairs_trading.lib.pt_strategy.models.OLSModel",
|
||||
|
||||
"training_size": 120,
|
||||
"model_data_policy_class": "pairs_trading.lib.pt_strategy.model_data_policy.RollingWindowDataPolicy",
|
||||
# "model_data_policy_class": "pairs_trading.lib.pt_strategy.model_data_policy.OptimizedWindowDataPolicy",
|
||||
# "min_training_size": 60,
|
||||
# "max_training_size": 150,
|
||||
|
||||
# ====== 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": {
|
||||
"timezone": "America/New_York",
|
||||
"begin_session": "7:30:00",
|
||||
"end_session": "18:30:00",
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"market_data_loading": {
|
||||
"CRYPTO": {
|
||||
"data_directory": "./data/crypto",
|
||||
"db_table_name": "md_1min_bars",
|
||||
"instrument_id_pfx": "PAIR-",
|
||||
},
|
||||
"EQUITY": {
|
||||
"data_directory": "./data/equity",
|
||||
"db_table_name": "md_1min_bars",
|
||||
"instrument_id_pfx": "STOCK-",
|
||||
}
|
||||
},
|
||||
|
||||
# ====== Funding ======
|
||||
"funding_per_pair": 2000.0,
|
||||
|
||||
# ====== Trading Parameters ======
|
||||
"stat_model_price": "close", # "vwap"
|
||||
"execution_price": {
|
||||
"column": "vwap",
|
||||
"shift": 1,
|
||||
},
|
||||
"dis-equilibrium_open_trshld": 1.75,
|
||||
"dis-equilibrium_close_trshld": 1.0,
|
||||
"model_class": "pairs_trading.lib.pt_strategy.models.VECMModel",
|
||||
|
||||
"training_size": 120,
|
||||
"model_data_policy_class": "pairs_trading.lib.pt_strategy.model_data_policy.RollingWindowDataPolicy",
|
||||
# "model_data_policy_class": "pairs_trading.lib.pt_strategy.model_data_policy.OptimizedWindowDataPolicy",
|
||||
# "min_training_size": 60,
|
||||
# "max_training_size": 150,
|
||||
|
||||
# ====== 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": {
|
||||
"timezone": "America/New_York",
|
||||
"begin_session": "7:30:00",
|
||||
"end_session": "18:30:00",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user