Loading...
Loading...
Guidance for implementing high-performance portfolio optimization using Python C extensions. This skill applies when tasks require optimizing financial computations (matrix operations, covariance calculations, portfolio risk metrics) by implementing C extensions for Python. Use when performance speedup requirements exist (e.g., 1.2x or greater) and the task involves numerical computations on large datasets (thousands of assets).
npx skill4agent add letta-ai/skills portfolio-optimizationPython.hnumpy/arrayobject.himport_array()PyArray_DATA()PyArray_DIM()PyArray_STRIDE()PyArray_IS_C_CONTIGUOUS()NPY_FLOAT64import_array()PyErr_SetString()# Build the C extension
python setup.py build_ext --inplace
# Run correctness tests
python -c "from portfolio_optimized import *; # test calls"
# Run benchmark
python benchmark.py
# Run full test suite
pytest test_portfolio.py -v