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.

NameKindSummary
EngineNotInstalledexceptionA check needs Forge's engine, and this installation does not include it.
INSTRUMENT_CLASSESconstant
STABLE_TRADE_FIELDSconstant
SampleBarsclassA set of bars for tests, with the facts of the instrument they imitate.
TestRunclassOne finished run in a test.
assert_entry_atfunctionAn entry was filled on primary bar ``bar``, on the ``side`` given when there is one.
assert_exit_atfunctionAn exit was filled on primary bar ``bar``, closing a position of ``side`` and for ``reason``.
assert_no_lookaheadfunctionFail unless the look-ahead audit shows no evidence of look-ahead.
assert_no_trade_betweenfunctionNo entry was filled from ``start`` to ``end``, both included.
assert_ready_to_publishfunctionFail unless every row of the pre-publish battery passes, naming each row that did not.
assert_same_tradesfunctionThe two runs made the same trades, compared one by one in entry-time order.
assert_stable_warmupfunctionFail unless every output of the strategy is stable at its declared warm-up.
broker_factsfunctionThe ``oathra.broker_facts/1`` payload a run receives, for the sample ``symbols``.
check_lookaheadfunctionAudit a strategy for look-ahead and return the report as plain JSON.
check_warmupfunctionMeasure how much each output of a strategy depends on where its data starts, as plain JSON.
instrumentfunctionA copy of the sample facts of ``symbol``: ``EURUSD``, ``GBPUSD``, ``USDJPY``, ``US500`` or ``XAUUSD``.
publish_checkfunctionRun the pre-publish battery on a strategy file and return its report as plain JSON.
runfunctionRun a strategy over sample bars and return what it did.
snapshotfunctionCompare a run, or a mapping of numbers, with the snapshot stored for this test.
stable_fieldsfunctionThe fields a run's snapshot keeps, by section, in the order the snapshot writes them.
syntheticfunctionA seeded synthetic sample.
to_snapshotfunctionA run, or a mapping of numbers, text, lists and mappings, as the plain structure a snapshot stores.