If you could predict every K-line, how much money could you make?
This project explores the upper bound of trading profitability under a hypothetical assumption:
🔮 The trader can perfectly predict the direction of every K-line.
Based on this assumption, we construct a "Perfect Prediction Strategy" and analyze:
- Maximum achievable return under ideal conditions
- The impact of transaction costs
- The role of market volatility in profit generation
The project is implemented as an interactive UI tool, allowing users to experiment with different assets, data sources, and parameters.
- Tushare (A-shares / ETF)
- Yahoo Finance (Stocks / Crypto)
- Gold ETF (e.g., 518880.SH)
- A-shares (e.g., 600519.SH)
- US Stocks (e.g., AAPL)
- Cryptocurrencies (e.g., BTC-USD)
- Perfect foresight (long when price rises, short when it falls)
- Trade only if profit > transaction cost
- Otherwise stay out of the market
- Transaction fee (core variable)
- Time range
- Time frequency (Year / Month / Day)
- Equity curve comparison (Strategy vs Buy & Hold)
- Trade frequency analysis
- Detailed yearly/monthly breakdown
Unlike traditional strategies that rely on direction prediction, this model captures:
📌 Absolute price movement (volatility), not net trend
The return is calculated as:
- Profit from upward movement → long position
- Profit from downward movement → short position
After transaction cost:
- Trade only when net return is positive
- Otherwise skip
Perfect_Prediction_UI/
│
├── app.py # Streamlit UI
│
├── core/
│ ├── data.py # Data fetching (Tushare / Yahoo)
│ ├── strategy.py # Strategy engine
│
├── utils/
│ ├── plot.py # Visualization
│
├── requirements.txt
git clone https://github.com/yourname/Perfect_Prediction_UI.git
cd Perfect_Prediction_UIpython -m pip install -r requirements.txtpython -m streamlit run app.pyThen open:
http://localhost:8501
You can deploy this project on a cloud server:
streamlit run app.py --server.address 0.0.0.0Access via:
http://your-server-ip:8501
- Analyze the theoretical upper bound of trading strategies
- Study the effect of transaction costs on profitability
- Compare volatility across different markets
- Build intuition about market microstructure
- This strategy assumes perfect future knowledge, which is impossible in reality
- Results represent an upper bound, not achievable performance
- High-frequency scenarios are extremely sensitive to transaction costs
Markets do not reward prediction alone — they reward the ability to extract value from volatility after friction.
- Fee sensitivity analysis curve
- Multi-asset comparison dashboard
- Strategy benchmarking (trend vs mean reversion)
- Exportable reports (PDF/CSV)
- Online deployment with domain
MIT License
- Tushare for financial data API
- Yahoo Finance for global asset data
- Streamlit for rapid UI development
Give it a star on GitHub!