Skip to main content

SQLite, Risk & Money management, discipline trader with risk rules & reports

Project description

๐Ÿง  Trade Manager

A production-grade Intraday Auto Trading Manager with full trade persistence, rule-based risk management, and daily performance tracking.


๐Ÿ“˜ Overview

TradeManager.py is a Python-based automated trade manager that combines professional risk control, performance logging, and capital discipline.
Designed for intraday traders, investors, and quantitative analysts, it helps manage trades with strict loss/profit limits, ensuring capital protection and consistency.


โš™๏ธ Core Features

๐Ÿ’ผ Portfolio & Risk Management

  • Capital Tracking โ€“ Auto carry-forward of daily closing balance.
  • Position Sizing โ€“ Based on risk % of total capital.
  • Max Daily Drawdown / Profit Cap โ€“ Automatically halts trading when daily limits are reached.
  • Capital Update Menu โ€“ Modify default capital interactively and persist across sessions.

๐Ÿ“Š Trade Rules

  • Limit simultaneous open trades: max_open_trades
  • Restrict total daily loss and profit trades:
    • max_loss_trades
    • max_target_trades
  • Auto-block further entries after hitting limits.
  • Hardcoded Startup Trades โ€“ Useful for testing and demo environments.

๐Ÿงพ Database Persistence (SQLite)

All trade and performance data are stored locally in trade_manager.db:

  • open_trades โ€“ Current running trades
  • trade_log โ€“ Historical closed trade performance
  • daily_stats โ€“ Day-wise P&L and metrics

๐Ÿ“ˆ Reports

Generate and review analytics directly in the terminal:

  • Intraday Stock-wise Report (Today or custom date)
  • Weekly Summary (Last 4 weeks)
  • Monthly Performance Summary

๐Ÿง  Intelligent Auto-Stop Logic

Automatically pauses the system if:

  • Daily drawdown limit exceeded
  • Profit target achieved
  • Too many loss trades occurred

๐Ÿงฉ Configuration Parameters

Parameter Type Description Default
db_file str SQLite database filename trade_manager.db
default_capital float Starting capital 10000.0
default_risk_pct float Risk % per trade 1.0
max_drawdown_pct float Daily drawdown stop 3.0
max_profit_pct float Daily profit stop 5.0
max_open_trades int Concurrent open positions 3
max_loss_trades int Max allowed loss trades per day 1
max_target_trades int Max allowed target hits per day 2
HARD_CODED_MODE_ON_START bool Enable/disable startup trades False

Example Workflow

  1. Start the manager โ†’ initializes database
  2. Add new trade with stop loss and target
  3. Manager auto-adjusts available capital
  4. Logs results upon close
  5. Displays P&L and risk compliance report

๐Ÿ“‚ Database Schema

open_trades

Field Type Description
id INTEGER Auto ID
symbol TEXT Stock/Instrument
entry_price REAL Entry level
stop_loss REAL SL value
target REAL Target price
qty INTEGER Quantity
status TEXT Active/Closed

trade_log

Field Type Description
id INTEGER Auto ID
symbol TEXT Stock
pnl REAL Profit/Loss
exit_reason TEXT Target/SL/Manual
date TEXT Trade date

daily_stats

Field Type Description
date TEXT Trading date
capital REAL End-of-day capital
daily_gain REAL Day P&L
drawdown REAL Daily drawdown %

๐Ÿงฐ Key Modules Used

  • sqlite3 โ€“ Data persistence
  • pandas โ€“ Data manipulation and reporting
  • rich โ€“ Colored and formatted terminal output
  • datetime โ€“ Trade and report timestamps

๐Ÿง‘โ€๐Ÿ’ผ Example Output (Terminal View)

๐Ÿ“‹ ORDER REVIEW
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
๐Ÿ’ฐ Available Capital: โ‚น10000.00
๐Ÿ’ธ Risk per Trade: โ‚น100.00 (1%)
๐Ÿ“ˆ Symbol: RELIANCE
๐ŸŽฏ Target: โ‚น2800.00
๐Ÿ›‘ Stop Loss: โ‚น2700.00
โœ”๏ธ Quantity: 10
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
โœ… Trade Added Successfully!

๐Ÿง  Future Enhancements

  • ๐Ÿ”ฎ ML-based profit probability prediction
  • ๐Ÿ“ก Live market data integration
  • ๐Ÿ’ฌ Telegram / Discord alerts
  • ๐Ÿงพ CSV export of reports
  • ๐Ÿ•น๏ธ GUI dashboard (Tkinter / Streamlit)

โš ๏ธ Disclaimer

This tool is built for educational and analytical use.
It does not execute real trades.
Always verify decisions manually before executing orders in live markets.


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

trademanager-0.0.2.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

trademanager-0.0.2-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file trademanager-0.0.2.tar.gz.

File metadata

  • Download URL: trademanager-0.0.2.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for trademanager-0.0.2.tar.gz
Algorithm Hash digest
SHA256 dfd808a254aa994672d4dba21dfa45c1e7531c1ca35e0a290e90a310aa162115
MD5 401fa5cb8499812f7a0ff14b2af5774c
BLAKE2b-256 9adb174cdb7b8a1427480dd0531d5f908aff072dbbd73b44b9e7e870467ceb45

See more details on using hashes here.

File details

Details for the file trademanager-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: trademanager-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for trademanager-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bfe7551d02514a8d5b3409e1e0b4c899027443436e5ba0a5ee80c6e3282a26c3
MD5 3456da62650909318c050379a1ae5ef2
BLAKE2b-256 4ced54217c35604c929f021898dcb1f546d58816c4759ab00a7a8cc9e45fac7f

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