Ta4j Wiki

Documentation, examples and further information of the ta4j project

View the Wiki On GitHub

This project is maintained by ta4j Organization

Perpetual Futures

Use this page when you want to model or record perpetual futures with ta4j’s existing trading APIs.

Requires ta4j 0.28.1 or later. The supporting core changes are pending human merge; see the funding, sizing, return on capital, examples, and recorded holding costs PRs before using these APIs.

1) A perpetual in one minute

A perpetual future is a derivative with no expiry. Like spot, its linear price change times base-asset amount determines gross profit; unlike unlevered spot, a trader can use leverage and pays or receives periodic funding. Leverage increases exposure and loss as well as potential profit. Funding is a signed holding cost, not an entry fee.

Your goal Start here
Run a small offline example Quickstart
Model real historical data and risk Backtesting
Record venue fills and settlements Live trading
Adapt a particular technique Cookbook

2) Concepts and APIs

Concept ta4j API
Linear notional Price times amount in base units
Fees LinearTransactionCostModel; actual fill fees use RecordedTradeCostModel
Funding FundingCostModel as a holding cost; recorded settlements via TradingRecord.recordHoldingCost
Leverage and lot step PositionSizer.balance(...).leveraged(...).roundedDownTo(...)
Return on committed capital ReturnOnCapitalCriterion
Approximate liquidation threshold StopLossRule combined with the strategy exit
flowchart LR
    Bars[Price and funding bars] --> Model[Fees, funding and sizing]
    Model --> Manager[BarSeriesManager]
    Manager --> Record[Trading record]
    Fills[Venue fills and settlements] --> Record
    Record --> Metrics[Net profit and return on capital]

3) Boundaries

ta4j does not provide a contract metadata type, margin account, cross-margin engine, exchange liquidation fills, or native inverse/quanto valuation here. Convert contract sizes in your adapter, supply venue data yourself, and use a stop only as an approximation. An inverse contract can be represented using reciprocal prices; see Backtesting.

4) Glossary