CAPM Metrics
A stock performance tool based on the Capital Asset Pricing Model (CAPM). This package allows you to analyze stock performance and expected returns based on market data.
Features
- Fetch historical stock data using the Yahoo Finance API.
- Calculate expected returns based on the CAPM model.
- Analyze stock performance against a market index.
- Get average yields from the 10-year Treasury note for risk-free return calculations.
Installation
You can install the capm-metrics package via pip:
pip install capm-metrics
Usage
Here's a basic example of how to use the CAPMAnalyzer class:
from capm_metric import CAPMAnalyzer
# Create an instance of CAPMAnalyzer
analyzer = CAPMAnalyzer()
# Analyze a stock (e.g., Apple Inc. with ticker 'AAPL')
results = analyzer.analyze('AAPL', period='1y')
# Print the results
print(results)
Parameters
symbol(str): The stock symbol for analysis.market(str, optional): The market index symbol (default:^GSPC).period(str, optional): Valid periods for fetching data (e.g.,1d,1mo,1y, etc.).start(str, optional): Download start date (YYYY-MM-DD).end(str, optional): Download end date (YYYY-MM-DD).
Expected Output
The analyze method returns an OrderedDict containing:
company_name: The full name of the company.symbol: The stock symbol.start_date: The start date of the analysis (YYYY-MM-DD).end_date: The end date of the analysis (YYYY-MM-DD).expected_return: The expected return calculated using CAPM.actual_return: The actual return calculated over the analysis period.performance: Indicates whether the stock overperformed or underperformed compared to the expected return.
Example
results = analyzer.analyze('AAPL', period='1y')
print(f"Expected Return: {results['expected_return']}")
print(f"Actual Return: {results['actual_return']}")
print(f"Performance: {results['performance']}")
Dependencies
numpypandasyfinance
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request if you'd like to contribute.
Acknowledgments
This package uses the yfinance library to fetch stock data, and the calculations are based on the Capital Asset Pricing Model (CAPM).
Metadata
Release files for capm-metrics 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| capm_metrics-0.1.1.tar.gz | 6.5 kB | Without provenance | Details for capm_metrics-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| capm_metrics-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for capm_metrics-0.1.1-py3-none-any.whl |
Total release size: 13.6 kB
Release files / capm_metrics-0.1.1.tar.gz
| Download URL | capm_metrics-0.1.1.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f510d7418e37fe8a2788129a1e79a3af41961ab9e0789130948e0b209f67ecd
|
|
BLAKE2b-256 checksum How to use checksums |
1a356f54a498f35d3b0645cefdb34bc53a63d50685847d05323fcf5b922aa0bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Release files / capm_metrics-0.1.1-py3-none-any.whl
| Download URL | capm_metrics-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae0276e2298836f9878af407fbdc757888a26da95bee24ee2e10079396644a6d
|
|
BLAKE2b-256 checksum How to use checksums |
4eb88e124248b68d8c106ef05fe2dd59ab538d1859dad6929887001df779a52f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Security for capm-metrics 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.