A comprehensive Python library for financial risk and return analysis, featuring advanced AI-powered insights and calculations.
Chrematai empowers financial professionals, researchers, and developers with robust tools for quantitative finance and risk management.
- π Financial Risk Metrics: Calculate Value at Risk (VaR), Expected Shortfall, Sharpe Ratio, and more
- π Return Analysis: Comprehensive return analysis with statistical measures
- π€ AI-Powered Insights: Integration with multiple AI providers (OpenAI, DeepSeek, Grok)
- π Financial Statement Analysis: Automated analysis of financial statements
- π Report Generation: Professional financial reports with insights
- π Multiple Data Sources: Support for various data formats (CSV, Excel, JSON, APIs)
- β‘ High Performance: Optimized calculations using NumPy and Pandas
- π§ͺ Well Tested: Comprehensive test suite with high coverage
pip install chremataigit clone https://github.com/artaasd95/chrematai.git
cd chrematai
pip install -e ".[dev]"from chrematai import FinancialAnalyzer
from chrematai.services.ai import AIService
# Initialize the analyzer
analyzer = FinancialAnalyzer()
# Load financial data
data = analyzer.load_data("portfolio_data.csv")
# Calculate risk metrics
risk_metrics = analyzer.calculate_risk_metrics(data)
print(f"Portfolio VaR (95%): {risk_metrics.var_95:.2%}")
print(f"Sharpe Ratio: {risk_metrics.sharpe_ratio:.2f}")
# Generate AI-powered insights
ai_service = AIService(provider="openai") # or "deepseek", "grok"
insights = ai_service.analyze_financials(data)
print(f"AI Insights: {insights.summary}")
# Generate comprehensive report
report = analyzer.generate_report(data, risk_metrics, insights)
report.save_to_pdf("financial_analysis_report.pdf")Full documentation is available at https://artaasd95.github.io/chrematai/
chrematai/
βββ π chrematai/ # Main package
β βββ π services/ # Service layer implementations
β β βββ π ai/ # AI service providers
β β βββ π analysis/ # Financial analysis services
β βββ π calculations/ # Core financial calculations
β βββ π data_loader/ # Data loading and processing
β βββ π analyzer.py # Main analyzer class
βββ π tests/ # Comprehensive test suite
βββ π docs/ # Documentation source
βββ π examples/ # Usage examples
βββ π requirements.txt # Dependencies
Create a .env file in your project root:
# AI Service API Keys
OPENAI_API_KEY=your_openai_api_key
DEEPSEEK_API_KEY=your_deepseek_api_key
GROK_API_KEY=your_grok_api_key
# Data Sources
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_key
QUANDL_API_KEY=your_quandl_keyfrom chrematai.config import Config
config = Config()
config.set_ai_provider("openai")
config.set_risk_level(0.05) # 5% risk level for VaR calculations
config.set_default_currency("USD")Run the test suite:
# Run all tests
pytest
# Run with coverage
pytest --cov=chrematai --cov-report=html
# Run specific test file
pytest tests/test_analyzer.pyWe welcome contributions! Please see our Contributing Guide for details.
-
Clone the repository:
git clone https://github.com/artaasd95/chrematai.git cd chrematai -
Create virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install development dependencies:
pip install -e ".[dev]" -
Run pre-commit hooks:
pre-commit install
This project uses:
- Black for code formatting
- isort for import sorting
- flake8 for linting
- mypy for type checking
Chrematai is optimized for performance with:
- Vectorized operations using NumPy
- Efficient data structures with Pandas
- Caching mechanisms for repeated calculations
- Parallel processing for large datasets
This project is licensed under the MIT License - see the LICENSE file for details.
- NumPy and Pandas for numerical computing
- OpenAI, DeepSeek, and Grok for AI capabilities
- SciPy for statistical functions
- The open-source financial community
- Documentation: https://artaasd95.github.io/chrematai/
- Issues: GitHub Issues
- Discussions: GitHub Discussions
