This project is a service for algorithmic trading of Taiwan stocks. It leverages the Fugle Python API library and FastAPI to provide a robust and efficient trading services.
- One stop API aggregation: integrate trading API and market API in one domain
- Integrate advance trading methods: iceberg order, stop loss/trailing profit order, swing trading
- Virtual Wallet: preventing users from defaulting on delivery obligations at T + 2
- Scalability: designed to scale with your trading needs.
- Python 3.10
- Fugle's Trading credentials/Marketdata API Key
mv filename.p12 cert.p12
- FastAPI
- Uvicorn
Run in docker:
docker build -t fugle-fastapi:latest .
This is the way fugle manage the credentials, only need to run once to get the cryptfile_pass.cfg
docker run -it --rm \
-v $(pwd)/credentials:/root/.local/share/python_keyring \
-v $(pwd)/config.ini:/app/config.ini:ro \
-v $(pwd)/cert.p12:/app/cert.p12 \
-v $(pwd)/.env:/app/.env:ro \
fugle-fastapi:latest python index.py
docker run -p 8000:8000 --rm -d \
-v $(pwd)/credentials/cryptfile_pass.cfg:/root/.local/share/python_keyring/cryptfile_pass.cfg:ro \
-v $(pwd)/config.ini:/app/config.ini:ro \
-v $(pwd)/cert.p12:/app/cert.p12 \
-v $(pwd)/.env:/app/.env:ro \
fugle-fastapi:latest
You can see the API progress in Swagger Docs
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
You can always use flake8 to make sure the coding quality
pip install flake8 autopep8 black mypy
pip install flake8 autopep8 black
flake8 app
Tools for auto reformatting:
autopep8 --select=W293 --in-place app/models/fugle.py
black app
pip install mypy
mypy --ignore-missing-imports --check-untyped-defs app
pip install pytest httpx pytest-asyncio pytest-cov
pytest --cov=app --cov-report=html
Run the server first and request the openapi.json
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
openapi-generator-cli generate -c ./openapi_generator_config.json