Python API reference / 2.2.1

Command-line entry points

Try it in Python

Call the command-line interface from a Python script and check its exit status.

from pricegenerator.cli import Main

status = Main(["generate", "--seed", "42", "--horizon", "24", "--output", "sample.csv"])
assert status == 0

pricegenerator.cli

Run the same generation, replay, validation, analysis, comparison, charting and Monte Carlo commands as python -m pricegenerator. Pass a list of command-line arguments to call them from Python.

Main

Run one CLI command from a Python argument list, starting with the subcommand name. For example, ["chart", "bars.csv", "--analysis", "--output", "chart.html", "--no-view"] creates an HTML chart with switchable indicators. Successful execution returns 0. Argparse exits with status 2 for invalid arguments and expected input or I/O errors.

Main(argv: list[str] | None = None) -> int
Parameters (1)
argv
List of argument strings, starting with the subcommand. Pass None to read the process command line.

Source ↗

pricegenerator.rendering.__main__

Use python -m pricegenerator.rendering to chart a price CSV. This entry point accepts the arguments of the chart subcommand.

Main

Run the chart subcommand from Python. Start the argument list with the input CSV path and omit the word chart. Returns 0 on success and uses the same argument handling as cli.Main.

Main(argv: list[str] | None = None) -> int
Parameters (1)
argv
Chart arguments starting with the input CSV path. Omit the subcommand name. None reads the process command line.

Source ↗