"""
Basic Usage Example - Quantfolio
Demonstrates simple portfolio optimization
"""

import quantfolio as qf

def main():
    print("=" * 60)
    print("QUANTFOLIO - BASIC USAGE EXAMPLE")
    print("=" * 60)
    
    # Define portfolio
    tickers = ['AAPL', 'MSFT', 'GOOGL', 'AMZN']
    
    print(f"\nOptimizing portfolio: {', '.join(tickers)}")
    
    # 1. Simple quantum optimization
    print("\n1. Quantum Optimization (QAOA)")
    print("-" * 60)
    
    optimizer = qf.HybridOptimizer(
        tickers=tickers,
        method='quantum',
        risk_aversion=0.5
    )
    
    result = optimizer.optimize()
    
    print("\nOptimal Portfolio Weights:")
    for ticker, weight in zip(tickers, result['weights']):
        print(f"  {ticker}: {weight*100:.1f}%")
    
    print(f"\nExpected Return: {result['expected_return']*100:.2f}%")
    print(f"Risk (Volatility): {result['risk']*100:.2f}%")
    print(f"Sharpe Ratio: {result['sharpe_ratio']:.2f}")
    
    # 2. Classical optimization
    print("\n\n2. Classical Optimization (Markowitz)")
    print("-" * 60)
    
    optimizer_classical = qf.HybridOptimizer(
        tickers=tickers,
        method='classical',
        risk_aversion=0.5
    )
    
    result_classical = optimizer_classical.optimize()
    
    print("\nOptimal Portfolio Weights:")
    for ticker, weight in zip(tickers, result_classical['weights']):
        print(f"  {ticker}: {weight*100:.1f}%")
    
    # 3. Visualizations
    print("\n\n3. Visualizations")
    print("-" * 60)
    
    try:
        optimizer.plot_weights()
        optimizer.plot_efficient_frontier()
        print("✓ Plots generated successfully!")
    except Exception as e:
        print(f"Note: Plotting requires display: {e}")
    
    print("\n" + "=" * 60)
    print("✓ Example completed successfully!")
    print("=" * 60)


if __name__ == '__main__':
    main()
