Skip to main content

A algorithm crypto trading system.

Project description

smtm

Travis license language codecov

It's a game to get money.

An algorithm-based cryptocurrency automatic trading system made in Python. https://smtm.msalt.net

한국어 👈

icon_wide_gold

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.

  1. Get data from Data Provider
  2. Make a decision using Strategy
  3. Execute a trading via Trader
    --- repeat ---
  4. Create analyzing result by Analyzer

intro

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.

smtm_bot

telegram_chatbot

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

Component Diagram

Class Diagram

Class Diagram

Sequence 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

smtm-book

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smtm-1.1.0.tar.gz (229.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smtm-1.1.0-py3-none-any.whl (187.9 kB view details)

Uploaded Python 3

File details

Details for the file smtm-1.1.0.tar.gz.

File metadata

  • Download URL: smtm-1.1.0.tar.gz
  • Upload date:
  • Size: 229.9 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.2 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

Hashes for smtm-1.1.0.tar.gz
Algorithm Hash digest
SHA256 09500d7319037739320ff570e4f6c4a3e214a8480d1f01337b7f840de9a79e84
MD5 9c1ddd8eb7565d3f1a4ef15f3e49c9af
BLAKE2b-256 541ae73e3c429dbfd87a5061bf1c8a59afb35af2699fc79859aa75aab32181f0

See more details on using hashes here.

File details

Details for the file smtm-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: smtm-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 187.9 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.2 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

Hashes for smtm-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97b32bf2c7b9f6ec4cdcef4ae7299b21f41979695d418eef0f5eaa81ba004f5a
MD5 6a3ac9c006d1259d09d1f0ce32e2112b
BLAKE2b-256 040c2b487e22c229a2183d768ae31929a2336f56e2b2717f93ece2fa01db4d3c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page