Skip to main content

Trading scanner application

Idea : To create a application where we can have certain screeners for stock market to be used for self.

Using : Streamlit + Fast api + n8n

  • n8n as the orchestrator to periodically fetch/update data or trigger on-demand.
  • FastAPI as the backend service to process data and serve it.
  • Streamlit as the frontend to visualize and interact with the data.

Setup

Structure

|-- backend/
| |-- main.py
| |-- Dockerfile
|-- frontend/
| |-- app.py
| |-- Dockerfile
|-- docker-compose.yml

Backend

Dockerfile

# Use the official FastAPI Uvicorn image
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8

# Set the working directory
WORKDIR /app

# Copy only the necessary files
# This step previously tried to copy the entire backend directory, which caused the error
COPY main.py /app/

# Install required libraries (extend this list as necessary)
RUN pip install fastapi uvicorn

# Command to run
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

main.py

from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}

Frontend

import streamlit as st
st.title('Streamlit App')
st.write("Hello, Streamlit!")

Dockerfile

FROM python:3.8
WORKDIR /app
COPY app.py /app/
RUN pip install streamlit
CMD ["streamlit", "run", "app.py"]

Docker-compose.yml

version: '3'
services:
backend:
build:
context: ./backend
dockerfile: Dockerfile
ports:
- "8000:8000"

frontend:
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "8501:8501"
n8n:
image: n8nio/n8n
ports:
- "5678:5678"
environment:
- N8N_BASIC_AUTH_ACTIVE=true

- N8N_BASIC_AUTH_USER=user

- N8N_BASIC_AUTH_PASSWORD=password

Scanners to build

Stocks

  1. All time high stocks with Rvol > 3
  2. Stocks 15% below 15 SMA, 20% below 20 SMA

FnO Index

  1. BankNifty, Nifty, Finnifty maxpain with option chain

FnO Stocks

  1. Heatmap sector wise

RRG Graph -- Relative rotation graph