Create a trading rule.
POST
/api/trading-rules
const url = 'https://api.tradr.cloud/api/trading-rules';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"accountId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","definition":{"params":{},"type":"example"},"enabled":true,"tagId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","weight":"critical"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.tradr.cloud/api/trading-rules \ --header 'Content-Type: application/json' \ --data '{ "accountId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "definition": { "params": {}, "type": "example" }, "enabled": true, "tagId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "weight": "critical" }'Authed. The body carries the rule definition (type and parameters), a weight, an enabled flag and optional account and tag scopes. A scoped amount rule’s currency must equal the account’s currency. Subject to a per-user cap; an exact duplicate (same type, scope and parameters) is refused.
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
accountId
required
string format: uuid
definition
required
object
params
required
object
type
required
string
enabled
required
boolean
tagId
required
string format: uuid
weight
required
string
Responses
Section titled “ Responses ”The created rule.
Validation error
No valid session.
TRADING_RULE_LIMIT_REACHED — the per-user rule cap has been reached; or TRADING_RULE_DUPLICATE — a rule with the same type, scope and parameters already exists.