dogabot dogabot Documentation

Ask AI recipes

Curated payloads for Ask AI and MCP. Machine-readable: /recipe-examples.json. Named-rule wire shapes stay on Named rules (/rule-examples.json).

Custom Logic

Paste under params.entry.rules.customLogic (or increase / decrease / reversal / exit). Labels in "leg" must match markets[].label. Prefer named rules when they already express the idea.

01-wait-after-cross

Wait after cross

Arm on EMA cross-down, wait N bars, then buy (classic stateful customLogic).

Example
{
  "enabled": true,
  "invert": false,
  "params": {
    "version": 1,
    "summary": "- Setup when close crosses below EMA(20)\n- Wait 4 closed candles while still below the EMA\n- Buy on the next bar if still watching\n- Cancel if price reclaims the EMA before buy",
    "vars": {
      "ma": {
        "fn": "ema",
        "args": [
          {
            "series": "close"
          },
          {
            "const": 20
          }
        ]
      }
    },
    "state": {
      "armed": {
        "type": "bool",
        "default": false
      },
      "barsWaited": {
        "type": "int",
        "default": 0
      }
    },
    "onBar": [
      {
        "if": {
          "fn": "and",
          "args": [
            {
              "state": "armed"
            },
            {
              "fn": "gt",
              "args": [
                {
                  "series": "close"
                },
                {
                  "var": "ma"
                }
              ]
            }
          ]
        },
        "then": [
          {
            "set": "armed",
            "value": {
              "const": false
            }
          },
          {
            "set": "barsWaited",
            "value": {
              "const": 0
            }
          }
        ]
      },
      {
        "if": {
          "fn": "and",
          "args": [
            {
              "fn": "not",
              "args": [
                {
                  "state": "armed"
                }
              ]
            },
            {
              "fn": "crossDown",
              "args": [
                {
                  "series": "close"
                },
                {
                  "var": "ma"
                }
              ]
            }
          ]
        },
        "then": [
          {
            "set": "armed",
            "value": {
              "const": true
            }
          },
          {
            "set": "barsWaited",
            "value": {
              "const": 0
            }
          }
        ]
      },
      {
        "if": {
          "state": "armed"
        },
        "then": [
          {
            "if": {
              "fn": "gte",
              "args": [
                {
                  "state": "barsWaited"
                },
                {
                  "const": 4
                }
              ]
            },
            "then": [
              {
                "emit": "buy"
              },
              {
                "set": "armed",
                "value": {
                  "const": false
                }
              },
              {
                "set": "barsWaited",
                "value": {
                  "const": 0
                }
              }
            ],
            "else": [
              {
                "set": "barsWaited",
                "value": {
                  "fn": "add",
                  "args": [
                    {
                      "state": "barsWaited"
                    },
                    {
                      "const": 1
                    }
                  ]
                }
              }
            ]
          }
        ]
      }
    ]
  }
}
02-per-leg-series-filter

Per leg series filter

Gate on another market’s series via `"leg"`; emit without leg → strategy stamp / `targetLeg`.

Example
{
  "enabled": true,
  "invert": false,
  "params": {
    "version": 1,
    "summary": "- Watch ETH on Binance via markets label eth_binance\n- Buy when that leg's close is above EMA(8)\n- Place uses strategy stamp / targetLeg (emit has no leg)",
    "vars": {
      "ma": {
        "fn": "ema",
        "args": [
          {
            "series": "close",
            "leg": "eth_binance"
          },
          {
            "const": 8
          }
        ]
      }
    },
    "state": {},
    "onBar": [
      {
        "if": {
          "fn": "gt",
          "args": [
            {
              "series": "close",
              "leg": "eth_binance"
            },
            {
              "var": "ma"
            }
          ]
        },
        "then": [
          {
            "emit": "buy"
          }
        ]
      }
    ]
  }
}
03-cheaper-venue-entry

Cheaper venue entry

Compare two venue closes; `{"emit":"buy","leg":"…"}` places on the cheaper book.

Example
{
  "enabled": true,
  "invert": false,
  "params": {
    "version": 1,
    "summary": "- Compare Binance vs OKX BTC closes\n- Buy on OKX when Binance close is higher\n- Otherwise buy on Binance",
    "vars": {},
    "state": {},
    "onBar": [
      {
        "if": {
          "fn": "gt",
          "args": [
            {
              "series": "close",
              "leg": "btc_binance"
            },
            {
              "series": "close",
              "leg": "btc_okx"
            }
          ]
        },
        "then": [
          {
            "emit": "buy",
            "leg": "btc_okx"
          }
        ],
        "else": [
          {
            "emit": "buy",
            "leg": "btc_binance"
          }
        ]
      }
    ]
  }
}
04-funding-spread-legs

Funding spread legs

Compare `fundingRate` (8h-eq, candle-aligned) on two labels; buy the lower-funding book.

Example
{
  "enabled": true,
  "invert": false,
  "params": {
    "version": 1,
    "summary": "- Compare eightHour-equivalent funding on two markets labels\n- Buy the leg with lower funding (receive bias)\n- Place on that book via emit.leg",
    "vars": {},
    "state": {},
    "onBar": [
      {
        "if": {
          "fn": "gt",
          "args": [
            {
              "series": "fundingRate",
              "leg": "skhy"
            },
            {
              "series": "fundingRate",
              "leg": "skhynix"
            }
          ]
        },
        "then": [
          {
            "emit": "buy",
            "leg": "skhynix"
          }
        ],
        "else": [
          {
            "emit": "buy",
            "leg": "skhy"
          }
        ]
      }
    ]
  }
}
05-wait-after-cross-limit-on-trigger

Wait after cross limit on trigger

Same as 01, but buy with a deferred limit (`on_trigger`) after a % pullback from the signal.

Example
{
  "enabled": true,
  "invert": false,
  "params": {
    "version": 1,
    "summary": "- Setup when close crosses below EMA(20)\n- Wait 4 closed candles while still below the EMA\n- Buy with a resting limit after a 1% pullback from the signal\n- Cancel if price reclaims the EMA before buy",
    "orderType": "limit",
    "limitArmFrom": "signal",
    "limitSendWhen": "on_trigger",
    "triggerType": "percentage",
    "triggerValue": 1,
    "targetType": "percentage",
    "targetValue": 0.5,
    "vars": {
      "ma": {
        "fn": "ema",
        "args": [
          {
            "series": "close"
          },
          {
            "const": 20
          }
        ]
      }
    },
    "state": {
      "armed": {
        "type": "bool",
        "default": false
      },
      "barsWaited": {
        "type": "int",
        "default": 0
      }
    },
    "onBar": [
      {
        "if": {
          "fn": "and",
          "args": [
            {
              "state": "armed"
            },
            {
              "fn": "gt",
              "args": [
                {
                  "series": "close"
                },
                {
                  "var": "ma"
                }
              ]
            }
          ]
        },
        "then": [
          {
            "set": "armed",
            "value": {
              "const": false
            }
          },
          {
            "set": "barsWaited",
            "value": {
              "const": 0
            }
          }
        ]
      },
      {
        "if": {
          "fn": "and",
          "args": [
            {
              "fn": "not",
              "args": [
                {
                  "state": "armed"
                }
              ]
            },
            {
              "fn": "crossDown",
              "args": [
                {
                  "series": "close"
                },
                {
                  "var": "ma"
                }
              ]
            }
          ]
        },
        "then": [
          {
            "set": "armed",
            "value": {
              "const": true
            }
          },
          {
            "set": "barsWaited",
            "value": {
              "const": 0
            }
          }
        ]
      },
      {
        "if": {
          "state": "armed"
        },
        "then": [
          {
            "if": {
              "fn": "gte",
              "args": [
                {
                  "state": "barsWaited"
                },
                {
                  "const": 4
                }
              ]
            },
            "then": [
              {
                "emit": "buy"
              },
              {
                "set": "armed",
                "value": {
                  "const": false
                }
              },
              {
                "set": "barsWaited",
                "value": {
                  "const": 0
                }
              }
            ],
            "else": [
              {
                "set": "barsWaited",
                "value": {
                  "fn": "add",
                  "args": [
                    {
                      "state": "barsWaited"
                    },
                    {
                      "const": 1
                    }
                  ]
                }
              }
            ]
          }
        ]
      }
    ]
  }
}
06-pairs-relative-legs

Pairs relative legs

1-bar BTC vs SOL returns; `each_trade_leg` stamps both books (omit `emit.leg`; `eq` unlabeled close vs `leg:"btc"` detects the current book).

Example
{
  "enabled": true,
  "invert": false,
  "params": {
    "version": 1,
    "summary": "- Compare 1-bar returns on BTC vs SOL\n- Short the outperformer and long the laggard\n- each_trade_leg places on both books (omit emit.leg)\n- Identify current book with eq(ctx.label, const)",
    "vars": {
      "btcRet": {
        "fn": "div",
        "args": [
          {
            "series": "close",
            "leg": "btc"
          },
          {
            "fn": "ref",
            "args": [
              {
                "series": "close",
                "leg": "btc"
              },
              {
                "const": 1
              }
            ]
          }
        ]
      },
      "solRet": {
        "fn": "div",
        "args": [
          {
            "series": "close",
            "leg": "sol"
          },
          {
            "fn": "ref",
            "args": [
              {
                "series": "close",
                "leg": "sol"
              },
              {
                "const": 1
              }
            ]
          }
        ]
      },
      "onBtc": {
        "fn": "eq",
        "args": [
          {
            "ctx": "label"
          },
          {
            "const": "btc"
          }
        ]
      }
    },
    "state": {},
    "onBar": [
      {
        "if": {
          "var": "onBtc"
        },
        "then": [
          {
            "if": {
              "fn": "gt",
              "args": [
                {
                  "var": "btcRet"
                },
                {
                  "var": "solRet"
                }
              ]
            },
            "then": [
              {
                "emit": "sell"
              }
            ],
            "else": [
              {
                "emit": "buy"
              }
            ]
          }
        ],
        "else": [
          {
            "if": {
              "fn": "gt",
              "args": [
                {
                  "var": "btcRet"
                },
                {
                  "var": "solRet"
                }
              ]
            },
            "then": [
              {
                "emit": "buy"
              }
            ],
            "else": [
              {
                "emit": "sell"
              }
            ]
          }
        ]
      }
    ]
  }
}
07-funding-limit-then-sibling-market

Funding limit then sibling market

Array of two `customLogic` instances: (1) limit short funding winner while both flat; (2) market hedge opposite when sibling `ctx.position` is open. Use `placementMode: each_trade_leg` + `legSizing: equal_notional`. Optional `siblingHedgeOnEntryFill` for fill-instant OE hedge.

Example
[
  {
    "enabled": true,
    "invert": false,
    "params": {
      "version": 1,
      "summary": "- Both books flat: short the higher eightHour funding leg via limit + small offset\n- Place only on the funding winner book this tick",
      "orderType": "limit",
      "limitArmFrom": "signal",
      "limitSendWhen": "now",
      "limitOffsetType": "percentage",
      "limitOffsetValue": -0.05,
      "limitStackPolicy": "stack",
      "vars": {
        "onDoge": {
          "fn": "eq",
          "args": [
            {
              "series": "close"
            },
            {
              "series": "close",
              "leg": "doge"
            }
          ]
        },
        "dogePaysMore": {
          "fn": "gt",
          "args": [
            {
              "series": "fundingRate",
              "leg": "doge"
            },
            {
              "series": "fundingRate",
              "leg": "xrp"
            }
          ]
        },
        "bothFlat": {
          "fn": "and",
          "args": [
            {
              "fn": "eq",
              "args": [
                {
                  "ctx": "position",
                  "leg": "doge"
                },
                {
                  "const": 0
                }
              ]
            },
            {
              "fn": "eq",
              "args": [
                {
                  "ctx": "position",
                  "leg": "xrp"
                },
                {
                  "const": 0
                }
              ]
            }
          ]
        }
      },
      "state": {},
      "onBar": [
        {
          "if": {
            "fn": "and",
            "args": [
              {
                "var": "bothFlat"
              },
              {
                "fn": "and",
                "args": [
                  {
                    "var": "onDoge"
                  },
                  {
                    "var": "dogePaysMore"
                  }
                ]
              }
            ]
          },
          "then": [
            {
              "emit": "sell"
            }
          ]
        },
        {
          "if": {
            "fn": "and",
            "args": [
              {
                "var": "bothFlat"
              },
              {
                "fn": "and",
                "args": [
                  {
                    "fn": "eq",
                    "args": [
                      {
                        "series": "close"
                      },
                      {
                        "series": "close",
                        "leg": "xrp"
                      }
                    ]
                  },
                  {
                    "fn": "not",
                    "args": [
                      {
                        "var": "dogePaysMore"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          "then": [
            {
              "emit": "sell"
            }
          ]
        }
      ]
    }
  },
  {
    "enabled": true,
    "invert": false,
    "params": {
      "version": 1,
      "summary": "- This book flat and sibling open: market hedge opposite the sibling position\n- Latency is next execution_interval unless siblingHedgeOnEntryFill is also enabled",
      "orderType": "market",
      "vars": {
        "onDoge": {
          "fn": "eq",
          "args": [
            {
              "series": "close"
            },
            {
              "series": "close",
              "leg": "doge"
            }
          ]
        }
      },
      "state": {},
      "onBar": [
        {
          "if": {
            "fn": "and",
            "args": [
              {
                "var": "onDoge"
              },
              {
                "fn": "and",
                "args": [
                  {
                    "fn": "eq",
                    "args": [
                      {
                        "ctx": "position"
                      },
                      {
                        "const": 0
                      }
                    ]
                  },
                  {
                    "fn": "lt",
                    "args": [
                      {
                        "ctx": "position",
                        "leg": "xrp"
                      },
                      {
                        "const": 0
                      }
                    ]
                  }
                ]
              }
            ]
          },
          "then": [
            {
              "emit": "buy"
            }
          ]
        },
        {
          "if": {
            "fn": "and",
            "args": [
              {
                "var": "onDoge"
              },
              {
                "fn": "and",
                "args": [
                  {
                    "fn": "eq",
                    "args": [
                      {
                        "ctx": "position"
                      },
                      {
                        "const": 0
                      }
                    ]
                  },
                  {
                    "fn": "gt",
                    "args": [
                      {
                        "ctx": "position",
                        "leg": "xrp"
                      },
                      {
                        "const": 0
                      }
                    ]
                  }
                ]
              }
            ]
          },
          "then": [
            {
              "emit": "sell"
            }
          ]
        },
        {
          "if": {
            "fn": "and",
            "args": [
              {
                "fn": "eq",
                "args": [
                  {
                    "series": "close"
                  },
                  {
                    "series": "close",
                    "leg": "xrp"
                  }
                ]
              },
              {
                "fn": "and",
                "args": [
                  {
                    "fn": "eq",
                    "args": [
                      {
                        "ctx": "position"
                      },
                      {
                        "const": 0
                      }
                    ]
                  },
                  {
                    "fn": "lt",
                    "args": [
                      {
                        "ctx": "position",
                        "leg": "doge"
                      },
                      {
                        "const": 0
                      }
                    ]
                  }
                ]
              }
            ]
          },
          "then": [
            {
              "emit": "buy"
            }
          ]
        },
        {
          "if": {
            "fn": "and",
            "args": [
              {
                "fn": "eq",
                "args": [
                  {
                    "series": "close"
                  },
                  {
                    "series": "close",
                    "leg": "xrp"
                  }
                ]
              },
              {
                "fn": "and",
                "args": [
                  {
                    "fn": "eq",
                    "args": [
                      {
                        "ctx": "position"
                      },
                      {
                        "const": 0
                      }
                    ]
                  },
                  {
                    "fn": "gt",
                    "args": [
                      {
                        "ctx": "position",
                        "leg": "doge"
                      },
                      {
                        "const": 0
                      }
                    ]
                  }
                ]
              }
            ]
          },
          "then": [
            {
              "emit": "sell"
            }
          ]
        }
      ]
    }
  }
]
08-bullish-engulfing

Bullish engulfing

Educational AST using `series:open` + `ref` for bullish engulfing. Prefer named `candlePattern` (`pattern: bullishEngulfing`) for create/Ask AI.

Example
{
  "enabled": true,
  "invert": false,
  "params": {
    "version": 1,
    "summary": "- Prefer named candlePattern for engulfing in production bots\n- This tree buys when a bullish engulfing forms using open/close + ref\n- Prior bar must be bearish; current body engulfs prior body",
    "vars": {},
    "state": {},
    "onBar": [
      {
        "if": {
          "fn": "and",
          "args": [
            {
              "fn": "and",
              "args": [
                {
                  "fn": "lt",
                  "args": [
                    {
                      "fn": "ref",
                      "args": [
                        {
                          "series": "close"
                        },
                        {
                          "const": 1
                        }
                      ]
                    },
                    {
                      "fn": "ref",
                      "args": [
                        {
                          "series": "open"
                        },
                        {
                          "const": 1
                        }
                      ]
                    }
                  ]
                },
                {
                  "fn": "gt",
                  "args": [
                    {
                      "series": "close"
                    },
                    {
                      "series": "open"
                    }
                  ]
                }
              ]
            },
            {
              "fn": "and",
              "args": [
                {
                  "fn": "lte",
                  "args": [
                    {
                      "series": "open"
                    },
                    {
                      "fn": "ref",
                      "args": [
                        {
                          "series": "close"
                        },
                        {
                          "const": 1
                        }
                      ]
                    }
                  ]
                },
                {
                  "fn": "gte",
                  "args": [
                    {
                      "series": "close"
                    },
                    {
                      "fn": "ref",
                      "args": [
                        {
                          "series": "open"
                        },
                        {
                          "const": 1
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        "then": [
          {
            "emit": "buy"
          }
        ]
      }
    ]
  }
}
09-ladder-exit-shrinking-tp

Ladder exit shrinking tp

Exit rule for an averaging-down ladder: take profit from `ctx avgEntry` that tightens with `ctx steps` (filled increase steps): 0.8%, then 0.55%, then 0.3%. Pair with `increase.rules.incrementalScaling`.

Example
{
  "enabled": true,
  "invert": false,
  "params": {
    "version": 1,
    "summary": "- Exit rule for an averaging-down ladder (put under exit.rules)\n- Take profit 0.8% from the average entry with no adds\n- Tighten by 0.25% per filled add: 0.55% after one, 0.3% after two\n- Works long and short",
    "vars": {},
    "state": {},
    "onBar": [
      {
        "if": {
          "fn": "and",
          "args": [
            {
              "fn": "gt",
              "args": [
                {
                  "ctx": "position"
                },
                {
                  "const": 0
                }
              ]
            },
            {
              "fn": "gte",
              "args": [
                {
                  "ctx": "price"
                },
                {
                  "fn": "mul",
                  "args": [
                    {
                      "ctx": "avgEntry"
                    },
                    {
                      "fn": "sub",
                      "args": [
                        {
                          "const": 1.008
                        },
                        {
                          "fn": "mul",
                          "args": [
                            {
                              "const": 0.0025
                            },
                            {
                              "ctx": "steps"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        "then": [
          {
            "emit": "sell"
          }
        ]
      },
      {
        "if": {
          "fn": "and",
          "args": [
            {
              "fn": "lt",
              "args": [
                {
                  "ctx": "position"
                },
                {
                  "const": 0
                }
              ]
            },
            {
              "fn": "lte",
              "args": [
                {
                  "ctx": "price"
                },
                {
                  "fn": "mul",
                  "args": [
                    {
                      "ctx": "avgEntry"
                    },
                    {
                      "fn": "add",
                      "args": [
                        {
                          "const": 0.992
                        },
                        {
                          "fn": "mul",
                          "args": [
                            {
                              "const": 0.0025
                            },
                            {
                              "ctx": "steps"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        "then": [
          {
            "emit": "buy"
          }
        ]
      }
    ]
  }
}
10-exit-at-band-middle

Exit at band middle

Exit rule for range bots: close when price returns to `bb_middle` (the 20-bar mean), long or short.

Example
{
  "enabled": true,
  "invert": false,
  "params": {
    "version": 1,
    "summary": "- Exit rule for a range / mean-reversion bot (put under exit.rules)\n- Close a long once price is back at the Bollinger middle line (20-bar mean)\n- Close a short the same way from below",
    "vars": {
      "mid": {
        "fn": "bb_middle",
        "args": [
          {
            "series": "close"
          },
          {
            "const": 20
          }
        ]
      }
    },
    "state": {},
    "onBar": [
      {
        "if": {
          "fn": "and",
          "args": [
            {
              "fn": "gt",
              "args": [
                {
                  "ctx": "position"
                },
                {
                  "const": 0
                }
              ]
            },
            {
              "fn": "gte",
              "args": [
                {
                  "ctx": "price"
                },
                {
                  "var": "mid"
                }
              ]
            }
          ]
        },
        "then": [
          {
            "emit": "sell"
          }
        ]
      },
      {
        "if": {
          "fn": "and",
          "args": [
            {
              "fn": "lt",
              "args": [
                {
                  "ctx": "position"
                },
                {
                  "const": 0
                }
              ]
            },
            {
              "fn": "lte",
              "args": [
                {
                  "ctx": "price"
                },
                {
                  "var": "mid"
                }
              ]
            }
          ]
        },
        "then": [
          {
            "emit": "buy"
          }
        ]
      }
    ]
  }
}

Create automation

Full Ask AI / MCP create_automation tool args (not a customLogic-only snippet). Paper examples only — do not start or set trading_mode=live without an explicit confirm.

01-pairs-btc-sol-paper

Pairs btc sol paper

Paper Bybit linear BTC+SOL relative-value bot. Top-level `markets[]` omits `leg_index` (server assigns 0, 1). `placementMode` is on the tool args (server copies it into `params`). `stopLoss` is a sibling `params.exit.rules` — never `params.entry.exit`. customLogic tree matches [`../custom_logic/06-pairs-relative-legs.json`](../custom_logic/06-pairs-relative-legs.json).

Example
{
  "type": "bot",
  "name": "Paper BTC/SOL Perp Arbitrage",
  "exchange": "bybit_linear",
  "symbol": "BTCUSDT",
  "candle_timeframe": "5m",
  "execution_interval": 300000,
  "initial_capital": 10000,
  "trading_mode": "paper",
  "placementMode": "each_trade_leg",
  "markets": [
    {
      "label": "btc",
      "exchange": "bybit_linear",
      "symbol": "BTCUSDT"
    },
    {
      "label": "sol",
      "exchange": "bybit_linear",
      "symbol": "SOLUSDT"
    }
  ],
  "params": {
    "legSizing": "equal_notional",
    "entry": {
      "rules": {
        "customLogic": {
          "enabled": true,
          "invert": false,
          "params": {
            "version": 1,
            "summary": "- Compare 1-bar returns on BTC vs SOL\n- Short the outperformer and long the laggard\n- each_trade_leg places on both books (omit emit.leg)",
            "vars": {
              "btcRet": {
                "fn": "div",
                "args": [
                  {
                    "series": "close",
                    "leg": "btc"
                  },
                  {
                    "fn": "ref",
                    "args": [
                      {
                        "series": "close",
                        "leg": "btc"
                      },
                      {
                        "const": 1
                      }
                    ]
                  }
                ]
              },
              "solRet": {
                "fn": "div",
                "args": [
                  {
                    "series": "close",
                    "leg": "sol"
                  },
                  {
                    "fn": "ref",
                    "args": [
                      {
                        "series": "close",
                        "leg": "sol"
                      },
                      {
                        "const": 1
                      }
                    ]
                  }
                ]
              },
              "onBtc": {
                "fn": "eq",
                "args": [
                  {
                    "ctx": "label"
                  },
                  {
                    "const": "btc"
                  }
                ]
              }
            },
            "state": {},
            "onBar": [
              {
                "if": {
                  "var": "onBtc"
                },
                "then": [
                  {
                    "if": {
                      "fn": "gt",
                      "args": [
                        {
                          "var": "btcRet"
                        },
                        {
                          "var": "solRet"
                        }
                      ]
                    },
                    "then": [
                      {
                        "emit": "sell"
                      }
                    ],
                    "else": [
                      {
                        "emit": "buy"
                      }
                    ]
                  }
                ],
                "else": [
                  {
                    "if": {
                      "fn": "gt",
                      "args": [
                        {
                          "var": "btcRet"
                        },
                        {
                          "var": "solRet"
                        }
                      ]
                    },
                    "then": [
                      {
                        "emit": "buy"
                      }
                    ],
                    "else": [
                      {
                        "emit": "sell"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        }
      }
    },
    "increase": {
      "rules": {}
    },
    "decrease": {
      "rules": {}
    },
    "reversal": {
      "rules": {}
    },
    "exit": {
      "rules": {
        "stopLoss": {
          "enabled": true,
          "params": {
            "type": "percentage",
            "value": 2
          }
        }
      }
    }
  }
}
02-aster-doge-xrp-sibling-hedge-paper

Aster doge xrp sibling hedge paper

Paper Aster DOGE+XRP funding limit → sibling market hedge. Dual `customLogic` ARRAY (from [`../custom_logic/07-funding-limit-then-sibling-market.json`](../custom_logic/07-funding-limit-then-sibling-market.json)) + `siblingHedgeOnEntryFill`, equal_notional, fill-armed TP 0.7% + scale-in amend. Ask AI embeds this recipe in the params hint.

Example
{
  "type": "bot",
  "name": "Paper Aster DOGE/XRP Funding Sibling Hedge",
  "exchange": "aster_dex",
  "symbol": "DOGEUSDT",
  "candle_timeframe": "1h",
  "execution_interval": 300000,
  "initial_capital": 1000,
  "trading_mode": "paper",
  "placementMode": "each_trade_leg",
  "markets": [
    {
      "label": "doge",
      "exchange": "aster_dex",
      "symbol": "DOGEUSDT"
    },
    {
      "label": "xrp",
      "exchange": "aster_dex",
      "symbol": "XRPUSDT"
    }
  ],
  "params": {
    "legSizing": "equal_notional",
    "siblingHedgeOnEntryFill": {
      "enabled": true
    },
    "entry": {
      "rules": {
        "customLogic": [
          {
            "enabled": true,
            "invert": false,
            "params": {
              "version": 1,
              "summary": "- Both books flat: short the higher eightHour funding leg via limit + small offset\n- Place only on the funding winner book this tick\n- Pair with siblingHedgeOnEntryFill for fill-instant market hedge on the other book",
              "orderType": "limit",
              "limitArmFrom": "signal",
              "limitSendWhen": "now",
              "limitOffsetType": "percentage",
              "limitOffsetValue": -0.05,
              "limitStackPolicy": "stack",
              "vars": {
                "onDoge": {
                  "fn": "eq",
                  "args": [
                    {
                      "series": "close"
                    },
                    {
                      "series": "close",
                      "leg": "doge"
                    }
                  ]
                },
                "dogePaysMore": {
                  "fn": "gt",
                  "args": [
                    {
                      "series": "fundingRate",
                      "leg": "doge"
                    },
                    {
                      "series": "fundingRate",
                      "leg": "xrp"
                    }
                  ]
                },
                "bothFlat": {
                  "fn": "and",
                  "args": [
                    {
                      "fn": "eq",
                      "args": [
                        {
                          "ctx": "position",
                          "leg": "doge"
                        },
                        {
                          "const": 0
                        }
                      ]
                    },
                    {
                      "fn": "eq",
                      "args": [
                        {
                          "ctx": "position",
                          "leg": "xrp"
                        },
                        {
                          "const": 0
                        }
                      ]
                    }
                  ]
                }
              },
              "state": {},
              "onBar": [
                {
                  "if": {
                    "fn": "and",
                    "args": [
                      {
                        "var": "bothFlat"
                      },
                      {
                        "fn": "and",
                        "args": [
                          {
                            "var": "onDoge"
                          },
                          {
                            "var": "dogePaysMore"
                          }
                        ]
                      }
                    ]
                  },
                  "then": [
                    {
                      "emit": "sell"
                    }
                  ]
                },
                {
                  "if": {
                    "fn": "and",
                    "args": [
                      {
                        "var": "bothFlat"
                      },
                      {
                        "fn": "and",
                        "args": [
                          {
                            "fn": "eq",
                            "args": [
                              {
                                "series": "close"
                              },
                              {
                                "series": "close",
                                "leg": "xrp"
                              }
                            ]
                          },
                          {
                            "fn": "not",
                            "args": [
                              {
                                "var": "dogePaysMore"
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  },
                  "then": [
                    {
                      "emit": "sell"
                    }
                  ]
                }
              ]
            }
          },
          {
            "enabled": true,
            "invert": false,
            "params": {
              "version": 1,
              "summary": "- This book flat and sibling open: market hedge opposite the sibling position\n- Strategy-listen latency is next execution_interval; with siblingHedgeOnEntryFill OE hedges on entry fill",
              "orderType": "market",
              "vars": {
                "onDoge": {
                  "fn": "eq",
                  "args": [
                    {
                      "series": "close"
                    },
                    {
                      "series": "close",
                      "leg": "doge"
                    }
                  ]
                }
              },
              "state": {},
              "onBar": [
                {
                  "if": {
                    "fn": "and",
                    "args": [
                      {
                        "var": "onDoge"
                      },
                      {
                        "fn": "and",
                        "args": [
                          {
                            "fn": "eq",
                            "args": [
                              {
                                "ctx": "position"
                              },
                              {
                                "const": 0
                              }
                            ]
                          },
                          {
                            "fn": "lt",
                            "args": [
                              {
                                "ctx": "position",
                                "leg": "xrp"
                              },
                              {
                                "const": 0
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  },
                  "then": [
                    {
                      "emit": "buy"
                    }
                  ]
                },
                {
                  "if": {
                    "fn": "and",
                    "args": [
                      {
                        "var": "onDoge"
                      },
                      {
                        "fn": "and",
                        "args": [
                          {
                            "fn": "eq",
                            "args": [
                              {
                                "ctx": "position"
                              },
                              {
                                "const": 0
                              }
                            ]
                          },
                          {
                            "fn": "gt",
                            "args": [
                              {
                                "ctx": "position",
                                "leg": "xrp"
                              },
                              {
                                "const": 0
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  },
                  "then": [
                    {
                      "emit": "sell"
                    }
                  ]
                },
                {
                  "if": {
                    "fn": "and",
                    "args": [
                      {
                        "fn": "eq",
                        "args": [
                          {
                            "series": "close"
                          },
                          {
                            "series": "close",
                            "leg": "xrp"
                          }
                        ]
                      },
                      {
                        "fn": "and",
                        "args": [
                          {
                            "fn": "eq",
                            "args": [
                              {
                                "ctx": "position"
                              },
                              {
                                "const": 0
                              }
                            ]
                          },
                          {
                            "fn": "lt",
                            "args": [
                              {
                                "ctx": "position",
                                "leg": "doge"
                              },
                              {
                                "const": 0
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  },
                  "then": [
                    {
                      "emit": "buy"
                    }
                  ]
                },
                {
                  "if": {
                    "fn": "and",
                    "args": [
                      {
                        "fn": "eq",
                        "args": [
                          {
                            "series": "close"
                          },
                          {
                            "series": "close",
                            "leg": "xrp"
                          }
                        ]
                      },
                      {
                        "fn": "and",
                        "args": [
                          {
                            "fn": "eq",
                            "args": [
                              {
                                "ctx": "position"
                              },
                              {
                                "const": 0
                              }
                            ]
                          },
                          {
                            "fn": "gt",
                            "args": [
                              {
                                "ctx": "position",
                                "leg": "doge"
                              },
                              {
                                "const": 0
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  },
                  "then": [
                    {
                      "emit": "sell"
                    }
                  ]
                }
              ]
            }
          }
        ]
      }
    },
    "increase": {
      "rules": {
        "incrementalScaling": {
          "enabled": true,
          "invert": false,
          "params": {
            "type": "percentage",
            "trendSide": false,
            "levels": [
              0.5,
              1,
              2,
              3,
              4
            ],
            "multipliers": [
              1,
              1,
              2,
              4,
              8
            ],
            "orderType": "limit",
            "limitArmFrom": "fill",
            "limitSendWhen": "now",
            "limitStackPolicy": "amend"
          }
        }
      }
    },
    "decrease": {
      "rules": {}
    },
    "reversal": {
      "rules": {}
    },
    "exit": {
      "rules": {
        "takeProfit": {
          "enabled": true,
          "invert": false,
          "params": {
            "type": "percentage",
            "value": 0.7,
            "orderType": "limit",
            "limitArmFrom": "fill",
            "limitSendWhen": "now",
            "limitStackPolicy": "amend"
          }
        },
        "stopLoss": {
          "enabled": true,
          "invert": false,
          "params": {
            "type": "percentage",
            "value": 10
          }
        }
      }
    }
  }
}
03-pairs-spread-btc-sol-paper

Pairs spread btc sol paper

Paper Bybit BTC+SOL using named `pairsSpread` (not customLogic) with `each_trade_leg` + equal_notional. Prefer this when the named rule already covers the spread idea.

Example
{
  "type": "bot",
  "name": "Paper BTC/SOL Pairs Spread",
  "exchange": "bybit_linear",
  "symbol": "BTCUSDT",
  "candle_timeframe": "5m",
  "execution_interval": 300000,
  "initial_capital": 10000,
  "trading_mode": "paper",
  "placementMode": "each_trade_leg",
  "markets": [
    {
      "label": "btc",
      "exchange": "bybit_linear",
      "symbol": "BTCUSDT"
    },
    {
      "label": "sol",
      "exchange": "bybit_linear",
      "symbol": "SOLUSDT"
    }
  ],
  "params": {
    "legSizing": "equal_notional",
    "placementMode": "each_trade_leg",
    "entry": {
      "rules": {
        "pairsSpread": {
          "enabled": true,
          "invert": false,
          "params": {
            "metric": "priceReturn",
            "mode": "meanRevert",
            "legA": "btc",
            "legB": "sol",
            "lookbackBars": 1,
            "zScoreWindow": 48,
            "threshold": 0.005,
            "convergeExitEnabled": false,
            "exitThreshold": 0.001
          }
        }
      }
    },
    "increase": {
      "rules": {}
    },
    "decrease": {
      "rules": {}
    },
    "reversal": {
      "rules": {}
    },
    "exit": {
      "rules": {
        "stopLoss": {
          "enabled": true,
          "params": {
            "type": "percentage",
            "value": 2
          }
        },
        "takeProfit": {
          "enabled": true,
          "params": {
            "type": "percentage",
            "value": 3
          }
        }
      }
    }
  }
}

Order execution

limitStackPolicy recipes (skip / stack / replace) for named rules. Paste under a rule’s params.

01-reactive-tp-skip

Reactive tp skip

`skip` (TP default) — Classic reactive limit TP — do not stack another GTC while one rests

Example
{
  "enabled": true,
  "params": {
    "type": "percentage",
    "value": 2,
    "exitQuantityMode": "full",
    "orderType": "limit",
    "limitArmFrom": "signal",
    "limitSendWhen": "now",
    "limitOffsetType": "distance",
    "limitOffsetValue": 0,
    "limitStackPolicy": "skip"
  }
}
02-entry-limit-stack

Entry limit stack

`stack` (entry default) — Place another entry-style limit while a prior GTC still rests

Example
{
  "enabled": true,
  "params": {
    "period": 14,
    "oversold": 30,
    "overbought": 70,
    "orderType": "limit",
    "limitArmFrom": "signal",
    "limitSendWhen": "now",
    "limitOffsetType": "percentage",
    "limitOffsetValue": -0.5,
    "limitStackPolicy": "stack"
  }
}
03-scale-in-replace

Scale in replace

`replace` — Cancel the resting scale limit, then park updated price/qty

Example
{
  "enabled": true,
  "params": {
    "type": "percentage",
    "trendSide": false,
    "levels": [
      1,
      2,
      3
    ],
    "multipliers": [
      1,
      1,
      1
    ],
    "orderType": "limit",
    "limitArmFrom": "fill",
    "limitSendWhen": "now",
    "limitStackPolicy": "replace"
  }
}