chore: scaffold python desktop app
This commit is contained in:
18
README.md
Normal file
18
README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Grid Trading
|
||||
|
||||
本项目是一个本地运行的 Python GUI 网格交易管理工具,第一阶段聚焦 A股/ETF 的账户、标的、手工成交、持仓成本、网格收益和回本价计算。
|
||||
|
||||
## 开发环境
|
||||
|
||||
```powershell
|
||||
python -m venv .venv
|
||||
.\.venv\Scripts\Activate.ps1
|
||||
python -m pip install -e ".[dev]"
|
||||
pytest
|
||||
```
|
||||
|
||||
## 启动
|
||||
|
||||
```powershell
|
||||
python -m grid_trading.app
|
||||
```
|
||||
27
pyproject.toml
Normal file
27
pyproject.toml
Normal file
@@ -0,0 +1,27 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=68"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "grid-trading"
|
||||
version = "0.1.0"
|
||||
description = "Local A-share and ETF grid trading management GUI"
|
||||
requires-python = ">=3.11"
|
||||
dependencies = [
|
||||
"PySide6>=6.7",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"pytest>=8",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
grid-trading = "grid_trading.app:main"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["src"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
pythonpath = ["src"]
|
||||
testpaths = ["tests"]
|
||||
1
src/grid_trading/__init__.py
Normal file
1
src/grid_trading/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
__version__ = "0.1.0"
|
||||
29
src/grid_trading/app.py
Normal file
29
src/grid_trading/app.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="grid-trading",
|
||||
description="Local A-share and ETF grid trading manager.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--db",
|
||||
help="Path to the SQLite database. Defaults to data/grid_trading.db.",
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
parser = build_parser()
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
from grid_trading.ui.main_window import run_gui
|
||||
|
||||
return run_gui(db_path=args.db)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main(sys.argv[1:]))
|
||||
20
src/grid_trading/config.py
Normal file
20
src/grid_trading/config.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
||||
DEFAULT_DB_PATH = PROJECT_ROOT / "data" / "grid_trading.db"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class DefaultFeeConfig:
|
||||
commission_rate: Decimal = Decimal("0.00025")
|
||||
min_commission: Decimal = Decimal("5")
|
||||
stamp_tax_rate: Decimal = Decimal("0.0005")
|
||||
transfer_fee_rate: Decimal = Decimal("0.00001")
|
||||
|
||||
|
||||
DEFAULT_FEE_CONFIG = DefaultFeeConfig()
|
||||
6
tests/test_imports.py
Normal file
6
tests/test_imports.py
Normal file
@@ -0,0 +1,6 @@
|
||||
def test_package_imports():
|
||||
import grid_trading
|
||||
from grid_trading.config import DEFAULT_DB_PATH
|
||||
|
||||
assert grid_trading.__version__
|
||||
assert DEFAULT_DB_PATH.name == "grid_trading.db"
|
||||
Reference in New Issue
Block a user