Skip to content

hanchiang/market-data-notification

Repository files navigation

Test Deploy Deploy cron stocks Deploy cron crypto Deploy common

Introduction

This repository sends stocks and crypto market data to channels like telegram

Features

Tech stack

  • Language: Python
  • Framework: FastAPI
  • Database: Redis

Structure

  • src
    • server: API server
    • service: For retrieving data from various sources
    • job: Scheduled jobs that sends stocks and crypto notification

Example message for stocks

EMA20 overextension, highest volume

stocks ema overextension highest volume

VIX futures single day and consecutive days decrease

stocks ema overextension highest volume

Fear greed index

stocks fear greed index

Example message for crypto

Exchange supply

crypto exchange supply

Fees

crypto fees

Top sectors

Top sectors

Trending coins

Trending coins

Top gainers

Top gainers

Fear greed index

crypto fear greed index

Data sources

Crypto

  • CoinMarketCap
  • Alternative.me
  • Chainanalysis

Stocks

  • TradingView
  • VIX central
  • CNN fear greed

Stocks cron workflow

  • Receive market data when market closes -> save in redis
  • Scheduled job before market open -> Send notification to telegram

Crypto cron workflow

  • Scheduled job send notification to telegram

Common cron workflow

  • Send redis data via email

Workflow

How to do local development

Note

market_data_library is currently not a public python package.

1. No docker

  • Install python: https://www.python.org/downloads/
  • Install poetry: https://python-poetry.org/docs/
  • Install dependencies: poetry install
  • Run server: poetry run python3 main.py
  • Run stocks job: poetry run python src/job/stocks/stocks.py --force_run=1 --test_mode=1
  • Run crypto job: poetry run python src/job/crypto/crypto.py --force_run=1 --test_mode=1

2. With docker

  • Install docker: https://docs.docker.com/engine/install/
  • Run server: docker-compose up -d
  • Run stocks job: docker exec -it market_data_notification sh -c "ENV=dev poetry run python src/job/stocks/stocks.py --force_run=1 --test_mode=1"
  • Run crypto job: docker exec -it market_data_notification sh -c "ENV=dev poetry run python src/job/crypto/crypto.py --force_run=1 --test_mode=1"

Run tests

  • Run test: coverage run --branch -m pytest
  • Coverage report: coverage report --show-missing

Test TradingView webhook

Webhooks have to be a HTTPS URL, so localhost does not work.

  • Use a reverse proxy like ngrok
  • Set is_testing_telegram to 'true', which will save data to a dev key in redis and send notification to a dev telegram channel

Contributing

See CONTRIBUTING

TODO

  • API to send message to telegram, backup data
  • Code coverage in github action
  • Bot with pre-defined menu for user interaction
  • log
  • Cache barchart stock price