Skip to content

Quick API Script Ideas

This document lists proposed Quick Scripts for the fyers-store project. These scripts provide focused, beginner-friendly demonstrations of specific functionality without complex infrastructure.

Implementation Rules

  • One Task: Each script must focus on one single objective.
  • No Boilerplate: Avoid CLI/argparse, manual auth plumbing, or complex environment setup.
  • Copy-Paste Ready: Designed for immediate use by beginners.
  • Readable: Must be understandable in under 2 minutes.

Block 1: Connectivity & Preflight

  • [x] quick_auth_check.py – Validate credentials and session status.
  • [x] quick_token_expiry_check.py – Check hours remaining before session expiry.
  • [x] quick_check_configs.py – Demonstrate internal resolver validating YAML paths.
  • [x] quick_store_health.py – Run a full diagnostic check on REST/WS/Cache components.
  • [x] quick_rest_health.py – Verify connectivity to the FYERS REST API.
  • [x] quick_ws_health.py – Verify WebSocket connectivity and heartbeat.
  • [x] quick_latency_check.py – Measure round-trip time for API requests.

Block 2: Market Snapshot & Discovery

  • [x] quick_ltp_fetch.py – Fetch the latest traded price for a symbol.
  • [x] quick_symbol_check.py – Validate if a symbol exists and is tradable.
  • [x] quick_symbol_search.py – Search for symbols by keyword (e.g., "RELIANCE").
  • [x] quick_multi_symbol_ltp.py – Fetch real-time prices for a list of symbols.
  • [x] quick_market_depth.py – Fetch top 5 bid/ask levels (Level 2 data).
  • [x] quick_intraday_snapshot.py – Get current day OHLC + Volume for a symbol.
  • [x] quick_top_gainers_losers.py – Identify the biggest movers in the market.
  • [x] quick_trading_hours_check.py – Check NSE/BSE market open/close status via MarketCalendar.

Symbol master helpers download the configured CSV (NSE_CM by default) and inspect the headers listed in config/symbol_master_sources.yaml, so these scripts require network access and may need header updates if FYERS changes the CSV layout.

Block 3: Historical Data & Persistence

  • [x] quick_history_fetch.py – Fetch a small historical dataset (e.g., last 100 1-min bars).
  • [x] quick_multi_symbol_history.py – Concurrent history fetch for multiple symbols.
  • [x] quick_cache_warmup.py – Pre-fill the SQLite cache for a list of symbols.
  • [x] quick_cache_stats.py – View SQLite storage stats and gap-fill coverage.
  • [x] quick_cache_inspector.py – Inspect specific date ranges in the local DB.
  • [x] quick_cache_clear.py – Safely wipe the historical cache for a clean start.

Block 4: Complex Trading Strategies (Backtrader)

  • [x] quick_orb_strategy.py – Opening Range Breakout (ORB) strategy implementation.
  • [x] quick_macd_strategy.py – MACD crossover with signal filtering and volume confirmation.
  • [x] quick_sma_backtest.py – Classic Dual SMA Crossover backtest.
  • [x] quick_rsi_backtest.py – Overbought/Oversold RSI strategy.
  • [x] quick_multi_tf_backtest.py – Running a strategy on dual timeframes (e.g., 5m entry on 1h trend).
  • [x] quick_macd_backtest.py – Standard MACD indicator backtest.
  • [x] quick_portfolio_backtest.py – Backtest a basket of symbols concurrently.
  • [x] quick_strategy_comparison.py – Compare performance of two indicator-based strategies.
  • [x] quick_backtest_summary.py – Generate a detailed Sharpe/Drawdown report for a strategy.
  • [x] quick_walk_forward_test.py – Demonstrate basic Train/Test split evaluation.

Block 5: Order Lifecycle & Execution

  • [x] quick_place_order.py – Place a single market/limit order.
  • [x] quick_modify_order.py – Adjust price/quantity of a pending order.
  • [x] quick_cancel_order.py – Cancel a specific open order.
  • [x] quick_cancel_all_orders.py – Bulk cancel all open orders for the account.
  • [x] quick_order_status.py – Trace the lifecycle of an order from Submit to Fill.
  • [x] quick_square_off.py – Intelligent "Panic Button" to exit all open positions.
  • [x] quick_trade_lifecycle.py – End-to-end demo: Order → Fill → Position Update.

Block 6: Account & Risk Awareness

  • [x] quick_account_balance.py – View real-time available funds and utilized margin.
  • [x] quick_margin_usage.py – Detailed breakdown of margin utilization across segments.
  • [x] quick_positions_check.py – View current open positions with unrealized P&L.
  • [x] quick_holdings_check.py – View long-term portfolio holdings.
  • [x] quick_daily_pnl.py – Calculate total realized vs unrealized P&L for the day.
  • [x] quick_trade_history.py – View a summary of all trades executed today.
  • [x] quick_exposure_summary.py – View market exposure broken down by sector/symbol.
  • [x] quick_drawdown_check.py – Check current account drawdown against limits.
  • [x] quick_risk_limits.py – View account-level risk constraints.

Block 7: Portfolio Management

  • [x] quick_multi_symbol_portfolio.py – Manage a basket of symbols with automatic sizing.
  • [x] quick_equal_weight_portfolio.py – Backtest an equal-weight allocation strategy.
  • [x] quick_risk_parity.py – Allocation based on symbol volatility.
  • [x] quick_sector_allocation.py – Allocate capital across different market sectors.
  • [x] quick_portfolio_snapshot.py – Detailed breakdown of portfolio composition.
  • [x] quick_rebalance_strategy.py – Portfolio rebalancing logic based on drift.

Block 8: Safety Guards & Environment

  • [x] quick_env_check.py – Identify current environment (LIVE vs PAPER vs SIM).
  • [x] quick_trading_guard_demo.py – Demonstrate automated guards blocking orders in restricted states.
  • [x] quick_readonly_mode.py – Force data-only access to prevent accidental trades.
  • [x] quick_trading_toggle.py – Programmatically enable/disable strategy execution.
  • [x] quick_emergency_stop.py – Stop all trading and disconnect adapters immediately.
  • [x] quick_failover_test.py – Simulate a networking failure and observe auto-reconnect.

Block 9: Strategy Utilities

  • [x] quick_signal_only.py – View signals in console without placing real orders.
  • [x] quick_position_sizing.py – Demonstrate fixed-fractional vs fixed-rupee sizing.
  • [x] quick_stop_loss_demo.py – Basic Hard Stop-Loss implementation.
  • [x] quick_trailing_stop.py – Dynamic Trailing Stop-Loss example.
  • [x] quick_take_profit.py – Take-Profit (bracket order style) logic.
  • [x] quick_multi_strategy.py – Run multiple independent strategies on the same symbol.

Block 10: Connectivity & Operations

  • [x] quick_ws_config_check.py – Validate WebSocket throttling and batching settings.
  • [x] quick_reconnect_ws.py – Manually trigger and verify a WS reconnection.
  • [x] quick_config_check.py – Validate all YAML config files for schema errors.
  • [x] quick_credentials_check.py – Verify API Keys and Secret keys.
  • [x] quick_restart_services.py – Demonstrate graceful restart of all adapters.
  • [x] quick_log_check.py – Verify logging output levels and file rotation.

Block 11: Educational / Learning

  • [x] quick_strategy_template.py – A minimal, clean template for starting a new strategy.
  • [x] quick_indicator_demo.py – Visualize common indicators (SMA, EMA, BBS).
  • [x] quick_backtrader_basics.py – Core integration concepts for Backtrader.
  • [x] quick_signal_visualization.py – Plot signals and trades on a chart.

Block 12: Paper & Simulation

  • [x] quick_paper_trading.py – Run a full strategy session in PAPER mode.
  • [x] quick_paper_positions.py – View simulated positions distinct from live ones.
  • [x] quick_paper_orders.py – Check status of simulated paper orders.
  • [x] quick_paper_pnl.py – Monitor profitability of a paper trading session.
  • [x] quick_paper_restart.py – Reset the simulation state for a clean run.
  • [x] quick_backtest_speed_test.py – Benchmark execution speed (bars per second).