A algorithm crypto trading system.
Project description
smtm
It's a game to get money.
An algorithm-based cryptocurrency automatic trading system made in Python. https://smtm.msalt.net
한국어 👈
It has a very simple routine and repeat periodically. Performance critical approach is NOT suitable. e.g. multiple tradings in seconds. If you want, find another solution.
- Get data from Data Provider
- Make a decision using Strategy
- Execute a trading via Trader
--- repeat --- - Create analyzing result by Analyzer
Features
- Simulation
- Mass-Simulation with Multi-process
- CLI mode Auto Trading
- Remote Control with Jupyter Notebook
- Telegram Message App Trading Control
Telegram Chat-bot Mode
User can launch the program with Telegram chat-bot mode which provide user interface via Telegram chat-bot.
Simulation Mode
User can execute simulation with Simulator or MassSimulator, which run simulations using past trading records.
How to install
Install all packages using requirements.txt
pip install -r requirements.txt
For development, all development depedencies included.
pip install -r requirements-dev.txt
How to run
There are 6 mode for each features.
- 0: simulator with interative mode
- 1: execute single simulation
- 2: controller for real trading
- 3: telegram chatbot controller
- 4: mass simulation with config file
- 5: make config file for mass simulation
Interactive mode simulator
run with only mode
python -m smtm --mode 0
Execute single simulation
run with mode and simulation setting parameters
python -m smtm --mode 1 --budget 50000 --from_dash_to 201220.170000-201221 --term 0.1 --strategy 0 --currency BTC
Run controller for trading
run with mode and initial setting parameters
python -m smtm --mode 2 --budget 50000 --term 60 --strategy 0 --currency ETH
for real trading API key and host url is included in .env file.
UPBIT_OPEN_API_ACCESS_KEY=Your API KEY
UPBIT_OPEN_API_SECRET_KEY=Your API KEY
UPBIT_OPEN_API_SERVER_URL=https://api.upbit.com
Run telegram chatbot controller for trading
run with only mode
python -m smtm --mode 3
chat-bot api token and chat room id is needed in .env.
TELEGRAM_BOT_TOKEN=bot123456789:YOUR bot Token
TELEGRAM_CHAT_ID=123456789
Execute mass simulation with config file
run with mode and config file info
python -m smtm --mode 4 --config /data/sma0_simulation.json
Make config file for mass simulation
run with mode and simulation setting parameters
python -m smtm --mode 5 --budget 50000 --title SMA_6H_week --strategy 1 --currency ETH --from_dash_to 210804.000000-210811.000000 --offset 360 --file generated_config.json
Architecture
Layered architecture
| Layer | Module | Role |
|---|---|---|
| Controller Layer | Simulator, Controller, TelegramController | User Interface |
| Operator Layer | Operator, SimulationOperator | Operating Manager |
| Core Layer | Analyzer, Trader, Strategy, Data Provider | Core Feature |
Component Diagram
Class Diagram
Sequence Diagram
How to test
Unit test
Test project with unittest.
# run unittest directly
python -m unittest discover ./tests *test.py -v
Integration test
Test with real trading market. Some integration tests are excuted via Jupyter notebook. It's good to run test flexible re-ordered.
You can find notebook files in notebook directory.
# run unittest directly
python -m unittest integration_tests
# or
python -m unittest integration_tests.simulation_ITG_test
Tip
clear jupyter notebook output before make commit
jupyter nbconvert --clear-output --inplace {file.ipynb}
#jupyter nbconvert --clear-output --inplace .\notebook\*.ipynb
If you run simulation or demo mode, you should set timezone to 'Asia/Seoul' because smtm use Upbit trading information for simulation and demo. For Linux, below command is available.
timedatectl set-timezone 'Asia/Seoul'
For keeping smtm program process after terminating ssh connection, using nohup is recommended as below. Standard, error ouput is redirected to specific files.
nohup python -m smtm --mode 3 --demo 1 > nohup.out 2> nohup.err < /dev/null &
Related Book
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smtm-1.2.0.tar.gz.
File metadata
- Download URL: smtm-1.2.0.tar.gz
- Upload date:
- Size: 233.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.25.0 requests-toolbelt/0.10.1 urllib3/1.26.15 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbadc20e9db07d0929f3767b8c8aaaad227a1ca1e02e832645fc90c8aaf7bb87
|
|
| MD5 |
0d2a7afea346deca1c4efd0ae48ab3be
|
|
| BLAKE2b-256 |
56c11992e61035bb5bfda948b78624bb104a46d7478dbb6d059716106e5d32ca
|
File details
Details for the file smtm-1.2.0-py3-none-any.whl.
File metadata
- Download URL: smtm-1.2.0-py3-none-any.whl
- Upload date:
- Size: 80.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.25.0 requests-toolbelt/0.10.1 urllib3/1.26.15 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93090d4751be5c3e81c73ff13e1fe0c9cec14cfd6a2ad945d8b666192676f888
|
|
| MD5 |
39bcbf382d7719623d5d8b9797a119cb
|
|
| BLAKE2b-256 |
9c18ae4f76debe9c3141caef3bf7d908f40d95db04cd6c049e797440ed372ea4
|