forge.signals
Forge API 1
What ``compute()`` returns: ``fg.Signals``, and named conditions built with ``fg.all_of``.
``compute(self, d)`` gives Forge whole arrays of entry and exit conditions. Forge turns them into orders without calling Python on every bar. Entry and exit fields are True/False numpy arrays the length of the strategy's bars, or condition trees whose names are kept so a bar can say which conditions were true.
| Name | Kind | Summary |
|---|---|---|
| AddOn | class | Add to a position that moved in its favour: ``fg.AddOn(every_pips=20, size_mult=0.5)``. |
| Bracket | function | An entry order with its stop and its target: ``fg.Bracket(entry, sl, tp)``. |
| BreakEven | class | Move the stop to the entry price once the trade is ahead: ``fg.BreakEven(at_r=1.0)``. |
| Caps | class | The most a strategy may hold or risk: ``fg.Caps(max_lots=2, max_positions=3)``. |
| Entry | class | How entries are placed: ``fg.Entry.market``, ``limit``, ``stop`` or ``stop_limit``. |
| Exit | class | The ways to close trades together or by time: ``fg.Exit.basket``. |
| Filter | class | Filters for ``fg.Signals(filters=[...])`` and the class attribute ``filters``: where not to trade. |
| Order | class | The orders ``ctx.order`` takes: ``fg.Order.market``, ``limit``, ``stop`` and ``stop_limit``. |
| Plot | class | A named series for ``fg.Signals(plots=...)`` with a style and a pane. |
| Region | class | A stretch of bars to shade on the chart: ``fg.Region(start, end, label="news")``. |
| Signals | class | What ``compute()`` returns: entry and exit conditions, and named series to plot or record. |
| Size | class | How much each entry trades. |
| Stop | class | Where a losing trade is closed. |
| Target | class | Where a winning trade is closed. |
| Targets | class | Several targets that each close a part of the trade: ``fg.Targets([(0.5, t1), (0.5, t2)])``. |
| TimeStop | class | Close a trade that has been open too long: ``fg.TimeStop(bars=48)`` or ``duration="2d"``. |
| Trail | class | A stop that follows the price. |
| all_of | function | True on a bar where every named condition is true. |
| any_of | function | True on a bar where at least one named condition is true. |
| armed | function | True from a bar where ``set_when`` is true until a bar where ``reset_when`` is, that bar excluded. |
| bars_since | function | For each bar, how many bars ago the condition was last true: 0 on a bar where it is true, and -1 before the first time it is. |
| count | function | The number of bars among this bar and the ``over - 1`` before it where the condition is true. |
| count_true | function | How many of this bar and the ``bars - 1`` before it the condition was true on, as whole numbers. |
| held | function | True where the condition was true on this bar and on each of the ``bars - 1`` before it. |
| n_of | function | True on a bar where at least ``k`` of the named conditions are true. |
| none_of | function | True on a bar where none of the named conditions is true. |
| since | function | True where the bars since the condition was last true compare with ``bars`` by ``op`` (``"<"``, ``"<="``, ``">"``, ``">="``, ``"=="`` or ``"!="``), and False on every bar before the first time it was true, whatever the comparison: there is no count yet to compare, as a missing value compares nowhere. |
| then | function | True where ``second`` becomes true, if ``first`` became true 1 to ``within`` bars earlier. |
| vote | function | True from the bar the weighted share of true conditions reaches ``open_at`` percent until the bar it falls to ``close_at`` percent or below. |
| within | function | True where the condition was true on this bar or one of the ``bars - 1`` before it. |