Skip to content

Commit 092ae3d

Browse files
committed
Readme for examples
1 parent 3292ea0 commit 092ae3d

File tree

1 file changed

+98
-11
lines changed

1 file changed

+98
-11
lines changed

examples/README.md

Lines changed: 98 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,23 @@ This directory contains example scripts demonstrating how to use the Borsdata AP
66

77
Before running these examples, make sure you have:
88

9-
1. Installed the borsdata-client package by cloning the repo.
9+
1. Clone the repository and install the package in development mode:
10+
11+
```bash
12+
# Clone the repository
13+
git clone https://github.com/alexwox/Modern-Borsdata-Client.git
14+
cd Modern-Borsdata-Client
15+
16+
# Create and activate a virtual environment (recommended)
17+
python -m venv .venv
18+
source .venv/bin/activate # On Windows use: .venv\Scripts\activate
19+
20+
# Install basic dependencies
21+
pip install -e .
22+
23+
# For running all examples including visualization
24+
pip install -r requirements-dev.txt
25+
```
1026

1127
2. Set up your API key as an environment variable or in a `.env` file:
1228
```
@@ -17,29 +33,100 @@ Before running these examples, make sure you have:
1733

1834
### Basic Usage (`basic_usage.py`)
1935

20-
A simple example showing how to fetch instruments, markets, and stock prices.
36+
A simple example showing how to fetch basic data from the Borsdata API:
37+
38+
- List all available instruments
39+
- Get market information
40+
- Fetch historical stock prices
2141

2242
```bash
2343
python basic_usage.py
2444
```
2545

2646
### Portfolio Analysis (`portfolio_analysis.py`)
2747

28-
A more advanced example demonstrating how to analyze a portfolio of stocks.
48+
An advanced example demonstrating portfolio analysis capabilities:
2949

30-
**Additional Requirements:**
31-
32-
- pandas: `pip install pandas`
50+
- Track multiple stocks in a portfolio
51+
- Calculate total portfolio value
52+
- Analyze portfolio allocation
53+
- Calculate key performance metrics:
54+
- Total and annualized returns
55+
- Portfolio volatility
56+
- Sharpe ratio
3357

3458
```bash
3559
python portfolio_analysis.py
3660
```
3761

62+
### Stock Visualization (`stock_visualization.py`)
63+
64+
A comprehensive visualization tool that creates beautiful charts for stock analysis:
65+
66+
- Interactive price charts with multiple views:
67+
- Price trends with 20-day and 50-day moving averages
68+
- Trading volume analysis
69+
- Daily returns visualization with color-coded gains/losses
70+
- Key statistics display including:
71+
- Current price
72+
- 52-week high/low
73+
- Daily volatility
74+
- Generates high-quality PNG files for each analyzed stock
75+
76+
```bash
77+
python stock_visualization.py
78+
```
79+
80+
## Dependencies
81+
82+
Each example may require different dependencies:
83+
84+
- `basic_usage.py`: Basic requirements only
85+
- `portfolio_analysis.py`: Requires pandas
86+
- `stock_visualization.py`: Requires pandas, matplotlib, and seaborn
87+
88+
All required dependencies are included in `requirements-dev.txt`.
89+
3890
## Customizing the Examples
3991

40-
Feel free to modify these examples to suit your needs. You can:
92+
These examples are designed to be easily customizable:
93+
94+
### Basic Usage
95+
96+
- Modify the time period for historical data
97+
- Change the number of price points displayed
98+
99+
### Portfolio Analysis
100+
101+
- Edit the `PORTFOLIO` dictionary to include your stocks
102+
- Adjust the analysis period
103+
- Add custom performance metrics
104+
105+
### Stock Visualization
106+
107+
- Modify the `tickers` list to analyze different stocks
108+
- Customize the chart appearance:
109+
- Change colors and styles
110+
- Adjust technical indicators
111+
- Modify the layout
112+
- Add additional technical indicators
113+
- Change the time period (default is 1 year)
114+
115+
## Output Examples
116+
117+
- `basic_usage.py`: Prints data to console
118+
- `portfolio_analysis.py`: Displays portfolio statistics and performance metrics
119+
- `stock_visualization.py`: Generates `{TICKER}_analysis.png` files with comprehensive visualizations
120+
121+
## Error Handling
122+
123+
All examples include proper error handling for common issues:
124+
125+
- Missing API key
126+
- Invalid stock tickers
127+
- Network connection problems
128+
- Missing data
129+
130+
## Contributing
41131

42-
- Change the portfolio stocks in `portfolio_analysis.py`
43-
- Adjust the time periods for historical data
44-
- Add additional analysis metrics
45-
- Integrate with visualization libraries like matplotlib or plotly
132+
Feel free to contribute additional examples or improvements to existing ones through pull requests.

0 commit comments

Comments
 (0)