A collection of modern Python projects featuring async APIs, real-time financial data, and interactive visualizations.
A powerful async Python script that fetches random English words and their definitions from the Datamuse API.
β¨ Key Features:
- β‘ Async HTTP requests for non-blocking operations
- π Fetches random 6-letter English nouns with detailed definitions
- π‘οΈ Intelligent fallback mechanism for offline usage
- ποΈ Customizable word length via wildcard patterns
- π Production-ready error handling
π‘ API: Datamuse API
Example Output:
π‘ Connecting to Datamuse API to fetch a secret word...
β
Word Found: PYTHON
Definition: A large snake found in tropical regions
An interactive CLI application that analyzes your investment portfolio with real-time stock prices and generates beautiful charts.
β¨ Key Features:
- π° Real-time stock price fetching from Yahoo Finance
- π₯οΈ Interactive command-line interface
- π Professional horizontal bar charts
- πΌ Automatic portfolio value calculation
- πΎ CSV export functionality
- π¨ Customized styling with seaborn
π‘ API: Yahoo Finance (via yfinance library)
Example Output:
π Launching visual engine window...
[Displays interactive portfolio allocation chart]
Sample portfolio data file demonstrating the expected CSV format.
Contents:
- NVDA: 45 units @ $209.05 = $9,407.25
- AAPL: 30 units @ $303.84 = $9,115.20
- Total Portfolio Value: $18,522.45
- Python 3.7+ (recommended: Python 3.10 or higher)
| Package | Version | Purpose |
|---|---|---|
httpx |
>= 0.23.0 | Async HTTP requests (Task1) |
yfinance |
>= 0.1.70 | Yahoo Finance data retrieval (Task2) |
matplotlib |
>= 3.5.0 | Data visualization (Task2) |
Optional but recommended:
pandas- Advanced data manipulationaiohttp- Alternative async HTTP libraryrequests- Synchronous HTTP fallback
- β Windows, macOS, or Linux
- β Internet connection (required for live API calls)
- β Display capability (for matplotlib visualizations)
- β 50MB+ free disk space
-
Clone or download this repository
git clone https://github.com/saksham-stack/codealpha-tasks.git cd codealpha-tasks -
Install dependencies
pip install httpx yfinance matplotlib
Or install from requirements file (if available):
pip install -r requirements.txt
-
Verify installation
python -c "import httpx, yfinance, matplotlib; print('β All dependencies installed!')"
python Task1.pyWhat it does:
- Connects to Datamuse API
- Fetches a random 6-letter English noun
- Displays the word with its definition
- Falls back to local dictionary if offline
Requirements: Internet connection
Sample Run:
π‘ Connecting to Datamuse API to fetch a secret word...
β
Word Found: WHISPER
Definition: Soft, hushed speech or voice
python Task2.pyStep-by-Step Walkthrough:
=========================================
VISUAL LIVE-TICKING ASSET ANALYTICS
=========================================
Type 'done' when you have finished entering your positions.
1οΈβ£ Enter ticker symbol: AAPL
2οΈβ£ Enter quantity held: 30
3οΈβ£ Enter unit price (optional, or press Enter for live fetch): [Press Enter]
β
Asset recorded: AAPL @ $303.84 (30 units)
4οΈβ£ Enter ticker symbol: NVDA
5οΈβ£ Enter quantity held: 45
6οΈβ£ Enter unit price (optional, or press Enter for live fetch): [Press Enter]
β
Asset recorded: NVDA @ $209.05 (45 units)
7οΈβ£ Enter ticker symbol: done
π Launching visual engine window...
πΎ Data exported to: visual_portfolio_manifest.csv
Output Files:
- Interactive chart visualization
visual_portfolio_manifest.csv- Portfolio data export
Requirements: Internet connection for real-time prices
Cause: Network connectivity issue or API downtime
Solution:
# Check internet connection
ping google.com
# Verify API is online (Task1)
curl https://api.datamuse.com/words?sp="?????"
# Try again in a few momentsCause: Dependencies not installed
Solution:
pip install --upgrade httpx yfinance matplotlibCause: API response is slow
Solution:
- Check your internet speed
- Try running the script again
- Increase timeout in code (advanced users)
Cause: Display backend not configured
Solution:
Add this to the top of Task2.py:
import matplotlib
matplotlib.use('TkAgg') # or 'Qt5Agg', 'Agg', etc.Cause: Typo in stock symbol
Solution:
- Verify ticker on Yahoo Finance
- Use uppercase (e.g., AAPL not aapl)
| Issue | Solution |
|---|---|
| No internet? | Task1 has offline fallback; Task2 requires internet |
| Charts not showing? | Try different matplotlib backend (TkAgg, Qt5Agg, Agg) |
| Slow API response? | Normal during market hours; try off-peak times |
| CSV not generated? | Ensure write permissions in the directory |
Change the wildcard pattern in line 15:
"sp": "??????", # 6-letter words (6 question marks)
"sp": "?????", # 5-letter words
"sp": "????????", # 8-letter wordsModify the color scheme in line 24:
bars = ax.barh(tickers, values, color='#2ca02c', edgecolor='#1a611a', height=0.6)
# Change '#2ca02c' to any hex color codecodealpha-tasks/
βββ README.md # This file
βββ Task1.py # Word fetcher script
βββ Task2.py # Portfolio visualizer script
βββ visual_portfolio_manifest.csv # Sample data file
βββ requirements.txt # (Optional) Dependency file
By using these projects, you'll learn:
- β Async Programming - Understanding asyncio and async/await patterns
- β REST APIs - Consuming external APIs (Datamuse, Yahoo Finance)
- β Data Visualization - Creating professional charts with matplotlib
- β CLI Development - Building interactive command-line applications
- β Error Handling - Implementing fallbacks and exception handling
- β CSV Operations - Reading and writing CSV files
We welcome contributions! Here's how to help:
- Report Issues - Found a bug? Create an issue
- Submit PRs - Have improvements? Send a pull request
- Improve Docs - Help us improve this README
- Share Ideas - Suggest new features in the discussions
These tasks are part of the CodeAlpha Training Program.
Licensed under the MIT License - see LICENSE file for details.
- Datamuse - For the amazing word/definition API
- Yahoo Finance - For real-time stock market data
- Python Community - For incredible libraries like httpx, yfinance, and matplotlib
- CodeAlpha - For the opportunity to build these projects
- π¬ Questions? Check the FAQ section
- π Found a bug? Report it here
- π‘ Feature request? Suggest it
| Metric | Value |
|---|---|
| Language | Python 3.7+ |
| Lines of Code | ~250 (combined) |
| External APIs | 2 |
| Core Dependencies | 3 |
| Last Updated | June 2026 |
Made with β€οΈ for the CodeAlpha Community