Comparing three stocks side by side in Excel is easy. But what happens when the task involves hundreds of companies, a decade of financial statements and price data that changes every day? As formulas multiply, the file becomes unwieldy, versions blur into one another, and the analysis stops being reproducible. Python changed financial analysis because it turns the process into code that can be inspected, versioned and run again.
This article walks through a pipeline for screening BIST stocks with data-science tools. The goal is not a winning formula, but a way of thinking that lets you encode your own criteria.
The invisible limit of Excel
Excel remains a strong tool for exploration and quick checks. The problem appears when it is used as a production system. Screening a universe of stocks is mostly manual: download, align, clean, calculate and format. Each step costs time and introduces the risk of error. More importantly, reproducing the same analysis six months later becomes nearly impossible.
Python overcomes this limit by turning the analysis from a file into a program. A program makes it explicit which data is processed and how; once it is correct, it can be run again on new data.
Why Python became the default
Three reasons explain Python’s adoption. First, it offers a mature data ecosystem: Pandas handles tables, NumPy numerical work, and Matplotlib visualisation. Second, the same code can be used across research, reporting and production.
For BIST stocks, libraries such as yfinance can retrieve data from Yahoo Finance by appending .IS to the ticker. It is practical for early exploration, though a permanent system should assess the licence, latency and accuracy of its source.
A screening pipeline, from universe to report
A good screen is a chain of four connected steps.
1. Define the universe
Decide which stocks to screen. The full BIST universe is a reasonable start, but thinly traded names can distort results through costs and price noise. Narrowing by liquidity, market capitalisation or sector makes the output easier to interpret.
2. Collect and clean the data
Returns calculated without adjusting for dividends and stock splits will mislead. For financial statements, document that period ends are aligned, that the currency is consistent, and how missing items are handled. Data cleaning is the least visible and most decisive step in the analysis.
3. Define the criteria
Do not reduce your criteria to a single ratio. Value, quality, growth and risk answer different questions:
- Value: price-to-earnings, price-to-book, enterprise value-to-EBITDA.
- Quality: return on equity, EBITDA margin, cash conversion cycle.
- Financial health: net debt to EBITDA, interest coverage.
- Market behaviour: long-term trend, volatility, relative strength versus the index.
Set a direction and a threshold for each measure. Instead of a broad claim such as “a low P/E is good”, write down why it should be good for a given sector and period.
4. Rank, filter and report
Collapsing every measure into a single score is tempting, but it hides which assumption drove the result. Apply hard filters first, rank the remaining universe on each measure, and report the results with their reasoning. The output is a shortlist for research, not a buy list.
A short example shows the flow:
import pandas as pd
import yfinance as yf
tickers = ["THYAO.IS", "ASELS.IS", "GARAN.IS"] # sample universe
prices = yf.download(tickers, period="1y", auto_adjust=True)["Close"]
momentum = prices.pct_change(126).iloc[-1].sort_values(ascending=False)
print(momentum)
This code only demonstrates the flow; the results alone are not enough for an investment decision.
Where AI earns its place
Machine learning contributes by evaluating many measures jointly and capturing non-linear relationships. It requires a labelled target, a sufficient sample and rigorous out-of-sample testing; leaking future information makes a model look perfect in hindsight and useless in practice.
Language models can summarise filings and news, but every sentence must be verified against its source. AI is not a black box that replaces the analyst; it adds scale.
No reproducibility, no screener
A screening system is valuable when it reproduces the same result from the same input. Keep the code under version control, record the data source and download date, centralise thresholds in a configuration file, and archive the output of every run. This makes it easier to find errors and understand why a strategy changed.
Conclusion
Python is not magic in financial analysis; it is leverage. It makes it possible to screen hundreds of stocks at once, document the criteria and reproduce the results. But however well the screen is built, the investment decision still requires risk management, patience and judgement. Code clarifies the question; responsibility for the answer remains with the analyst.
This article is for educational purposes only and does not constitute investment advice. The code example illustrates a conceptual flow only.