clawdfolio 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- clawdfolio-2.2.0/.github/dependabot.yml +10 -0
- clawdfolio-2.2.0/.github/workflows/ci.yml +60 -0
- clawdfolio-2.2.0/.github/workflows/release.yml +58 -0
- clawdfolio-2.2.0/.gitignore +70 -0
- clawdfolio-2.2.0/.pre-commit-config.yaml +15 -0
- clawdfolio-2.2.0/CHANGELOG.md +51 -0
- clawdfolio-2.2.0/LICENSE +21 -0
- clawdfolio-2.2.0/PKG-INFO +340 -0
- clawdfolio-2.2.0/PROMOTION.md +312 -0
- clawdfolio-2.2.0/README.md +295 -0
- clawdfolio-2.2.0/README_CN.md +295 -0
- clawdfolio-2.2.0/SKILL.md +135 -0
- clawdfolio-2.2.0/docs/OPTIONS_STRATEGY_PLAYBOOK_v2.1.md +314 -0
- clawdfolio-2.2.0/examples/basic_usage.py +82 -0
- clawdfolio-2.2.0/examples/config.example.yaml +54 -0
- clawdfolio-2.2.0/pyproject.toml +137 -0
- clawdfolio-2.2.0/src/clawdfolio/__init__.py +31 -0
- clawdfolio-2.2.0/src/clawdfolio/analysis/__init__.py +44 -0
- clawdfolio-2.2.0/src/clawdfolio/analysis/concentration.py +230 -0
- clawdfolio-2.2.0/src/clawdfolio/analysis/risk.py +312 -0
- clawdfolio-2.2.0/src/clawdfolio/analysis/technical.py +316 -0
- clawdfolio-2.2.0/src/clawdfolio/brokers/__init__.py +11 -0
- clawdfolio-2.2.0/src/clawdfolio/brokers/base.py +132 -0
- clawdfolio-2.2.0/src/clawdfolio/brokers/demo.py +174 -0
- clawdfolio-2.2.0/src/clawdfolio/brokers/futu.py +286 -0
- clawdfolio-2.2.0/src/clawdfolio/brokers/longport.py +196 -0
- clawdfolio-2.2.0/src/clawdfolio/brokers/registry.py +101 -0
- clawdfolio-2.2.0/src/clawdfolio/cli/__init__.py +20 -0
- clawdfolio-2.2.0/src/clawdfolio/cli/main.py +711 -0
- clawdfolio-2.2.0/src/clawdfolio/core/__init__.py +25 -0
- clawdfolio-2.2.0/src/clawdfolio/core/config.py +327 -0
- clawdfolio-2.2.0/src/clawdfolio/core/exceptions.py +58 -0
- clawdfolio-2.2.0/src/clawdfolio/core/types.py +273 -0
- clawdfolio-2.2.0/src/clawdfolio/finance/__init__.py +29 -0
- clawdfolio-2.2.0/src/clawdfolio/finance/runner.py +132 -0
- clawdfolio-2.2.0/src/clawdfolio/finance/workflows.py +214 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/README.md +24 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/__init__.py +1 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/archive_scripts/account_report_excel.py +108 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/archive_scripts/binance_assets_summary.py +118 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/archive_scripts/broker_assets_combined.py +113 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/archive_scripts/longport_assets.py +45 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/archive_scripts/longport_full_report.py +214 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/archive_scripts/moomoo_full_report.py +231 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/account_report.py +410 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/config.example.json +37 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/dca_proposal_tg.py +110 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/earnings_calendar.py +124 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/lib/__init__.py +1 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/lib/brokers.py +438 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/lib/env_loader.py +55 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/lib/fmt.py +96 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/lib/market.py +500 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/lib/market_data.py +180 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/lib/state.py +76 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/longport_assets_message.py +44 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/longport_assets_summary.py +108 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/market_news.py +151 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/moomoo_assets_message.py +134 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/option_buyback_monitor.py +140 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/portfolio_alert_monitor.py +568 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/portfolio_analysis_enhanced.py +376 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/portfolio_daily_brief.py +335 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/portfolio_daily_brief2.py +368 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/portfolio_daily_brief2_clean.py +35 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/portfolio_daily_brief_clean.py +34 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/portfolio_daily_brief_tg.py +367 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/portfolio_daily_brief_tg_clean.py +40 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/portfolio_report.py +515 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/portfolio_report_clean.py +46 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/realtime_quotes.py +148 -0
- clawdfolio-2.2.0/src/clawdfolio/legacy_finance/scripts/security_pin.py +85 -0
- clawdfolio-2.2.0/src/clawdfolio/market/__init__.py +56 -0
- clawdfolio-2.2.0/src/clawdfolio/market/calendar.py +191 -0
- clawdfolio-2.2.0/src/clawdfolio/market/data.py +735 -0
- clawdfolio-2.2.0/src/clawdfolio/market/hours.py +177 -0
- clawdfolio-2.2.0/src/clawdfolio/monitors/__init__.py +14 -0
- clawdfolio-2.2.0/src/clawdfolio/monitors/earnings.py +156 -0
- clawdfolio-2.2.0/src/clawdfolio/monitors/options.py +238 -0
- clawdfolio-2.2.0/src/clawdfolio/monitors/price.py +186 -0
- clawdfolio-2.2.0/src/clawdfolio/output/__init__.py +12 -0
- clawdfolio-2.2.0/src/clawdfolio/output/console.py +190 -0
- clawdfolio-2.2.0/src/clawdfolio/output/json.py +136 -0
- clawdfolio-2.2.0/src/clawdfolio/py.typed +0 -0
- clawdfolio-2.2.0/src/clawdfolio/strategies/__init__.py +9 -0
- clawdfolio-2.2.0/src/clawdfolio/strategies/dca.py +190 -0
- clawdfolio-2.2.0/src/clawdfolio/utils/__init__.py +5 -0
- clawdfolio-2.2.0/src/clawdfolio/utils/suppress.py +31 -0
- clawdfolio-2.2.0/tests/__init__.py +0 -0
- clawdfolio-2.2.0/tests/conftest.py +41 -0
- clawdfolio-2.2.0/tests/test_analysis.py +228 -0
- clawdfolio-2.2.0/tests/test_brokers.py +190 -0
- clawdfolio-2.2.0/tests/test_brokers_longport.py +53 -0
- clawdfolio-2.2.0/tests/test_cli.py +33 -0
- clawdfolio-2.2.0/tests/test_config.py +24 -0
- clawdfolio-2.2.0/tests/test_core.py +196 -0
- clawdfolio-2.2.0/tests/test_finance_runner.py +90 -0
- clawdfolio-2.2.0/tests/test_market.py +120 -0
- clawdfolio-2.2.0/tests/test_market_data.py +103 -0
- clawdfolio-2.2.0/tests/test_market_options.py +113 -0
- clawdfolio-2.2.0/tests/test_options_monitor.py +123 -0
- clawdfolio-2.2.0/tests/test_types.py +113 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
+
uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: pip install -e ".[dev]"
|
|
26
|
+
|
|
27
|
+
- name: Lint with ruff
|
|
28
|
+
run: ruff check src/ tests/
|
|
29
|
+
|
|
30
|
+
- name: Type check with mypy
|
|
31
|
+
run: mypy src/clawdfolio --ignore-missing-imports
|
|
32
|
+
|
|
33
|
+
- name: Run tests
|
|
34
|
+
run: pytest tests/ -v --cov=src/clawdfolio --cov-report=xml
|
|
35
|
+
|
|
36
|
+
- name: Upload coverage
|
|
37
|
+
if: matrix.python-version == '3.11'
|
|
38
|
+
uses: codecov/codecov-action@v5
|
|
39
|
+
with:
|
|
40
|
+
file: ./coverage.xml
|
|
41
|
+
|
|
42
|
+
build:
|
|
43
|
+
needs: test
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
|
|
48
|
+
- name: Set up Python
|
|
49
|
+
uses: actions/setup-python@v5
|
|
50
|
+
with:
|
|
51
|
+
python-version: "3.11"
|
|
52
|
+
|
|
53
|
+
- name: Install build tools
|
|
54
|
+
run: pip install build twine
|
|
55
|
+
|
|
56
|
+
- name: Build package
|
|
57
|
+
run: python -m build
|
|
58
|
+
|
|
59
|
+
- name: Check package
|
|
60
|
+
run: twine check dist/*
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- name: Set up Python
|
|
15
|
+
uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.11"
|
|
18
|
+
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: |
|
|
21
|
+
python -m pip install --upgrade pip
|
|
22
|
+
pip install build
|
|
23
|
+
|
|
24
|
+
- name: Build package
|
|
25
|
+
run: python -m build
|
|
26
|
+
|
|
27
|
+
- name: Upload build artifacts
|
|
28
|
+
uses: actions/upload-artifact@v4
|
|
29
|
+
with:
|
|
30
|
+
name: dist
|
|
31
|
+
path: dist/
|
|
32
|
+
|
|
33
|
+
publish:
|
|
34
|
+
needs: build
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
# Only run if PYPI_API_TOKEN is configured
|
|
37
|
+
if: ${{ vars.ENABLE_PYPI_PUBLISH == 'true' }}
|
|
38
|
+
|
|
39
|
+
steps:
|
|
40
|
+
- name: Download artifacts
|
|
41
|
+
uses: actions/download-artifact@v4
|
|
42
|
+
with:
|
|
43
|
+
name: dist
|
|
44
|
+
path: dist/
|
|
45
|
+
|
|
46
|
+
- name: Set up Python
|
|
47
|
+
uses: actions/setup-python@v5
|
|
48
|
+
with:
|
|
49
|
+
python-version: "3.11"
|
|
50
|
+
|
|
51
|
+
- name: Install twine
|
|
52
|
+
run: pip install twine
|
|
53
|
+
|
|
54
|
+
- name: Publish to PyPI
|
|
55
|
+
env:
|
|
56
|
+
TWINE_USERNAME: __token__
|
|
57
|
+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
|
58
|
+
run: twine upload dist/*
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
.env
|
|
25
|
+
.venv
|
|
26
|
+
env/
|
|
27
|
+
venv/
|
|
28
|
+
ENV/
|
|
29
|
+
|
|
30
|
+
# IDE
|
|
31
|
+
.idea/
|
|
32
|
+
.vscode/
|
|
33
|
+
*.swp
|
|
34
|
+
*.swo
|
|
35
|
+
*~
|
|
36
|
+
|
|
37
|
+
# Testing
|
|
38
|
+
.pytest_cache/
|
|
39
|
+
.coverage
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
|
|
44
|
+
# Type checking
|
|
45
|
+
.mypy_cache/
|
|
46
|
+
|
|
47
|
+
# Secrets - NEVER commit these
|
|
48
|
+
config.yaml
|
|
49
|
+
config.json
|
|
50
|
+
*.env
|
|
51
|
+
.env.*
|
|
52
|
+
secrets.yaml
|
|
53
|
+
credentials.json
|
|
54
|
+
|
|
55
|
+
# OS
|
|
56
|
+
.DS_Store
|
|
57
|
+
Thumbs.db
|
|
58
|
+
|
|
59
|
+
# Logs
|
|
60
|
+
*.log
|
|
61
|
+
logs/
|
|
62
|
+
|
|
63
|
+
# Local data
|
|
64
|
+
data/
|
|
65
|
+
*.db
|
|
66
|
+
*.sqlite
|
|
67
|
+
|
|
68
|
+
# Keep bundled legacy finance libs for v2 migration
|
|
69
|
+
!src/clawdfolio/legacy_finance/scripts/lib/
|
|
70
|
+
!src/clawdfolio/legacy_finance/scripts/lib/**
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v4.6.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: trailing-whitespace
|
|
6
|
+
- id: end-of-file-fixer
|
|
7
|
+
- id: check-yaml
|
|
8
|
+
- id: check-added-large-files
|
|
9
|
+
|
|
10
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
11
|
+
rev: v0.8.6
|
|
12
|
+
hooks:
|
|
13
|
+
- id: ruff
|
|
14
|
+
args: [--fix]
|
|
15
|
+
- id: ruff-format
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.2.0] - 2025-02-14
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `py.typed` marker file for PEP 561 compliance, enabling downstream type-checking support.
|
|
13
|
+
- `clawdfolio.utils.suppress` shared module with `suppress_stdio` context manager (DRY refactor from `brokers/futu.py` and `brokers/longport.py`).
|
|
14
|
+
- `CHANGELOG.md` to track version history.
|
|
15
|
+
- Structured `logging` across core modules (`market/data.py`, `brokers/futu.py`, `brokers/longport.py`, `cli/main.py`).
|
|
16
|
+
- `_yf_symbol()` centralised ticker normalisation helper in `market/data.py`.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **Version bumped to 2.2.0.**
|
|
21
|
+
- CLI `--version` flag now reads dynamically from `clawdfolio.__version__` instead of a hardcoded string.
|
|
22
|
+
- `get_quotes_yfinance()` rewritten to use `yf.download` for batch retrieval with per-ticker fallback, significantly reducing API calls.
|
|
23
|
+
- Market data cache (`_cache`) is now protected by `threading.Lock` for thread-safe concurrent access.
|
|
24
|
+
- NaN check in `_safe_float()` replaced from `num == num` idiom to explicit `math.isnan(num)`.
|
|
25
|
+
- Config search now prefers `CLAWDFOLIO_CONFIG` env var and `~/.config/clawdfolio/` paths, with backward-compatible fallback to `PORTFOLIO_MONITOR_CONFIG` and `~/.config/portfolio-monitor/`.
|
|
26
|
+
- Module docstring in `core/config.py` and `core/exceptions.py` updated from "Portfolio Monitor" to "Clawdfolio".
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- All repository URLs in `pyproject.toml`, `README.md`, and `README_CN.md` corrected from `2165187809-AXE/clawdfolio` to `YichengYang-Ethan/clawdfolio`.
|
|
31
|
+
- Removed unused `import io` side-effect in `brokers/longport.py` (kept only where actually needed).
|
|
32
|
+
|
|
33
|
+
## [2.1.0] - 2025-01-28
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- Dedicated options strategy playbook (`docs/OPTIONS_STRATEGY_PLAYBOOK_v2.1.md`).
|
|
38
|
+
- Research-to-execution alignment for CC and Sell Put lifecycle management.
|
|
39
|
+
- Explicit gamma-risk, margin, leverage, roll, assignment, and pause-condition decision rules.
|
|
40
|
+
- Feature mapping connecting strategy decisions to `clawdfolio options` and `clawdfolio finance` workflows.
|
|
41
|
+
|
|
42
|
+
## [2.0.0] - 2025-01-15
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- Full finance migration from `~/clawd/scripts` (20 production workflows).
|
|
47
|
+
- `clawdfolio finance` command group (list, init, run).
|
|
48
|
+
- Categorized workflow catalog and bundled `legacy_finance` package.
|
|
49
|
+
- Mutable workspace bootstrap (`~/.clawdfolio/finance`).
|
|
50
|
+
- Wilder RSI smoothing, Longport symbol fix, yfinance hardening.
|
|
51
|
+
- Options quote/chain/buyback monitor.
|
clawdfolio-2.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 YICHENG YANG
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clawdfolio
|
|
3
|
+
Version: 2.2.0
|
|
4
|
+
Summary: Production-grade quantitative portfolio toolkit — multi-broker aggregation, institutional risk analytics, options lifecycle management, and 20+ automated finance workflows
|
|
5
|
+
Project-URL: Homepage, https://github.com/YichengYang-Ethan/clawdfolio
|
|
6
|
+
Project-URL: Documentation, https://github.com/YichengYang-Ethan/clawdfolio#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/YichengYang-Ethan/clawdfolio.git
|
|
8
|
+
Project-URL: Issues, https://github.com/YichengYang-Ethan/clawdfolio/issues
|
|
9
|
+
Author: YICHENG YANG
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: broker,claude-code-compatible,clawdbot,finance,futu,investment,longport,moomoo,options-greeks,options-trading,portfolio,portfolio-analytics,quantitative-finance,risk-management,sharpe-ratio,trading,var
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: numpy>=1.24.0
|
|
26
|
+
Requires-Dist: pandas>=2.0.0
|
|
27
|
+
Requires-Dist: pyyaml>=6.0
|
|
28
|
+
Requires-Dist: rich>=13.0.0
|
|
29
|
+
Requires-Dist: yfinance>=0.2.30
|
|
30
|
+
Provides-Extra: all
|
|
31
|
+
Requires-Dist: futu-api>=7.0.0; extra == 'all'
|
|
32
|
+
Requires-Dist: longport>=1.0.0; extra == 'all'
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
39
|
+
Requires-Dist: types-pyyaml>=6.0.0; extra == 'dev'
|
|
40
|
+
Provides-Extra: futu
|
|
41
|
+
Requires-Dist: futu-api>=7.0.0; extra == 'futu'
|
|
42
|
+
Provides-Extra: longport
|
|
43
|
+
Requires-Dist: longport>=1.0.0; extra == 'longport'
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
|
|
46
|
+
# Clawdfolio 🦙📊
|
|
47
|
+
|
|
48
|
+
[](https://github.com/YichengYang-Ethan/clawdfolio/actions/workflows/ci.yml)
|
|
49
|
+
[](https://pypi.org/project/clawdfolio/)
|
|
50
|
+
[](https://www.python.org/downloads/)
|
|
51
|
+
[](https://opensource.org/licenses/MIT)
|
|
52
|
+
[](https://github.com/anthropics/claude-code)
|
|
53
|
+
|
|
54
|
+
English | [中文](README_CN.md)
|
|
55
|
+
|
|
56
|
+
> **Production-grade quantitative portfolio toolkit** — multi-broker aggregation, institutional risk analytics, options lifecycle management, and 20+ automated finance workflows.
|
|
57
|
+
>
|
|
58
|
+
> *Also available as a native [Claude Code](https://github.com/anthropics/claude-code) / Clawdbot skill.*
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Why Clawdfolio?
|
|
63
|
+
|
|
64
|
+
| Traditional Tools | Clawdfolio |
|
|
65
|
+
|-------------------|------------|
|
|
66
|
+
| Manual data entry | Auto-sync from Longport, Moomoo/Futu |
|
|
67
|
+
| Basic P&L tracking | VaR, Sharpe, Beta, Max Drawdown, HHI |
|
|
68
|
+
| Single broker view | Multi-broker aggregation |
|
|
69
|
+
| Spreadsheet alerts | Smart RSI / price / P&L alerts |
|
|
70
|
+
| No extensibility | Python API + CLI + Claude Code skill |
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Features
|
|
75
|
+
|
|
76
|
+
- **Multi-Broker Support** — Longport (Longbridge), Moomoo/Futu, or demo mode
|
|
77
|
+
- **Risk Analytics** — Volatility, Beta, Sharpe Ratio, Value at Risk, Max Drawdown
|
|
78
|
+
- **Technical Analysis** — RSI, SMA, EMA, Bollinger Bands
|
|
79
|
+
- **Concentration Analysis** — HHI index, sector exposure, correlation warnings
|
|
80
|
+
- **Smart Alerts** — Price movements, RSI extremes, P&L thresholds
|
|
81
|
+
- **Earnings Calendar** — Track upcoming earnings for holdings
|
|
82
|
+
- **DCA Analysis** — Dollar-cost averaging signals
|
|
83
|
+
- **Options Toolkit** — Option quote/Greeks, option chain snapshot, buyback trigger monitor
|
|
84
|
+
- **Options Strategy Playbook (v2.1)** — Covered Call and Sell Put lifecycle management with delta/gamma/margin guardrails
|
|
85
|
+
- **Finance Workflow Suite** — 20 production workflows for reports, alerts, market intel, and broker snapshots
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Quick Start
|
|
90
|
+
|
|
91
|
+
### Installation
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pip install clawdfolio # Core
|
|
95
|
+
pip install clawdfolio[longport] # + Longport broker
|
|
96
|
+
pip install clawdfolio[futu] # + Moomoo/Futu broker
|
|
97
|
+
pip install clawdfolio[all] # All brokers
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### CLI Usage
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
clawdfolio summary # Portfolio overview
|
|
104
|
+
clawdfolio risk # Risk metrics (VaR, Sharpe, Beta, etc.)
|
|
105
|
+
clawdfolio quotes AAPL TSLA NVDA # Real-time quotes
|
|
106
|
+
clawdfolio alerts # Check alerts
|
|
107
|
+
clawdfolio earnings # Upcoming earnings calendar
|
|
108
|
+
clawdfolio dca AAPL # DCA analysis
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Options Commands
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
clawdfolio options expiries TQQQ
|
|
115
|
+
clawdfolio options quote TQQQ --expiry 2026-06-18 --strike 60 --type C
|
|
116
|
+
clawdfolio options chain TQQQ --expiry 2026-06-18 --side both --limit 10
|
|
117
|
+
clawdfolio options buyback # Trigger check from config
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Python API
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from clawdfolio.brokers import get_broker
|
|
124
|
+
from clawdfolio.analysis import analyze_risk
|
|
125
|
+
|
|
126
|
+
broker = get_broker("demo") # or "longport", "futu"
|
|
127
|
+
broker.connect()
|
|
128
|
+
|
|
129
|
+
portfolio = broker.get_portfolio()
|
|
130
|
+
metrics = analyze_risk(portfolio)
|
|
131
|
+
|
|
132
|
+
print(f"Net Assets: ${portfolio.net_assets:,.2f}")
|
|
133
|
+
print(f"Sharpe Ratio: {metrics.sharpe_ratio:.2f}")
|
|
134
|
+
print(f"VaR 95%: ${metrics.var_95:,.2f}")
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Risk Metrics
|
|
140
|
+
|
|
141
|
+
| Metric | Description |
|
|
142
|
+
|--------|-------------|
|
|
143
|
+
| **Volatility** | 20-day and 60-day annualized |
|
|
144
|
+
| **Beta** | Correlation with SPY/QQQ |
|
|
145
|
+
| **Sharpe Ratio** | Risk-adjusted returns |
|
|
146
|
+
| **VaR** | Value at Risk (95%/99%) |
|
|
147
|
+
| **Max Drawdown** | Largest peak-to-trough decline |
|
|
148
|
+
| **HHI** | Portfolio concentration index |
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Options Toolkit
|
|
153
|
+
|
|
154
|
+
The built-in options module provides real-time Greeks inspection, chain analysis, and stateful buyback monitoring:
|
|
155
|
+
|
|
156
|
+
| Command | Description |
|
|
157
|
+
|---------|-------------|
|
|
158
|
+
| `options expiries` | List available expiry dates for a symbol |
|
|
159
|
+
| `options quote` | Single option quote with Greeks (delta, gamma, theta, vega, IV) |
|
|
160
|
+
| `options chain` | Full option chain snapshot with filtering |
|
|
161
|
+
| `options buyback` | Stateful trigger monitor for short option buyback |
|
|
162
|
+
|
|
163
|
+
Strategy methodology is documented in the [Options Strategy Playbook](docs/OPTIONS_STRATEGY_PLAYBOOK_v2.1.md) — covering Covered Call and Sell Put lifecycle management with delta-based strike selection, roll/assignment rules, and margin guardrails.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Configuration
|
|
168
|
+
|
|
169
|
+
### Environment Variables
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Longport
|
|
173
|
+
export LONGPORT_APP_KEY=your_app_key
|
|
174
|
+
export LONGPORT_APP_SECRET=your_app_secret
|
|
175
|
+
export LONGPORT_ACCESS_TOKEN=your_access_token
|
|
176
|
+
|
|
177
|
+
# Moomoo: Run OpenD locally on port 11111
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Config File (optional)
|
|
181
|
+
|
|
182
|
+
Create `config.yaml`:
|
|
183
|
+
|
|
184
|
+
```yaml
|
|
185
|
+
brokers:
|
|
186
|
+
longport:
|
|
187
|
+
enabled: true
|
|
188
|
+
futu:
|
|
189
|
+
enabled: true
|
|
190
|
+
extra:
|
|
191
|
+
host: "127.0.0.1"
|
|
192
|
+
port: 11111
|
|
193
|
+
|
|
194
|
+
alerts:
|
|
195
|
+
pnl_trigger: 500.0
|
|
196
|
+
rsi_high: 80
|
|
197
|
+
rsi_low: 20
|
|
198
|
+
|
|
199
|
+
option_buyback:
|
|
200
|
+
enabled: true
|
|
201
|
+
symbol: "TQQQ"
|
|
202
|
+
targets:
|
|
203
|
+
- name: "cc-june"
|
|
204
|
+
strike: 60
|
|
205
|
+
expiry: "2026-06-18"
|
|
206
|
+
type: "C"
|
|
207
|
+
trigger_price: 1.60
|
|
208
|
+
qty: 2
|
|
209
|
+
reset_pct: 0.20
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Supported Brokers
|
|
213
|
+
|
|
214
|
+
| Broker | Region | Status |
|
|
215
|
+
|--------|--------|--------|
|
|
216
|
+
| Demo | Global | Built-in |
|
|
217
|
+
| Longport | US/HK/SG | Optional |
|
|
218
|
+
| Moomoo/Futu | US/HK/SG | Optional |
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Claude Code & Clawdbot Integration
|
|
223
|
+
|
|
224
|
+
Clawdfolio works as a native skill in [Claude Code](https://github.com/anthropics/claude-code) and Clawdbot environments:
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
/clawdfolio summary
|
|
228
|
+
/clawdfolio risk
|
|
229
|
+
/clawdfolio quotes AAPL MSFT NVDA
|
|
230
|
+
/clawdfolio alerts
|
|
231
|
+
/clawdfolio options chain TQQQ --expiry 2026-06-18
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The skill is registered via [`SKILL.md`](SKILL.md) and supports all CLI commands through natural language interaction.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Finance Workflows
|
|
239
|
+
|
|
240
|
+
20 production workflows migrated from live trading infrastructure, organized by category:
|
|
241
|
+
|
|
242
|
+
| Category | Examples |
|
|
243
|
+
|----------|---------|
|
|
244
|
+
| **Portfolio Reports** | Account report, portfolio analysis, risk breakdown |
|
|
245
|
+
| **Briefing Cards** | Daily brief (console + Telegram), multi-format |
|
|
246
|
+
| **Alerts & Monitors** | Price/RSI alerts, option buyback trigger |
|
|
247
|
+
| **Market Intelligence** | Real-time quotes, earnings calendar, market news |
|
|
248
|
+
| **Broker Snapshots** | Longport / Moomoo asset summaries |
|
|
249
|
+
| **Strategy** | DCA proposals |
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
clawdfolio finance list # Browse all workflows by category
|
|
253
|
+
clawdfolio finance init # Bootstrap ~/.clawdfolio/finance workspace
|
|
254
|
+
clawdfolio finance run <workflow_id> # Execute a workflow
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Ecosystem
|
|
260
|
+
|
|
261
|
+
Clawdfolio is the data hub of a quantitative finance toolkit. Other projects consume its output or share its analytical methodology.
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
┌──────────────────────────┐
|
|
265
|
+
│ ML Research Layer │
|
|
266
|
+
│ crypto-prediction │
|
|
267
|
+
│ ESG-prediction │
|
|
268
|
+
└────────────┬─────────────┘
|
|
269
|
+
│ research informs alert thresholds
|
|
270
|
+
┌────────────▼─────────────┐
|
|
271
|
+
│ clawdfolio (this repo) │
|
|
272
|
+
│ brokers · risk · alerts │
|
|
273
|
+
│ clawdfolio summary -o json
|
|
274
|
+
└────────────┬─────────────┘
|
|
275
|
+
│ JSON data feed
|
|
276
|
+
┌────────────▼─────────────┐
|
|
277
|
+
│ Visualization Layer │
|
|
278
|
+
│ investment-dashboard │
|
|
279
|
+
│ QQQ-200D-Dashboard │
|
|
280
|
+
└──────────────────────────┘
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
| Project | Layer | Relationship |
|
|
284
|
+
|---------|-------|-------------|
|
|
285
|
+
| **clawdfolio** (this repo) | Core Engine | Risk analytics, broker integration, signal generation, options strategy |
|
|
286
|
+
| [investment-dashboard](https://github.com/YichengYang-Ethan/investment-dashboard) | Visualization | Web frontend — consumes `clawdfolio summary -o json` for portfolio data |
|
|
287
|
+
| [QQQ-200D-Deviation-Dashboard](https://github.com/YichengYang-Ethan/QQQ-200D-Deviation-Dashboard) | Visualization | Implements clawdfolio's SMA deviation methodology as a standalone React dashboard |
|
|
288
|
+
| [crypto-return-prediction](https://github.com/YichengYang-Ethan/crypto-return-prediction-kaggle) | ML Research | Short-term momentum prediction — shares RSI/Bollinger feature engineering |
|
|
289
|
+
| [ESG-Driven-Stock-Value-Prediction](https://github.com/YichengYang-Ethan/ESG-Driven-Stock-Value-Prediction) | ML Research | Long-term value factor research — ESG signals complementing technical indicators |
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
<details>
|
|
294
|
+
<summary><strong>Changelog</strong></summary>
|
|
295
|
+
|
|
296
|
+
### v2.2.0 (2025-02-14)
|
|
297
|
+
|
|
298
|
+
- Thread-safe market data caching (`threading.Lock`)
|
|
299
|
+
- Batch quote fetching via `yf.download` with per-ticker fallback
|
|
300
|
+
- Shared `suppress_stdio` utility (DRY refactor)
|
|
301
|
+
- Dynamic CLI version from `__version__`
|
|
302
|
+
- PEP 561 compliance (`py.typed` marker)
|
|
303
|
+
- Structured logging across core modules
|
|
304
|
+
- Centralized ticker normalization (`_yf_symbol()`)
|
|
305
|
+
- Config path migration to `clawdfolio` namespace (backward-compatible)
|
|
306
|
+
|
|
307
|
+
### v2.1.0 (2025-01-28)
|
|
308
|
+
|
|
309
|
+
- Options Strategy Playbook v2.1 (`docs/OPTIONS_STRATEGY_PLAYBOOK_v2.1.md`)
|
|
310
|
+
- Research-to-execution framework for CC and Sell Put lifecycle
|
|
311
|
+
- Explicit gamma-risk, margin, leverage, and assignment decision rules
|
|
312
|
+
|
|
313
|
+
### v2.0.0 (2025-01-15)
|
|
314
|
+
|
|
315
|
+
- Full finance migration: 20 production workflows from live trading infrastructure
|
|
316
|
+
- `clawdfolio finance` command group (list, init, run)
|
|
317
|
+
- Mutable workspace bootstrap (`~/.clawdfolio/finance`)
|
|
318
|
+
- Options quote/chain/buyback monitor
|
|
319
|
+
- Wilder RSI smoothing, Longport symbol fix, yfinance hardening
|
|
320
|
+
|
|
321
|
+
See [CHANGELOG.md](CHANGELOG.md) for full details.
|
|
322
|
+
|
|
323
|
+
</details>
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Contributing
|
|
328
|
+
|
|
329
|
+
Contributions welcome! Please submit a Pull Request.
|
|
330
|
+
|
|
331
|
+
## License
|
|
332
|
+
|
|
333
|
+
MIT License — see [LICENSE](LICENSE)
|
|
334
|
+
|
|
335
|
+
## Links
|
|
336
|
+
|
|
337
|
+
- [GitHub Repository](https://github.com/YichengYang-Ethan/clawdfolio)
|
|
338
|
+
- [Report Issues](https://github.com/YichengYang-Ethan/clawdfolio/issues)
|
|
339
|
+
- [Options Strategy Playbook](docs/OPTIONS_STRATEGY_PLAYBOOK_v2.1.md)
|
|
340
|
+
- [Claude Code](https://github.com/anthropics/claude-code)
|