Response and Trade Execution
When the rule is successfully created (HTTP 201), the response confirms creation but does not immediately execute trades unless the trigger conditions are met instantly. In the example of a scheduled daily DCA, no trade happens at creation time — the first trade will execute at the scheduled start time (2025-07-16 11:08 UTC).
For immediate triggers (e.g., trigger type "direct_order" or a condition that is already true), a trade could execute right away. In such cases, or whenever a trade is executed as part of a rule, Coinrule will produce a Trade object containing the details of that execution. This Trade data can be accessed via the API or delivered through webhooks/notifications if configured.
Trade Data Schema: The Trade
schema (detailed in the OpenAPI spec above) includes comprehensive information about each trade:
Whether it was triggered by a rule or on-demand (
type
field).The assets traded (
base
,quote
,symbol
), side (buy
/sell
), order type, quantity, etc.Execution details like fills (partial fills with price and quantity), fees paid, transaction hash (for on-chain trades), and status (filled/part-filled/canceled/etc.).
Performance data like price values at execution, any profit realized, and diagnostic info (condition evaluations and timing via
runtimeDataHistory
andspeedStats
).
Retrieving Trade Results: You can retrieve executed trades via the API (for example, there may be an endpoint like GET /v3/rules/{ruleId}/trades
to list trades for a rule, or GET /v3/trades/{tradeId}
to get a specific trade's details). A webhook or notification might also be sent when a trade executes, depending on your integration. Ensure to consult your Coinrule integration guide or account manager for how trade execution results are delivered in the B2B context.
Example Response
Below is an example of a trade result in JSON, showing a filled order to buy ~0.0275 ETH for $50 USDC (price ~$1820.5 per ETH), including fees and other details. In practice, not all fields may be present for every trade (for instance, coinruleFee
or aggregatorFee
might be null if not applicable, and realizedProfit
would be filled only when a position is closed).
{
"id": "64b40d8f62cf0a0012345678",
"owner": "0xABC123... (user wallet address)",
"exchange": "Base",
"uid": "0xdef456... (txn hash or exchange order ID)",
"type": "rule",
"ruleId": "60d5adf568a3e60012345678",
"status": "filled",
"base": "ETH",
"quote": "USDC",
"symbol": "ETHUSDC",
"orderSide": "buy",
"orderType": "market",
"orderQuantity": "0.0275",
"orderDetails": { /* ... */ },
"tradeDetails": { /* ... */ },
"txHash": "0xdef456...",
"fills": [
{
"price": "1820.50",
"quantity": "0.0275",
"commission": "0.0000825",
"asset": "ETH",
"coinruleFee": { "tokenAmount": "0.00001", "tokenAddress": "0xCoinruleFeeToken..." },
"aggregatorFee": { "tokenAmount": "0.00003", "tokenAddress": "0xAggregatorFeeToken..." }
}
],
"totalBought": { "asset": "ETH", "amount": "0.0275" },
"totalSold": { "asset": "USDC", "amount": "50" },
"totalExfee": [
{ "asset": "ETH", "amount": "0.0000825" }
],
"runtimeDataHistory": [
{
"symbol": "ETH",
"indicator": "price",
"value": "1820.50",
"params": {
"conditionIndex": 0,
"operation": "above",
"timestamp": "2025-05-16T11:08:00Z"
}
}
],
"speedStats": {
"threadStartTime": "2025-05-16T11:07:59.500Z",
"conditions": [
{ "conditionIndex": 0, "evaluationTime": 12.5 }
]
},
"priceValues": [
{ "asset": "ETH", "amount": "1820.50" },
{ "asset": "USDC", "amount": "50" }
],
"tradeValues": [
{ "asset": "USD", "amount": "50" }
],
"realizedProfit": []
}
Last updated