Inspiration

Stock markets are exciting, but real-world trading carries financial risks, often worsened by social media hype. Platforms like Twitter and Reddit can drive fear of missing out (FOMO), leading to impulsive investments in volatile stocks or risky trends. Many traders, influenced by viral posts, engage in day trading and speculative buying, often without understanding long-term consequences.

Our goal is to provide a risk-free environment where users can experiment with strategies, learn market dynamics, and refine decision-making, all while avoiding the financial risks associated with real-world trading. By incorporating penalties for reckless behaviors like overtrading and day trading, the game promotes thoughtful, long-term investing over hype-driven speculation. This way, players develop practical investment habits while enjoying a fun and interactive challenge.

What it does

The Fantasy Stock League is an interactive stock trading simulation game where players:

  • Create individualized accounts with $100,000 in virtual cash.
  • Buy and sell real stocks using live market data via Yahoo Finance.
  • Compete on a leaderboard based on preferred smart investment strategies.
  • Get penalized for risky behaviors like day trading, overtrading, and reckless investing.
  • Earn bonus points for diversification of portfolio and beating trends like the S&P 500.
  • Track portfolio value, trade history, and open positions with a real-time data interface.
  • Receive real-time feedback on trading strategies, including penalties and score updates.
  • View a detailed breakdown of trades, including entry/exit times and stock beta values.
  • Monitor performance via a stock price history graph and portfolio distribution chart.

Game Rules & Mechanics πŸ†

βœ” Real-Time Stock Prices – Fetches stock prices via Yahoo Finance API.
βœ” Fantasy Portfolio Management – Track holdings, trade history, and overall portfolio distribution.
βœ” Score Calculation – Rewards long-term investors and penalizes excessive trading.
βœ” Day Trading Detection – Identifies and penalizes same-day buy and sell transactions.
βœ” Overtrading Penalty – Imposes penalties if trade count exceeds a certain threshold.
βœ” Portfolio Diversification Bonus – Encourages spreading investments across different stocks.
βœ” Real-Time Graphs – Stock price history and open stock holdings pie chart.
βœ” Authentication System – Secure sign-in and account creation for persistent user tracking.

Positive Reinforcements

βœ… Smart Investing – Focus on long-term portfolio growth and outperforming the market.
βœ… Risk Management – Diversify holdings and avoid concentrated high-value trades.
βœ… Strategic Trading – Make informed investment decisions rather than frequent speculative trades.

Penalized Behaviors

❌ Avoid Day Trading – Steer clear of quick buy and sell cycles for short-term gains.
❌ Limit Overtrading – Avoid excessive transactions that don’t add value to portfolio performance.
❌ Unnecessary Risks – Manage risk by limiting oversized trades that could jeopardize returns.

How We Built It πŸ› οΈ

Frontend: Built with Streamlit for an interactive and intuitive user interface.
Backend: Python for processing trades, scoring, and handling session states.
Live Stock Data: Yahoo Finance API for fetching real-time stock prices.
Data Handling: Pandas for managing and displaying portfolio data.
User Authentication: Secure sign-in and registration system with hashed password storage.
Graphing & Visualization: Plotly for displaying stock history and portfolio distribution.

Challenges we ran into

πŸ”΄ Git Version Control: Managing Git version control led to conflicts when multiple team members worked on the same files, requiring careful resolution to avoid data loss and rework.
πŸ”΄ Balancing Penalties and Rewards: Fine-tuning the penalty system for behaviors like day trading and overtrading was tricky to ensure it was both effective and engaging without discouraging participation.
πŸ”΄ User Login and Registration: Ensuring proper initialization and storage of user data (portfolio, trades) across sessions while preventing users from re-entering their name if they already have an existing account.
πŸ”΄ Real-Time Data Handling: Ensuring stock prices and portfolio values update efficiently without excessive API calls.

Accomplishments that we're proud of

πŸ… Successfully built a fully functional fantasy trading platform!
πŸ… Implemented real-time data visualization updates using Yahoo Finance API.
πŸ… Designed a unique scoring system that encourages smart investing strategies.
πŸ… Developed a penalty system to deter risky trading behaviors.
πŸ… Created real-time portfolio monitoring tools, including detailed trade breakdowns and stock charts.

What we learned

πŸ“Œ How to integrate financial data APIs into a live web app.
πŸ“Œ Best practices for user session management in Streamlit.
πŸ“Œ The importance of penalty systems in gamifying financial education.
πŸ“Œ Implementing efficient data visualization tools for tracking financial trends.

What's next for Fantasy Stock League

πŸ”œ Expand Leaderboards – Track all-time, weekly, and daily top traders.
πŸ”œ Introduce Trading Strategies – AI-generated insights based on user trading patterns.
πŸ”œ More Penalties & Bonuses – Reward for holding stocks longer, penalize extreme volatility.
πŸ”œ Mobile Support – Optimize UI for seamless mobile trading.
πŸ”œ Enhanced Market Insights – Provide real-time news integration for better decision-making.

Built With

Share this project:

Updates