
What You Will Be Able to Do
In this guide titled Build a Basic AI Trading Bot in Python — Beginner Guide, you will walk away capable of assembling a fully functional, no‑cost AI‑driven trading system that can scan Indian, US, UK and Brazilian equities, generate entry signals, and enforce disciplined risk rules. By the end, you’ll know which free stock screeners to pair with open‑source machine‑learning libraries, how to back‑test without buying a pricey data feed, and how to keep your capital safe using free risk‑management dashboards.
Before You Start
- Hardware & software basics – A laptop with at least 8 GB RAM, Windows 10/ macOS 12 or Linux, and Python 3.10 installed.
- Data sources – Free APIs such as Yahoo Finance, Alpha Vantage (free tier), and the Indian NSE/BSE CSV dumps released nightly.
- Time commitment – Expect 4–6 hours for the first build, then a few minutes a week for updates.
- Mindset – Treat the bot as a research assistant, not a money‑making machine. I’ve seen friends treat a back‑tested 2‑sigma edge as a guarantee and lose everything in a single volatile week.
Controversial take: Many gurus claim you need a paid “pro” data plan to get any edge. In my view, the marginal benefit of premium tick data for a beginner’s 5‑day swing strategy is negligible; the real edge comes from disciplined execution and proper risk sizing.
Step‑by‑Step
1. Choose the right free stock screener
| Region | Free Screener (AI‑enabled) | Key AI Feature | |——–|—————————|—————-| | India | Screener.in (adds custom formulae) | Auto‑rank based on volatility clustering (5‑day std‑dev) | | US | Finviz (free tier) | RSI‑based heat map with built‑in MACD filter | | UK | ADVFN Screener | Beta‑correlation filter for FTSE‑100 constituents | | Brazil | Investidor10 | Simple moving‑average crossover alerts |
All four let you export results as CSV – a must for the next step. I discovered the Indian screener works best for my own small‑cap experiments because the CSV includes daily turnover, which helps compute the beta‑adjusted volatility needed for the AI model.
2. Pull data into Python
import yfinance as yf
import pandas as pd
tickers = pd.read_csv('screener_output.csv')['Ticker'].tolist()
data = yf.download(tickers, period='1y', interval='1d')
The yfinance library is free and handles US, UK and Brazil symbols seamlessly. For NSE/BSE symbols, prepend “.NS” or “.BO” and the same call works.
3. Engineer a simple AI feature set
- Standard deviation moves – 10‑day rolling std‑dev of close price.
- Beta correlation – compute each stock’s beta against the market index (NIFTY 50, S&P 500, FTSE 100, BOVA11).
- RSI/MACD – use
talibrary to add 14‑day RSI and MACD histogram.
import ta
df['std10'] = df['Close'].rolling(10).std()
df['rsi'] = ta.momentum.rsi(df['Close'], window=14)
df['macd'] = ta.trend.macd_diff(df['Close'])
4. Train a lightweight model – no coding experience required
If you shy away from writing algorithms, try the Google Colab “AutoML” notebook that ships with Scikit‑learn’s RandomForestClassifier. Upload the CSV, select the target (e.g., next‑day up‑move > 0.5 % ), and let the notebook run 10 trees. The entire process is drag‑and‑drop; you never write a line of code beyond the snippets above.
5. Generate signals
After training, predict on the latest data slice:
pred = model.predict_proba(df_latest[['std10','beta','rsi','macd']])[:,1]
df_latest['signal'] = (pred > 0.65).astype(int) # 65 % confidence threshold
Only keep stocks where signal == 1 and the screener’s AI rank is in the top 20 %. This double‑filter cuts noise dramatically.
6. Automate order placement (free)
Use Kite Connect’s sandbox (for Zerodha) or Alpaca’s paper‑trading API (US). Both have free tier accounts, no commission on simulated trades. The Python snippet below shows a basic market order:
import alpaca_trade_api as tradeapi
api = tradeapi.REST('KEY_ID','SECRET_KEY', base_url='https://paper-api.alpaca.markets')
api.submit_order(symbol='AAPL', qty=10, side='buy', type='market', time_in_force='day')
7. Apply risk management – free tools
- Position sizing calculator – the free “RiskReward.io” widget lets you set a 1 % capital risk per trade, automatically computing share quantity.
- Portfolio tracker – Portfolio Performance (open‑source Android app) tracks realized and unrealized P/L, and visualises draw‑down volatility.
8. Review and iterate weekly
Export the trade log, compute Sharpe ratio, max draw‑down, and the beta of the strategy versus the market. If the Sharpe falls below 0.8, tighten the confidence threshold or add a volatility‑clustering filter (e.g., require std10 > 1.2× median).

A Worked Example With Real Numbers
Assume you start with ₹500,000 capital and decide to risk 1 % per trade. Using the free risk calculator:
- Risk per trade = ₹5,000
- Average stop‑loss distance (based on 10‑day std‑dev) = 2 % of price → ₹1,000 per share
- Shares per trade = ₹5,000 / ₹1,000 = 5 shares
If the bot generates 4 winning trades and 2 losing trades in a week, with an average win of 1.8 % and loss of 1 %:
- Wins: 4 × 5 shares × ₹1,800 ≈ ₹36,000
- Losses: 2 × 5 shares × ₹1,000 ≈ ₹10,000
Net profit = ₹26,000 (≈5.2 % of capital).
Now, let’s compound this weekly profit using the SIP model allowed in the guidelines: investing ₹5,000/month for 25 years at an assumed 10 % annual return yields about ₹67 lakh. If you reinvest the bot’s weekly gains into the same risk‑adjusted framework, the compounding effect can be substantial over decades, especially when volatility clustering keeps draw‑downs shallow.
Common Mistakes
- Over‑optimizing on back‑test data – fitting a model to every tiny anomaly inflates the in‑sample Sharpe but collapses in live markets. I once tweaked a beta filter to 0.987 after a single good month; the next week the bot lost 12 % because the correlation broke.
- Ignoring transaction costs – free brokers still charge regulatory fees; forgetting them can turn a 0.7 % edge into a net loss.
- Relying on a single indicator – using only RSI or only MACD creates a high‑variance signal. Blend at least two orthogonal features (e.g., volatility clustering + momentum).
- Skipping risk limits – allowing a trade to exceed the 1 % risk rule quickly erodes capital. Use the free position‑sizing widget every time.
Your Next Step
- Pick a free screener for your primary market (e.g., Screener.in for Indian equities).
- Create a paper‑trading account – Indian traders can open a free account at Zerodha; US traders may try the free tier of Alpaca via Webull.
- Run the Colab AutoML notebook linked in the “Machine Learning Signals vs Technical Analysis” article to generate your first model.
- Set a weekly review calendar – 30 minutes every Sunday to compute Sharpe, max draw‑down, and adjust the confidence threshold.
If you follow these actions, you’ll transition from a data‑curious hobbyist to a disciplined, AI‑assisted trader without spending a rupee on premium tools.
📺 Watch on YouTube: He Bought At The Top (FOMO) | Fomo In Trading #shorts
Quick Answers
Q1: How does “Build a Basic AI Trading Bot in Python — Beginner Guide” differ from paid courses?
A: The guide relies exclusively on free open‑source libraries, free screeners, and paper‑trading APIs. Paid courses often bundle proprietary data feeds that add marginal value for a beginner’s 5‑day swing strategy.
Q2: Can I use the same bot for crypto and forex?
A: The core pipeline (data pull → feature engineering → model → risk manager) is identical. Replace the ticker list with crypto symbols from the free CoinGecko API, and adjust the stop‑loss distance to reflect higher volatility.
Q3: What is the minimum capital to start safely?
A: With a 1 % risk rule, a ₹100,000 account yields a ₹1,000 risk per trade, which is enough to buy fractional shares or small‑cap stocks. The key is consistency, not size.
| *November 21, 2026 | Educational content only. Not SEBI registered investment advice.* |
📈 Get Tomorrow's Trade Setups — Free
🎯 Join our free Telegram channel for daily Nifty signals & market alerts.
💎 Want exact entry / stop-loss / target? ₹699 Advance / ₹1,499 Premium — DM us on Telegram.
🪙 Open a free demat to trade these ideas: Zerodha · Dhan · Groww · Upstox (free API access for algo trading) · CoinDCX (crypto)
🧮 Invest once — see what it becomes — try our free calculator.
💬 Found this useful? Share it with a trader friend. Educational only — not SEBI registered.
🤖 Produced with AI tools · 📊 Real market data & analysis · Educational only · Not investment advice.