
Use comment-driven generation to create initial scaffolding quickly, but manually verify validation, edge cases, and algorithmic details afterwards.
What this example includes (quick overview)
Full example: implementation (main.py)
The following consolidated example demonstrates a realistic scaffold that you might generate from well-formed comments. It keeps type hints, validation logic, and a stock-data processing method suitable for prototyping.Example unit tests (test_main.py)
Below is a compact pytest-based test module that checks structure and some basic expectations of the stock-processing pipeline and the trading parameter validator. Generated tests often focus on structure and obvious edge cases; review and extend them for numerical correctness and domain-specific behavior.Generated code and tests are a starting point. Always inspect generated logic for correctness, numeric stability, and security issues before using in production.
Best practices for comment-driven generation
- Write clear, concise comments describing the intended behavior and edge cases you care about (input shapes, allowed ranges, failure modes).
- Use generated code to scaffold structure and tests, but prioritize manual reviews for:
- Validation logic (types and ranges)
- Numerical stability (rolling windows, NaN handling, outlier treatment)
- Performance-critical loops or IO
- Create targeted unit tests that assert domain-specific numerical expectations in addition to structural checks.
- Document assumptions directly in code docstrings so generated tests can pick up on them.
Links and references
- pandas documentation: https://pandas.pydata.org/docs/
- numpy documentation: https://numpy.org/doc/
- pytest documentation: https://docs.pytest.org/