forge.testing
Forge API 1
The Forge developer test kit.
Fixture bars, a test harness, snapshots, the look-ahead and warm-up checks and a linter, all runnable from ordinary pytest on your own machine. The sample prices are Forge's own synthetic prices, named after the instrument they imitate: checks on them say "Checked on Forge's sample prices." and never claim to be real market data.
Indicators have their own kit, ``forge.testing.indicator``, imported by name.
A function that runs Forge's engine raises ``EngineNotInstalled`` where the engine is absent, such as a package installed on its own.
| Name | Kind | Summary |
|---|---|---|
| EngineNotInstalled | exception | A check needs Forge's engine, and this installation does not include it. |
| INSTRUMENT_CLASSES | constant | |
| STABLE_TRADE_FIELDS | constant | |
| SampleBars | class | A set of bars for tests, with the facts of the instrument they imitate. |
| TestRun | class | One finished run in a test. |
| assert_entry_at | function | An entry was filled on primary bar ``bar``, on the ``side`` given when there is one. |
| assert_exit_at | function | An exit was filled on primary bar ``bar``, closing a position of ``side`` and for ``reason``. |
| assert_no_lookahead | function | Fail unless the look-ahead audit shows no evidence of look-ahead. |
| assert_no_trade_between | function | No entry was filled from ``start`` to ``end``, both included. |
| assert_ready_to_publish | function | Fail unless every row of the pre-publish battery passes, naming each row that did not. |
| assert_same_trades | function | The two runs made the same trades, compared one by one in entry-time order. |
| assert_stable_warmup | function | Fail unless every output of the strategy is stable at its declared warm-up. |
| broker_facts | function | The ``oathra.broker_facts/1`` payload a run receives, for the sample ``symbols``. |
| check_lookahead | function | Audit a strategy for look-ahead and return the report as plain JSON. |
| check_warmup | function | Measure how much each output of a strategy depends on where its data starts, as plain JSON. |
| instrument | function | A copy of the sample facts of ``symbol``: ``EURUSD``, ``GBPUSD``, ``USDJPY``, ``US500`` or ``XAUUSD``. |
| publish_check | function | Run the pre-publish battery on a strategy file and return its report as plain JSON. |
| run | function | Run a strategy over sample bars and return what it did. |
| snapshot | function | Compare a run, or a mapping of numbers, with the snapshot stored for this test. |
| stable_fields | function | The fields a run's snapshot keeps, by section, in the order the snapshot writes them. |
| synthetic | function | A seeded synthetic sample. |
| to_snapshot | function | A run, or a mapping of numbers, text, lists and mappings, as the plain structure a snapshot stores. |