# Models

## The RuleCreateRequest object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"RuleCreateRequest":{"type":"object","required":["data"],"properties":{"name":{"type":"string","description":"Optional human-readable name for the rule."},"trigger":{"type":"object","description":"Trigger settings that determine how/when the rule is activated.","properties":{"type":{"type":"string","enum":["time","event","direct_order"],"description":"The type of trigger that starts the rule execution."},"schedule":{"type":"object","description":"Scheduling parameters for time-based triggers (if trigger type is 'time').","properties":{"start":{"type":"string","format":"date-time","description":"Start date-time for the first execution (ISO 8601 format)."},"interval":{"type":"object","description":"Interval between executions for recurring rules.","properties":{"unit":{"type":"string","enum":["minutes","hours","days"],"description":"Time unit for the interval."},"value":{"type":"integer","description":"Interval value in the given unit."}}},"repeatCount":{"type":"integer","description":"Number of times to execute the rule (after which it stops). If absent or large, the rule continues until manually stopped."},"minInterval":{"type":"string","description":"Minimum time gap between consecutive executions (to prevent overly frequent triggers). For example, '1 day'."}}}}},"data":{"type":"object","description":"Rule definition, including sequences of conditions/operators/actions.","properties":{"sequences":{"type":"array","description":"Ordered list of rule sequence blocks that define the logic of the rule. \nA rule is typically composed of:\n - **CONDITION blocks** (optional): define if/when an action should execute (market conditions, price triggers, etc.).\n - **OPERATOR blocks** (optional): connect multiple conditions or actions (e.g., THEN, OR, WAIT, DO_NOT, PARALLEL).\n - **ACTION blocks**: define the actions to execute (trades or notifications).\nThe sequence should generally start with a CONDITION (or a time trigger specified above) and end with one or more ACTIONs. \nOperators can chain multiple conditions and actions in complex ways.\n","items":{"oneOf":[{"$ref":"#/components/schemas/ConditionSequence"},{"$ref":"#/components/schemas/OperatorSequence"},{"$ref":"#/components/schemas/ActionSequence"}]}}}},"timestamp":{"type":"string","format":"date-time","description":"Client timestamp of when the rule is created, in ISO 8601 format. This can be used for request auditing or to schedule relative triggers (optional)."}}},"ConditionSequence":{"type":"object","properties":{"t":{"type":"string","enum":["CONDITION"],"description":"Indicates this is a condition sequence block."},"d":{"type":"object","required":["co","c"],"properties":{"co":{"type":"string","enum":["and","or","and_not"],"description":"Logical operator for combining multiple conditions in this block:\n  - **and**: All conditions must be true.\n  - **or**: At least one condition is true.\n  - **and_not** (but_not): All conditions are true and none of a certain subset are true (used for \"and not\" logic).\n"},"c":{"type":"array","description":"List of individual condition definitions within this block.","items":{"type":"object","required":["ct"],"properties":{"ct":{"type":"string","enum":["symbol","bundle","that_coin","any_coin","any_leveraged_token","any_my_coin","from_sequence","rule_in_profit","rule_in_loss","tradingview_signal","custom_signal","api_signal","best_market","worst_market","best_mine","worst_mine"],"description":"The type of condition to evaluate. Examples:\n  - **symbol**: A specific market/coin condition (e.g., price or indicator of a specific coin).\n  - **bundle**: Condition on a predefined bundle of assets.\n  - **that_coin**: Refers to \"the coin\" from a previous condition (used in multi-step rules).\n  - **any_coin**: Any coin meets the condition (on a given exchange or list).\n  - **any_leveraged_token**: Any leveraged token meets the condition.\n  - **any_my_coin**: Any coin in the user's portfolio meets the condition.\n  - **from_sequence**: Reuse output from a prior sequence as a condition.\n  - **rule_in_profit** / **rule_in_loss**: Another rule's performance triggers this (profit or loss).\n  - **tradingview_signal**: Trigger from a TradingView signal.\n  - **custom_signal**: Trigger from a custom user-defined signal.\n  - **api_signal**: Trigger from an external API signal.\n  - **best_market** / **worst_market**: The best or worst performing market (usually within a set) meets some criteria.\n  - **best_mine** / **worst_mine**: The best or worst performing asset in the user's own portfolio meets criteria.\n"},"symbol":{"type":"string","description":"If the condition type involves a specific asset or market (e.g., ct = 'symbol'), this field is the symbol or market identifier (e.g., \"ETH\" or \"ETH/USDC\")."},"indicator":{"type":"string","description":"The indicator or metric to check (e.g., \"price\", \"volume\", \"moving_average\"). Applicable for ct types that require an indicator (like 'symbol' or performance conditions)."},"operator":{"type":"string","enum":["lte","gte","above","below","inc","dec"],"description":"The comparison operator or trigger type:\n  - **lte**: less than or equal to (<=)\n  - **gte**: greater than or equal to (>=)\n  - **above**: crosses above a certain value\n  - **below**: crosses below a certain value\n  - **inc**: increases by a certain amount or percentage\n  - **dec**: decreases by a certain amount or percentage\n"},"value":{"type":"string","description":"The value to compare the indicator against (as a string). This could be an absolute number or a percentage, depending on context (e.g., \"5%\" for inc/dec or a price level like \"2000\")."},"within":{"type":"string","enum":["current_price","delta","action_price","trailing"],"description":"*(Optional)* Context for the condition, mainly used with `inc`/`dec` or time-based indicators:\n  - **current_price**: Compare with the current price (default for price conditions).\n  - **delta**: Evaluate over a candle period change (e.g., price delta over a period).\n  - **action_price**: Compare against the price at which a previous action was executed.\n  - **trailing**: Use a trailing value (for trailing stop or similar conditions).\n"}}}}}}}},"OperatorSequence":{"type":"object","properties":{"t":{"type":"string","enum":["OPERATOR"],"description":"Indicates this is an operator sequence block (linking conditions/actions)."},"d":{"type":"object","required":["do"],"properties":{"do":{"type":"string","enum":["then","do_not","wait","or","parallel"],"description":"The operator connecting to the next sequence:\n  - **then**: If the previous condition(s) are satisfied, then proceed to the next sequence block.\n  - **or**: If the previous condition block fails, switch to an alternative condition path (the next condition block after this operator).\n  - **wait**: Pause the rule execution; the next condition/action will execute only after a certain time or event passes.\n  - **do_not**: Exclusion operator – do not execute the next action for certain cases (e.g., exclude certain coins or scenarios).\n  - **parallel**: Execute multiple subsequent action blocks in parallel (simultaneously) rather than sequentially.\n"},"values":{"type":"string","enum":["_stablecoins","_samecoins","_anycoins","_samecoinsever","_fiatcoins","_openpositions","_nomcap"],"description":"*(Used if **do** = \"do_not\")* A predefined exclusion category indicating what to skip:\n - **_stablecoins**: Exclude stablecoins (do not apply actions to stablecoins).\n - **_samecoins**: Do not pick the same coin twice in a row.\n - **_anycoins**: Exclude all coins (this might be used to prevent any action if any coin condition triggered, effectively disabling action in certain cases).\n - **_samecoinsever**: Never pick the same coin more than once in the lifetime of the rule.\n - **_fiatcoins**: Exclude fiat currency assets.\n - **_openpositions**: Exclude assets that already have open positions.\n - **_nomcap**: Exclude coins that have no market cap (very low cap/unlisted coins).\n"},"waitOption":{"type":"string","enum":["once","for"],"description":"*(Used if **do** = \"wait\")* Mode of waiting:\n - **once**: Wait until the next scheduled trigger occurs (pause rule once).\n - **for**: Wait for a specific duration before proceeding.\n"},"duration":{"type":"string","description":"*(Used if waitOption = \"for\")* The duration to wait (e.g., \"1h\" for 1 hour, \"24h\" for 24 hours) before continuing to the next sequence.\n"}}}}},"ActionSequence":{"type":"object","properties":{"t":{"type":"string","enum":["ACTION"],"description":"Indicates this is an action sequence block."},"d":{"type":"object","required":["do"],"properties":{"do":{"type":"string","enum":["trade","notify"],"description":"The action to perform:\n  - **trade**: Execute a trade on the connected exchange/wallet.\n  - **notify**: Send a notification (e.g., email or Telegram alert).\n"},"ta":{"type":"object","required":["at","b","q","ot","ort","v"],"description":"Parameters for the trade action.","properties":{"at":{"type":"string","enum":["buy","sell"],"description":"Trade action type:\n  - **buy**: Buy the base asset(s) using the quote asset.\n  - **sell**: Sell the base asset(s) into the quote asset.\n"},"b":{"type":"array","items":{"type":"string"},"description":"List of base asset symbols to trade. Usually this is a single-element array (e.g. `[\"ETH\"]`), but multiple assets can be listed if the action should apply to several assets."},"q":{"type":"string","description":"Quote asset symbol (the asset used as payment in a buy, or the asset received in a sell, e.g. `\"USDC\"`)."},"ot":{"type":"string","enum":["market","limit","swap"],"description":"Order type for the trade:\n  - **market**: Execute at market price.\n  - **limit**: Place a limit order (at a specific price or better).\n  - **swap**: Execute via a DeFi swap/aggregator (typically used for DEX trades).\n"},"ort":{"type":"string","enum":["base","that_coin","best_market","worst_market","best_mine","worst_mine","from_sequence"],"description":"Target asset context for the trade:\n  - **base**: Use the asset(s) specified in `b` as the trade target.\n  - **that_coin**: Use the coin from the triggering condition (\"that coin\").\n  - **best_market**: Target the best-performing market identified in a prior condition.\n  - **worst_market**: Target the worst-performing market from a prior condition.\n  - **best_mine**: Target the best-performing asset in the user's portfolio (if determined by a prior analysis step).\n  - **worst_mine**: Target the worst-performing asset in the user's portfolio.\n  - **from_sequence**: Target an asset determined by an earlier sequence (the specifics depend on prior logic).\n"},"v":{"type":"object","required":["v","iv","s"],"description":"The trade amount or volume information.","properties":{"v":{"type":"string","description":"The numeric value of the trade amount (as string). This is typically the amount in terms of the currency `s`."},"iv":{"type":"string","description":"The initial specified value (usually the same as `v` unless the rule adjusts it)."},"s":{"type":"string","description":"The unit or currency of the amount. For example, `\"USD\"` if the value is in US dollars, or an asset symbol if the value is given in that asset."}}},"ls":{"type":"number","description":"*(Optional)* Limit order spread as a percentage. Used if `ot` = \"limit\" and no exact limit price is given, to determine how far from the current price to place the limit order.\nFor example, `0.5` means 0.5% above/below the current price (buy orders below current price, sell orders above).\nIf `ls` is 0 or not provided, a default spread (e.g., 0.5%) may be used.\n"},"maxgf":{"type":"string","description":"Maximum gas fee amount for the trade, in the smallest unit of the network's currency. \nFor example, on Ethereum this would be in Wei. This value ensures the trade will not execute if the network fee would exceed this amount.\n"},"maxgfinbasecurrency":{"type":"string","description":"The maximum gas fee expressed in the base/reference currency (e.g. \"0.2\" meaning $0.2 USD). This is for reference/clarity; the system may calculate `maxgf` from this."},"maxpi":{"type":"string","description":"*(Optional)* Maximum price impact allowed for the trade. If provided, the trade will not execute if the expected price impact exceeds this percentage. (Not typically used for simple market orders; more relevant for large swap orders.)\n"},"maxsl":{"type":"string","description":"Maximum slippage percentage allowed for the trade. For example, \"0.5\" for 0.5% slippage. The trade will fail if slippage exceeds this."},"sr":{"type":"string","nullable":true,"description":"*(Optional)* Stop rule or secondary reference for the trade. Typically not used (or null) for basic trades; can be used to link this trade with a condition to stop the rule or similar advanced logic.\n"}}},"channel":{"type":"string","enum":["telegram","email"],"description":"*(Required if do = notify)* The channel through which to send the notification.\n"},"message":{"type":"string","description":"*(Required if do = notify)* The content of the notification message to send.\n"},"timeframe":{"type":"string","enum":["instantly"],"description":"*(Optional, notify only)* When to send the notification. Currently, only \"instantly\" is supported (send immediately when rule triggers).\n"}}}}}}}}
```

## The ConditionSequence object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"ConditionSequence":{"type":"object","properties":{"t":{"type":"string","enum":["CONDITION"],"description":"Indicates this is a condition sequence block."},"d":{"type":"object","required":["co","c"],"properties":{"co":{"type":"string","enum":["and","or","and_not"],"description":"Logical operator for combining multiple conditions in this block:\n  - **and**: All conditions must be true.\n  - **or**: At least one condition is true.\n  - **and_not** (but_not): All conditions are true and none of a certain subset are true (used for \"and not\" logic).\n"},"c":{"type":"array","description":"List of individual condition definitions within this block.","items":{"type":"object","required":["ct"],"properties":{"ct":{"type":"string","enum":["symbol","bundle","that_coin","any_coin","any_leveraged_token","any_my_coin","from_sequence","rule_in_profit","rule_in_loss","tradingview_signal","custom_signal","api_signal","best_market","worst_market","best_mine","worst_mine"],"description":"The type of condition to evaluate. Examples:\n  - **symbol**: A specific market/coin condition (e.g., price or indicator of a specific coin).\n  - **bundle**: Condition on a predefined bundle of assets.\n  - **that_coin**: Refers to \"the coin\" from a previous condition (used in multi-step rules).\n  - **any_coin**: Any coin meets the condition (on a given exchange or list).\n  - **any_leveraged_token**: Any leveraged token meets the condition.\n  - **any_my_coin**: Any coin in the user's portfolio meets the condition.\n  - **from_sequence**: Reuse output from a prior sequence as a condition.\n  - **rule_in_profit** / **rule_in_loss**: Another rule's performance triggers this (profit or loss).\n  - **tradingview_signal**: Trigger from a TradingView signal.\n  - **custom_signal**: Trigger from a custom user-defined signal.\n  - **api_signal**: Trigger from an external API signal.\n  - **best_market** / **worst_market**: The best or worst performing market (usually within a set) meets some criteria.\n  - **best_mine** / **worst_mine**: The best or worst performing asset in the user's own portfolio meets criteria.\n"},"symbol":{"type":"string","description":"If the condition type involves a specific asset or market (e.g., ct = 'symbol'), this field is the symbol or market identifier (e.g., \"ETH\" or \"ETH/USDC\")."},"indicator":{"type":"string","description":"The indicator or metric to check (e.g., \"price\", \"volume\", \"moving_average\"). Applicable for ct types that require an indicator (like 'symbol' or performance conditions)."},"operator":{"type":"string","enum":["lte","gte","above","below","inc","dec"],"description":"The comparison operator or trigger type:\n  - **lte**: less than or equal to (<=)\n  - **gte**: greater than or equal to (>=)\n  - **above**: crosses above a certain value\n  - **below**: crosses below a certain value\n  - **inc**: increases by a certain amount or percentage\n  - **dec**: decreases by a certain amount or percentage\n"},"value":{"type":"string","description":"The value to compare the indicator against (as a string). This could be an absolute number or a percentage, depending on context (e.g., \"5%\" for inc/dec or a price level like \"2000\")."},"within":{"type":"string","enum":["current_price","delta","action_price","trailing"],"description":"*(Optional)* Context for the condition, mainly used with `inc`/`dec` or time-based indicators:\n  - **current_price**: Compare with the current price (default for price conditions).\n  - **delta**: Evaluate over a candle period change (e.g., price delta over a period).\n  - **action_price**: Compare against the price at which a previous action was executed.\n  - **trailing**: Use a trailing value (for trailing stop or similar conditions).\n"}}}}}}}}}}}
```

## The OperatorSequence object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"OperatorSequence":{"type":"object","properties":{"t":{"type":"string","enum":["OPERATOR"],"description":"Indicates this is an operator sequence block (linking conditions/actions)."},"d":{"type":"object","required":["do"],"properties":{"do":{"type":"string","enum":["then","do_not","wait","or","parallel"],"description":"The operator connecting to the next sequence:\n  - **then**: If the previous condition(s) are satisfied, then proceed to the next sequence block.\n  - **or**: If the previous condition block fails, switch to an alternative condition path (the next condition block after this operator).\n  - **wait**: Pause the rule execution; the next condition/action will execute only after a certain time or event passes.\n  - **do_not**: Exclusion operator – do not execute the next action for certain cases (e.g., exclude certain coins or scenarios).\n  - **parallel**: Execute multiple subsequent action blocks in parallel (simultaneously) rather than sequentially.\n"},"values":{"type":"string","enum":["_stablecoins","_samecoins","_anycoins","_samecoinsever","_fiatcoins","_openpositions","_nomcap"],"description":"*(Used if **do** = \"do_not\")* A predefined exclusion category indicating what to skip:\n - **_stablecoins**: Exclude stablecoins (do not apply actions to stablecoins).\n - **_samecoins**: Do not pick the same coin twice in a row.\n - **_anycoins**: Exclude all coins (this might be used to prevent any action if any coin condition triggered, effectively disabling action in certain cases).\n - **_samecoinsever**: Never pick the same coin more than once in the lifetime of the rule.\n - **_fiatcoins**: Exclude fiat currency assets.\n - **_openpositions**: Exclude assets that already have open positions.\n - **_nomcap**: Exclude coins that have no market cap (very low cap/unlisted coins).\n"},"waitOption":{"type":"string","enum":["once","for"],"description":"*(Used if **do** = \"wait\")* Mode of waiting:\n - **once**: Wait until the next scheduled trigger occurs (pause rule once).\n - **for**: Wait for a specific duration before proceeding.\n"},"duration":{"type":"string","description":"*(Used if waitOption = \"for\")* The duration to wait (e.g., \"1h\" for 1 hour, \"24h\" for 24 hours) before continuing to the next sequence.\n"}}}}}}}}
```

## The ActionSequence object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"ActionSequence":{"type":"object","properties":{"t":{"type":"string","enum":["ACTION"],"description":"Indicates this is an action sequence block."},"d":{"type":"object","required":["do"],"properties":{"do":{"type":"string","enum":["trade","notify"],"description":"The action to perform:\n  - **trade**: Execute a trade on the connected exchange/wallet.\n  - **notify**: Send a notification (e.g., email or Telegram alert).\n"},"ta":{"type":"object","required":["at","b","q","ot","ort","v"],"description":"Parameters for the trade action.","properties":{"at":{"type":"string","enum":["buy","sell"],"description":"Trade action type:\n  - **buy**: Buy the base asset(s) using the quote asset.\n  - **sell**: Sell the base asset(s) into the quote asset.\n"},"b":{"type":"array","items":{"type":"string"},"description":"List of base asset symbols to trade. Usually this is a single-element array (e.g. `[\"ETH\"]`), but multiple assets can be listed if the action should apply to several assets."},"q":{"type":"string","description":"Quote asset symbol (the asset used as payment in a buy, or the asset received in a sell, e.g. `\"USDC\"`)."},"ot":{"type":"string","enum":["market","limit","swap"],"description":"Order type for the trade:\n  - **market**: Execute at market price.\n  - **limit**: Place a limit order (at a specific price or better).\n  - **swap**: Execute via a DeFi swap/aggregator (typically used for DEX trades).\n"},"ort":{"type":"string","enum":["base","that_coin","best_market","worst_market","best_mine","worst_mine","from_sequence"],"description":"Target asset context for the trade:\n  - **base**: Use the asset(s) specified in `b` as the trade target.\n  - **that_coin**: Use the coin from the triggering condition (\"that coin\").\n  - **best_market**: Target the best-performing market identified in a prior condition.\n  - **worst_market**: Target the worst-performing market from a prior condition.\n  - **best_mine**: Target the best-performing asset in the user's portfolio (if determined by a prior analysis step).\n  - **worst_mine**: Target the worst-performing asset in the user's portfolio.\n  - **from_sequence**: Target an asset determined by an earlier sequence (the specifics depend on prior logic).\n"},"v":{"type":"object","required":["v","iv","s"],"description":"The trade amount or volume information.","properties":{"v":{"type":"string","description":"The numeric value of the trade amount (as string). This is typically the amount in terms of the currency `s`."},"iv":{"type":"string","description":"The initial specified value (usually the same as `v` unless the rule adjusts it)."},"s":{"type":"string","description":"The unit or currency of the amount. For example, `\"USD\"` if the value is in US dollars, or an asset symbol if the value is given in that asset."}}},"ls":{"type":"number","description":"*(Optional)* Limit order spread as a percentage. Used if `ot` = \"limit\" and no exact limit price is given, to determine how far from the current price to place the limit order.\nFor example, `0.5` means 0.5% above/below the current price (buy orders below current price, sell orders above).\nIf `ls` is 0 or not provided, a default spread (e.g., 0.5%) may be used.\n"},"maxgf":{"type":"string","description":"Maximum gas fee amount for the trade, in the smallest unit of the network's currency. \nFor example, on Ethereum this would be in Wei. This value ensures the trade will not execute if the network fee would exceed this amount.\n"},"maxgfinbasecurrency":{"type":"string","description":"The maximum gas fee expressed in the base/reference currency (e.g. \"0.2\" meaning $0.2 USD). This is for reference/clarity; the system may calculate `maxgf` from this."},"maxpi":{"type":"string","description":"*(Optional)* Maximum price impact allowed for the trade. If provided, the trade will not execute if the expected price impact exceeds this percentage. (Not typically used for simple market orders; more relevant for large swap orders.)\n"},"maxsl":{"type":"string","description":"Maximum slippage percentage allowed for the trade. For example, \"0.5\" for 0.5% slippage. The trade will fail if slippage exceeds this."},"sr":{"type":"string","nullable":true,"description":"*(Optional)* Stop rule or secondary reference for the trade. Typically not used (or null) for basic trades; can be used to link this trade with a condition to stop the rule or similar advanced logic.\n"}}},"channel":{"type":"string","enum":["telegram","email"],"description":"*(Required if do = notify)* The channel through which to send the notification.\n"},"message":{"type":"string","description":"*(Required if do = notify)* The content of the notification message to send.\n"},"timeframe":{"type":"string","enum":["instantly"],"description":"*(Optional, notify only)* When to send the notification. Currently, only \"instantly\" is supported (send immediately when rule triggers).\n"}}}}}}}}
```

## The Trade object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"Trade":{"type":"object","description":"Details of an executed trade (result of a rule's action).","properties":{"id":{"type":"string","description":"Unique identifier of the trade (assigned by Coinrule)."},"owner":{"type":"string","description":"Identifier of the user on whose account this trade occurred (e.g., user ID or wallet address)."},"exchange":{"type":"string","description":"Identifier of the exchange or trading venue where the trade was executed."},"uid":{"type":"string","description":"External order ID or transaction ID (from the exchange or network) for this trade."},"type":{"type":"string","enum":["rule","ondemand"],"description":"Trade execution type. `\"rule\"` indicates the trade was executed as part of an automated rule; `\"ondemand\"` indicates a one-off manual trade."},"ruleId":{"type":"string","description":"If `type` = \"rule\", this is the ID of the rule that triggered the trade."},"status":{"type":"string","enum":["new","partfilled","filled","canceled","rejected","expired","unknown"],"description":"Current status of the order/trade:\n  - **new**: The order is placed/initialized.\n  - **partfilled**: The order is partially filled.\n  - **filled**: The order has been completely filled.\n  - **canceled**: The order was canceled.\n  - **rejected**: The order was rejected by the exchange.\n  - **expired**: The order expired (e.g., a limit order that was not filled in time).\n  - **unknown**: The status is not confirmed or is unknown.\n"},"base":{"type":"string","description":"Base asset symbol that was bought or sold (e.g., `\"ETH\"`)."},"quote":{"type":"string","description":"Quote asset symbol used in the trade (e.g., `\"USDC\"`)."},"symbol":{"type":"string","description":"Trading pair symbol or market identifier (e.g., `\"ETHUSDC\"` or similar)."},"orderSide":{"type":"string","enum":["buy","sell"],"description":"Side of the order – \"buy\" or \"sell\"."},"orderType":{"type":"string","enum":["limit","market","swap"],"description":"Type of order that was executed (market order, limit order, or swap)."},"orderQuantity":{"type":"string","description":"Quantity of the base asset in the order (as a decimal string)."},"orderDetails":{"type":"object","description":"Raw order details object sent to the exchange (structure varies by exchange/API)."},"tradeDetails":{"type":"object","description":"Raw data received from the exchange after execution (filled order details, etc.)."},"txHash":{"type":"string","description":"Transaction hash (if this trade was on a blockchain/DEX and resulted in a transaction)."},"fills":{"type":"array","description":"List of individual fills (partial executions) for this order (if an order was filled in multiple parts).","items":{"$ref":"#/components/schemas/Fill"}},"totalBought":{"$ref":"#/components/schemas/AssetAmount"},"totalSold":{"$ref":"#/components/schemas/AssetAmount"},"totalExfee":{"type":"array","description":"Total exchange fee paid, possibly broken down by asset (if fees are paid in multiple assets).","items":{"$ref":"#/components/schemas/AssetAmount"}},"runtimeDataHistory":{"type":"array","description":"Historical data of relevant indicators/conditions at runtime leading up to this trade (for advanced analysis or debugging).","items":{"$ref":"#/components/schemas/RuntimeDataHistory"}},"speedStats":{"$ref":"#/components/schemas/SpeedStats"},"priceValues":{"type":"array","description":"Snapshot of price values of relevant assets (including base and quote) at the time of trade execution (for calculating portfolio impact).","items":{"$ref":"#/components/schemas/AssetAmount"}},"tradeValues":{"type":"array","description":"The monetary value of the trade in various reference assets (e.g., how much the trade was worth in USD, BTC, etc., at execution time).","items":{"$ref":"#/components/schemas/AssetAmount"}},"realizedProfit":{"type":"array","description":"Realized profit or loss from this trade, in various reference assets, if this trade closed an open position.","items":{"$ref":"#/components/schemas/AssetAmount"}}}},"Fill":{"type":"object","description":"Details of a single fill (partial execution) of an order.","properties":{"price":{"type":"string","description":"Execution price for this portion of the trade."},"quantity":{"type":"string","description":"Quantity of the base asset filled in this portion."},"commission":{"type":"string","description":"Fee charged by the exchange for this fill (in the `asset` specified)."},"asset":{"type":"string","description":"Asset in which the commission fee was paid."},"coinruleFee":{"$ref":"#/components/schemas/DeFiFee"},"aggregatorFee":{"$ref":"#/components/schemas/DeFiFee"}}},"DeFiFee":{"type":"object","description":"Fee information for DeFi or aggregator executions.","properties":{"tokenAmount":{"type":"string","description":"Amount of the fee token charged."},"tokenAddress":{"type":"string","description":"Contract address of the fee token."}}},"AssetAmount":{"type":"object","description":"Pair of asset and amount, used for summaries.","properties":{"asset":{"type":"string","description":"Asset symbol."},"amount":{"type":"string","description":"Amount of that asset."}}},"RuntimeDataHistory":{"type":"object","description":"Record of an indicator's value (or other data) at runtime.","properties":{"symbol":{"type":"string","description":"Asset or market symbol related to this data point."},"indicator":{"type":"string","description":"Indicator name (e.g., \"price\", \"EMA(50)\", \"RSI\", etc.)."},"value":{"type":"string","description":"Recorded value of the indicator at the given time."},"params":{"$ref":"#/components/schemas/RuntimeDataHistoryParameter"}}},"RuntimeDataHistoryParameter":{"type":"object","description":"Additional parameters associated with a runtime data record.","properties":{"conditionIndex":{"type":"integer","description":"Index of the condition block in the rule sequence that this data relates to."},"operation":{"type":"string","description":"Operation or comparison performed (e.g., \"above\", \"below\", \"gte\")."},"timestamp":{"type":"string","format":"date-time","description":"Timestamp when this data was captured."},"candlePeriod":{"type":"string","description":"If the data is candle-based, the timeframe of the candle (e.g. \"5m\", \"1h\")."},"candleStartTime":{"type":"string","format":"date-time","description":"Start time of the candle period (if applicable)."},"previousValue":{"type":"string","description":"Previous value (if comparing change, for inc/dec)."},"growth":{"type":"string","description":"Growth percentage or delta (if applicable, e.g. percentage change since previous)."}}},"SpeedStats":{"type":"object","description":"Timing and performance stats for the rule execution thread that executed a trade.","properties":{"threadStartTime":{"type":"string","format":"date-time","description":"Timestamp when the rule's execution cycle started for this trigger (used to measure execution latency)."},"conditions":{"type":"array","description":"List of conditions evaluated during this execution, with their evaluation times.","items":{"$ref":"#/components/schemas/ConditionStats"}}}},"ConditionStats":{"type":"object","description":"Performance metrics for evaluating a condition block.","properties":{"conditionIndex":{"type":"integer","description":"The index of the condition block that was evaluated."},"evaluationTime":{"type":"number","format":"float","description":"Time (in milliseconds) it took to evaluate this condition."}}}}}}
```

## The Fill object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"Fill":{"type":"object","description":"Details of a single fill (partial execution) of an order.","properties":{"price":{"type":"string","description":"Execution price for this portion of the trade."},"quantity":{"type":"string","description":"Quantity of the base asset filled in this portion."},"commission":{"type":"string","description":"Fee charged by the exchange for this fill (in the `asset` specified)."},"asset":{"type":"string","description":"Asset in which the commission fee was paid."},"coinruleFee":{"$ref":"#/components/schemas/DeFiFee"},"aggregatorFee":{"$ref":"#/components/schemas/DeFiFee"}}},"DeFiFee":{"type":"object","description":"Fee information for DeFi or aggregator executions.","properties":{"tokenAmount":{"type":"string","description":"Amount of the fee token charged."},"tokenAddress":{"type":"string","description":"Contract address of the fee token."}}}}}}
```

## The DeFiFee object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"DeFiFee":{"type":"object","description":"Fee information for DeFi or aggregator executions.","properties":{"tokenAmount":{"type":"string","description":"Amount of the fee token charged."},"tokenAddress":{"type":"string","description":"Contract address of the fee token."}}}}}}
```

## The AssetAmount object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"AssetAmount":{"type":"object","description":"Pair of asset and amount, used for summaries.","properties":{"asset":{"type":"string","description":"Asset symbol."},"amount":{"type":"string","description":"Amount of that asset."}}}}}}
```

## The RuntimeDataHistory object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"RuntimeDataHistory":{"type":"object","description":"Record of an indicator's value (or other data) at runtime.","properties":{"symbol":{"type":"string","description":"Asset or market symbol related to this data point."},"indicator":{"type":"string","description":"Indicator name (e.g., \"price\", \"EMA(50)\", \"RSI\", etc.)."},"value":{"type":"string","description":"Recorded value of the indicator at the given time."},"params":{"$ref":"#/components/schemas/RuntimeDataHistoryParameter"}}},"RuntimeDataHistoryParameter":{"type":"object","description":"Additional parameters associated with a runtime data record.","properties":{"conditionIndex":{"type":"integer","description":"Index of the condition block in the rule sequence that this data relates to."},"operation":{"type":"string","description":"Operation or comparison performed (e.g., \"above\", \"below\", \"gte\")."},"timestamp":{"type":"string","format":"date-time","description":"Timestamp when this data was captured."},"candlePeriod":{"type":"string","description":"If the data is candle-based, the timeframe of the candle (e.g. \"5m\", \"1h\")."},"candleStartTime":{"type":"string","format":"date-time","description":"Start time of the candle period (if applicable)."},"previousValue":{"type":"string","description":"Previous value (if comparing change, for inc/dec)."},"growth":{"type":"string","description":"Growth percentage or delta (if applicable, e.g. percentage change since previous)."}}}}}}
```

## The RuntimeDataHistoryParameter object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"RuntimeDataHistoryParameter":{"type":"object","description":"Additional parameters associated with a runtime data record.","properties":{"conditionIndex":{"type":"integer","description":"Index of the condition block in the rule sequence that this data relates to."},"operation":{"type":"string","description":"Operation or comparison performed (e.g., \"above\", \"below\", \"gte\")."},"timestamp":{"type":"string","format":"date-time","description":"Timestamp when this data was captured."},"candlePeriod":{"type":"string","description":"If the data is candle-based, the timeframe of the candle (e.g. \"5m\", \"1h\")."},"candleStartTime":{"type":"string","format":"date-time","description":"Start time of the candle period (if applicable)."},"previousValue":{"type":"string","description":"Previous value (if comparing change, for inc/dec)."},"growth":{"type":"string","description":"Growth percentage or delta (if applicable, e.g. percentage change since previous)."}}}}}}
```

## The ConditionStats object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"ConditionStats":{"type":"object","description":"Performance metrics for evaluating a condition block.","properties":{"conditionIndex":{"type":"integer","description":"The index of the condition block that was evaluated."},"evaluationTime":{"type":"number","format":"float","description":"Time (in milliseconds) it took to evaluate this condition."}}}}}}
```

## The SpeedStats object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"SpeedStats":{"type":"object","description":"Timing and performance stats for the rule execution thread that executed a trade.","properties":{"threadStartTime":{"type":"string","format":"date-time","description":"Timestamp when the rule's execution cycle started for this trigger (used to measure execution latency)."},"conditions":{"type":"array","description":"List of conditions evaluated during this execution, with their evaluation times.","items":{"$ref":"#/components/schemas/ConditionStats"}}}},"ConditionStats":{"type":"object","description":"Performance metrics for evaluating a condition block.","properties":{"conditionIndex":{"type":"integer","description":"The index of the condition block that was evaluated."},"evaluationTime":{"type":"number","format":"float","description":"Time (in milliseconds) it took to evaluate this condition."}}}}}}
```

## The ErrorResponse object

```json
{"openapi":"3.0.3","info":{"title":"Coinrule B2B API","version":"1.0"},"components":{"schemas":{"ErrorResponse":{"type":"object","description":"Standard error response structure.","properties":{"error":{"type":"string","description":"Short error code or description."},"message":{"type":"string","description":"Detailed error message."}}}}}}
```
