Models¶
composer
¶
Composer API Client.
ApplySubscription
¶
Asset
¶
Bases: BaseNode
A ticker/asset node representing a security to trade.
Source code in composer/models/common/symphony.py
BacktestExistingSymphonyRequest
¶
Bases: BacktestParams
Backtest request for an existing saved symphony.
Use this when backtesting a symphony that has already been saved. The symphony_id is provided in the URL path, not the request body.
Source code in composer/models/backtest/requests.py
BacktestRequest
¶
Bases: BacktestParams
Full backtest request with symphony definition.
Use this when backtesting a new symphony by providing the full symphony definition in the request body.
Source code in composer/models/backtest/requests.py
BacktestResult
¶
Bases: BaseModel
Complete backtest result.
This is the main response model returned by both backtest endpoints: - POST /api/v0.1/backtest (backtest by definition) - POST /api/v0.1/symphonies/{symphony-id}/backtest (backtest existing symphony)
Contains performance metrics, holdings history, costs, and statistics.
Source code in composer/models/backtest/responses.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
__repr__()
¶
Return string representation of BacktestResult.
Source code in composer/models/backtest/responses.py
__str__()
¶
transform_dvm_capital(v)
classmethod
¶
Transform dvm_capital field to date-indexed dict.
Source code in composer/models/backtest/responses.py
transform_first_day(v)
classmethod
¶
Transform first_day from epoch to date string.
transform_last_market_day(v)
classmethod
¶
Transform last_market_day from epoch to date string.
Source code in composer/models/backtest/responses.py
transform_rebalance_days(v)
classmethod
¶
Transform rebalance_days from epochs to date strings.
Source code in composer/models/backtest/responses.py
transform_tdvm_weights(v)
classmethod
¶
Transform tdvm_weights field to date-indexed dict.
Source code in composer/models/backtest/responses.py
BacktestVersion
¶
BaseNode
¶
Bases: BaseModel
Base class for all symphony nodes.
Source code in composer/models/common/symphony.py
model_dump(**kwargs)
¶
Override model_dump to exclude None values by default.
model_dump_json(**kwargs)
¶
Override model_dump_json to exclude None values by default.
parse_children()
¶
validate_id(v)
classmethod
¶
Ensure ID is a valid UUID. If not, auto-generate one.
Source code in composer/models/common/symphony.py
BenchmarkStats
¶
Bases: BaseModel
Statistics for a benchmark comparison.
Source code in composer/models/common/stats.py
Broker
¶
ComposerClient
¶
Main client for interacting with the Composer API.
This client provides access to various Composer API resources including backtest, market data, trading, portfolio management, and more.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
The API Key ID |
required |
api_secret
|
str
|
The API Secret Key |
required |
timeout
|
float
|
Request timeout in seconds (default: 30.0) |
30.0
|
retry_config
|
RetryConfig | None
|
Configuration for retry behavior (default: 3 retries, 10s for 429, 3s for 5xx) |
_DEFAULT_RETRY_CONFIG
|
Source code in composer/client.py
__init__(api_key, api_secret, timeout=30.0, retry_config=_DEFAULT_RETRY_CONFIG)
¶
Initialize the Composer Client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
The API Key ID |
required |
api_secret
|
str
|
The API Secret Key |
required |
timeout
|
float
|
Request timeout in seconds (default: 30.0) |
30.0
|
retry_config
|
RetryConfig | None
|
Configuration for retry behavior. Pass None to disable retries (default: RetryConfig()) |
_DEFAULT_RETRY_CONFIG
|
Source code in composer/client.py
Costs
¶
Bases: BaseModel
Fee and cost breakdown from a backtest.
Shows all the costs incurred during the backtest including regulatory fees, TAF fees, slippage, spread markup, and subscription costs.
Source code in composer/models/backtest/responses.py
DataWarning
¶
Bases: BaseModel
Data quality warning for a specific ticker.
Source code in composer/models/backtest/responses.py
Empty
¶
Filter
¶
Bases: BaseNode
Filter node for selecting top/bottom N assets.
Source code in composer/models/common/symphony.py
Function
¶
Bases: StrEnum
Mathematical and technical analysis functions available for conditions and filters.
Source code in composer/models/common/symphony.py
Group
¶
Bases: BaseNode
Group node containing a single weight strategy.
Source code in composer/models/common/symphony.py
validate_single_child(v)
classmethod
¶
Validate that group has exactly one child.
If
¶
Bases: BaseNode
If/Else conditional node.
Source code in composer/models/common/symphony.py
validate_if_children(v)
classmethod
¶
Ensure If node has exactly one true and one false child.
Source code in composer/models/common/symphony.py
IfChildFalse
¶
Bases: BaseNode
The 'false' (else) branch of an If condition.
Source code in composer/models/common/symphony.py
IfChildTrue
¶
Bases: BaseNode
The 'true' branch of an If condition.
Source code in composer/models/common/symphony.py
Quote
¶
Bases: BaseModel
Quote for a single ticker in rebalance.
Source code in composer/models/backtest/requests.py
RebalanceFrequency
¶
Bases: StrEnum
How often the symphony should rebalance its holdings.
Source code in composer/models/common/symphony.py
RebalanceRequest
¶
Bases: BaseModel
Request body for the rebalance endpoint.
Used to run a rebalance for specified symphonies given a starting state.
Source code in composer/models/backtest/requests.py
RebalanceResult
¶
Bases: BaseModel
Result from a rebalance request.
Contains quotes, fractionability info, and run results for each symphony.
Source code in composer/models/backtest/responses.py
RecommendedTrade
¶
Bases: BaseModel
A recommended trade in a dry run or preview.
Source code in composer/models/dry_run/__init__.py
RegressionMetrics
¶
Bases: BaseModel
Regression metrics for benchmark comparison (alpha, beta, etc.).
Source code in composer/models/common/stats.py
RetryConfig
¶
Bases: BaseModel
Configuration for retry behavior.
Source code in composer/http_client.py
Stats
¶
Bases: BaseModel
Performance statistics for portfolios, backtests, and symphonies.
Contains all key performance metrics like Sharpe ratio, cumulative return, max drawdown, and various trailing returns.
Source code in composer/models/common/stats.py
Config
¶
__repr__()
¶
Return string representation of Stats.
Source code in composer/models/common/stats.py
SymphonyDefinition
¶
Bases: BaseNode
Definition of a symphony/strategy.
Source code in composer/models/common/symphony.py
parse_children()
¶
Recursively parse children dicts into typed models.
validate_corridor_width(v, info)
classmethod
¶
Corridor width only allowed when rebalance is 'none'.
Source code in composer/models/common/symphony.py
validate_single_child(v)
classmethod
¶
SymphonyDefinition must have exactly one weight child.
Source code in composer/models/common/symphony.py
SymphonyRebalanceState
¶
Bases: BaseModel
State of a single symphony for rebalance.
Source code in composer/models/backtest/requests.py
SymphonyRunResult
¶
Bases: BaseModel
Result of running a single symphony during rebalance.
Source code in composer/models/backtest/responses.py
UpdateSymphonyNodesResponse
¶
Bases: BaseModel
Response from updating symphony nodes.
Source code in composer/models/symphony/__init__.py
UpdateSymphonyResponse
¶
Bases: BaseModel
Response from updating a symphony.
Source code in composer/models/symphony/__init__.py
WeightCashEqual
¶
Bases: BaseNode
Equal weighting across all children.
Source code in composer/models/common/symphony.py
WeightCashSpecified
¶
Bases: BaseNode
Specified weighting with explicit weights.
Source code in composer/models/common/symphony.py
WeightInverseVol
¶
WeightMap
¶
Bases: BaseModel
Weight fraction represented as numerator/denominator.
Examples¶
- 50% = num: 50, den: 100
- 33.3% = num: 33.3, den: 100
Source code in composer/models/common/symphony.py
validate_positive(v)
classmethod
¶
Ensure weight values are non-negative.
Source code in composer/models/common/symphony.py
validate_symphony_score(score)
¶
Validate a symphony score and check crypto rebalancing rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
score
|
SymphonyDefinition | dict
|
Symphony score as SymphonyDefinition model or dict |
required |
Returns¶
Validated SymphonyDefinition model