C0419 Study Pack — Educational Only
C0419 Study Note
AI Trading System Development — Python Backtesting, Web Scraping, LLM Sentiment, Correlation
Class ID: C0419 | Date: 2026-04-19 | Source: [Link]
EDUCATIONAL ONLY — This note explains the lecture process and technology stack. It is not financial advice
and does not recommend any trade, product, broker, or strategy.
Executive Summary
Use Python as the “workbench” for backtesting, optimization, data collection, LLM analysis, and reporting. Ref: C0419-
S01, C0419-S05
Run a baseline strategy before optimization; optimization is for controlled improvement, not proof. Ref: C0419-S04
Use web scraping to collect allowed web data; use LLMs to summarize and score news, but keep human/risk review.
Ref: C0419-S06, C0419-S15
Use correlation to understand whether positions diversify exposure or secretly behave like the same trade. Ref:
C0419-S16, C0419-S17
Execution can be modular: TradingView for entry signals, MT5 EA/Python for post-entry position management. Ref:
C0419-S19
Transcript Section Map
Section ID Title Timestamp
C0419-S01 Lecture roadmap and new tooling 00:00:00–00:04:40
C0419-S02 Jupyter setup and data download 00:04:41–00:09:46
C0419-S03 Strategy class and GMMA logic 00:09:47–00:16:04
C0419-S04 Backtest metrics and optimization 00:16:05–00:24:15
C0419-S05 Sizing, CSV flexibility, scheduling 00:24:16–00:30:37
C0419-S06 Web scraping and AI use cases 00:30:38–00:38:57
C0419-S07 URL, DNS, HTTP request-response 00:38:58–00:47:38
C0419-S08 Inspect element and HTML tree 00:47:39–00:59:49
C0419-S09 Requests, imports, BeautifulSoup 00:59:50–01:05:08
C0419-S10 Tags, classes, tables, selectors 01:05:09–01:14:32
C0419-S11 Hands-on scraping exercise 01:14:33–01:29:35
C0419-S12 Exercise review and numeric parsing 01:29:36–01:43:47
C0419-S13 Selenium and JavaScript pages 01:43:48–01:55:34
C0419-S14 OpenAI API summarization pipeline 01:55:35–02:08:27
C0419-S15 Bullish-bearish scoring prompt 02:08:28–02:15:59
C0419-S16 Correlation: VIX and NQ example 02:16:00–02:25:06
C0419-S17 Index-stock correlation and risk 02:25:07–02:41:12
C0419-S18 Exam and assignment guidance 02:41:13–02:46:57
C0419-S19 Course recap and EA workflow 02:46:58–02:53:13
C0419-S20 Wrap-up: stocks, options, AI 02:53:14–03:00:34
Educational only — not financial advice.
C0419 Study Pack — Educational Only
Core Learning Flow
Step Meaning
Define a repeatable strategy hypothesis before touching
Idea
parameters. Ref: C0419-S03
Prepare OHLCV/CSV data and ensure the columns match the
Data
backtesting framework. Ref: C0419-S05
Run the strategy once with reasonable parameters and
Baseline
inspect the trade list/equity curve. Ref: C0419-S04
Search TP/SL or other parameters only after the baseline
Optimize
works. Ref: C0419-S04
Add web/news/sentiment/correlation data as supporting
Augment signals, not as blind trade commands. Ref: C0419-S06, C0419-
S15, C0419-S16
Separate entry signal from position/risk management. Ref:
Deploy
C0419-S19
1. What this lecture adds to the course
Python is positioned as the flexible layer for strategy testing, optimization, reporting, and AI integration. Ref: C0419-
S01, C0419-S02
The lecture connects three workflows: backtesting/optimization, web data collection, and correlation/risk analysis.
Ref: C0419-S01, C0419-S16
The instructor repeatedly states that examples are demonstrations, not strategy recommendations. Ref: C0419-S04,
C0419-S05
2. Python backtesting workflow
Install or import the needed libraries: pandas/yfinance for data handling, a backtesting framework for simulation, and
plotting/report tools for review. Ref: C0419-S02
Shape your data into the expected OHLCV format before testing. Any instrument can be tested if the data is reliable
and formatted correctly. Ref: C0419-S05
Define the strategy as a reusable class: inputs/parameters, indicators, entry conditions, exit conditions, and
state/memory. Ref: C0419-S03
Run a baseline test first; review win rate, return, CAGR, Sharpe ratio, drawdown, equity curve, and individual trade
records. Ref: C0419-S04
Only after a baseline exists should you optimize parameters such as TP/SL. Ref: C0419-S04
3. GMMA / Guppy-style strategy example
The example compares short EMA groups with long EMA groups, similar to Guppy lines / GMMA logic. Ref: C0419-S03
A long state appears when short-term EMA structure is above the long-term group; a short state appears in the
reverse condition. Ref: C0419-S03
The strategy needs event detection, not repeated state entries: enter on the first valid signal, not every bar where the
condition remains true. Ref: C0419-S03
Exit logic is separate from entry logic. A reverse condition or TP/SL can close an existing trade. Ref: C0419-S03, C0419-
S04
Educational only — not financial advice.
C0419 Study Pack — Educational Only
4. Optimization without fooling yourself
Parameter optimization can maximize return, Sharpe ratio, or another selected metric, but each objective creates
different behavior. Ref: C0419-S04
A brute-force grid can be slow when many parameter combinations are tested; smarter search methods or sampling
can reduce computation time. Ref: C0419-S04
Optimization results must be interpreted alongside position sizing and capital assumptions. A return number can
look low or high depending on denominator and contract size. Ref: C0419-S05
Do not assume the optimized set is robust. Treat it as a candidate for further validation, not proof of future
profitability. Ref: C0419-S04, C0419-S05
5. Web scraping as a data source
Web scraping starts with a URL, DNS resolution, HTTP request, and HTTP response. Ref: C0419-S07
The returned HTML is a structured document. Tags, classes, IDs, and tables allow code to find the content you want.
Ref: C0419-S08, C0419-S10
requests + BeautifulSoup is suitable for many static pages; Selenium is useful when JavaScript or browser interaction
is required. Ref: C0419-S09, C0419-S13
Extracted values may arrive as text; convert to numeric form before using them in calculations. Ref: C0419-S12
6. LLM sentiment-analysis pipeline
A practical pipeline is: scrape article links and text -> store in a DataFrame/CSV -> send article text to an LLM -> receive
summaries and sentiment scores. Ref: C0419-S14
The prompt can request bullish/bearish scoring plus reasons, so the output is reviewable instead of a black-box
number. Ref: C0419-S15
News sentiment is an input, not a trade command. It should be combined with risk controls, technical context, and
validation. Ref: C0419-S01, C0419-S15
API keys are operational secrets and may change; notebooks should not rely on shared demo keys for production.
Ref: C0419-S14
7. Correlation and risk thinking
Correlation measures linear co-movement between two series, ranging from -1 to +1. Ref: C0419-S16
VIX versus NQ/Nasdaq is used as a negative-correlation example; index stocks are used as positive-correlation
examples. Ref: C0419-S16, C0419-S17
Correlation can identify proxy exposure: a highly correlated stock may behave similarly to an index in broad moves.
Ref: C0419-S17
Correlation can also identify concentration risk. A portfolio of highly correlated names may not be diversified even if it
contains many tickers. Ref: C0419-S17
8. Semi-autonomous execution idea
TradingView can send the entry signal; MT5/EA or Python can manage the open position afterward. Ref: C0419-S19
The EA can stay idle when there is no position, then manage TP, SL, and trailing stop once a position exists. Ref:
C0419-S19
MQL may be preferable for tick-level management, while Python may be better for orchestration, data analysis, AI,
and reporting. Ref: C0419-S19, C0419-S20
This separation keeps entry logic, execution, and risk management modular. Ref: C0419-S19
Educational only — not financial advice.
C0419 Study Pack — Educational Only
Practice Labs
Lab 1 — Python baseline backtest
Open the 0419 backtesting notebook in Jupyter Notebook. Ref: C0419-S02
Run the library installation/import cells. Confirm pandas, yfinance, and the backtesting package load correctly. Ref:
C0419-S02
Download the historical dataset and inspect the OHLCV columns. Ref: C0419-S02
Run the GMMA/Guppy baseline strategy and capture the equity curve plus trade list. Ref: C0419-S03, C0419-S04
Write down win rate, return, CAGR, Sharpe ratio, max drawdown, and number of trades. Ref: C0419-S04
Lab 2 — Parameter optimization
Choose one objective: return, Sharpe ratio, or drawdown-aware score. Ref: C0419-S04
Set TP/SL ranges and run the optimizer. Ref: C0419-S04
Compare the best parameter set with the baseline, then explain whether the improvement is meaningful. Ref: C0419-
S05
Checkpoint: does the result look robust, or does it look like overfitting? Ref: C0419-S04, C0419-S05
Lab 3 — Static web scraping with BeautifulSoup
Open the target webpage and use Inspect Element to find the HTML tag/class around the value. Ref: C0419-S08,
C0419-S10
Use requests to retrieve the page and BeautifulSoup to parse it. Ref: C0419-S09
Use find or find_all to extract the target value. Ref: C0419-S12
Convert the extracted text into a number when it will be used for calculation. Ref: C0419-S12
Lab 4 — LLM news scoring
Collect article links and full text into a DataFrame. Ref: C0419-S14
Send each article to the LLM with a prompt asking for summary, bullish/bearish score, and reasoning. Ref: C0419-S15
Sort by extreme scores and manually review a sample of outputs. Ref: C0419-S15
Checkpoint: does the model explanation match the actual article content? Ref: C0419-S15
Lab 5 — Correlation scan
Load an index and a basket of candidate stocks or ETFs. Ref: C0419-S17
Compute pairwise correlation against the index. Ref: C0419-S16, C0419-S17
Rank the results from highest positive to lowest/negative correlation. Ref: C0419-S17
Checkpoint: identify which names are index proxies and which names may diversify exposure. Ref: C0419-S17
Fast Review Checklist
☐ Can I explain the difference between baseline backtest and optimization? Ref: C0419-S04
☐ Can I identify state vs event logic and avoid repeated entries? Ref: C0419-S03
☐ Can I inspect a webpage and find the tag/class containing the target data? Ref: C0419-S08, C0419-S10
☐ Can I explain when Selenium is needed instead of requests? Ref: C0419-S13
☐ Can I interpret correlation coefficient direction and strength? Ref: C0419-S16
☐ Can I describe the TradingView entry + EA management workflow? Ref: C0419-S19
Mini Glossary
Term Plain meaning
Backtesting Testing a strategy against historical data. Ref: C0419-S04
Optimization Searching parameter combinations against an objective
Educational only — not financial advice.
C0419 Study Pack — Educational Only
metric. Ref: C0419-S04
EMA-group trend structure using short and long EMA groups.
GMMA / Guppy lines
Ref: C0419-S03
Programmatic extraction of allowed webpage data. Ref:
Web scraping
C0419-S06
BeautifulSoup Python tool for parsing HTML. Ref: C0419-S09
Browser automation tool for JavaScript-heavy or interactive
Selenium
pages. Ref: C0419-S13
LLM sentiment score Model-generated classification of news tone. Ref: C0419-S15
Numerical measure of co-movement from -1 to +1. Ref:
Correlation coefficient
C0419-S16
MT5 Expert Advisor that can automate or semi-automate
EA
management tasks. Ref: C0419-S19
Review Questions
Why should you run a baseline backtest before optimizing TP/SL? Ref: C0419-S04
What problem occurs if you treat a long/short state as an entry event? Ref: C0419-S03
When would Selenium be more appropriate than requests + BeautifulSoup? Ref: C0419-S13
What should an LLM sentiment prompt return besides a score? Ref: C0419-S15
How can high positive correlation create hidden concentration risk? Ref: C0419-S17
Why separate TradingView entry signals from EA position management? Ref: C0419-S19
One-Week Practice Plan
Day 1: Re-run the baseline backtest and save the equity curve. Ref: C0419-S04
Day 2: Change one TP/SL range and compare the result with the baseline. Ref: C0419-S04
Day 3: Scrape one harmless public webpage value and convert it to a number. Ref: C0419-S12
Day 4: Summarize one news article with an LLM and ask for bullish/bearish reasoning. Ref: C0419-S15
Day 5: Compute correlation between one index and five related stocks/ETFs. Ref: C0419-S17
Educational only — not financial advice.