Crypto Perpetuals on Binance
Build a long/short crypto perpetuals strategy on Binance, size positions with leverage in mind, and avoid liquidation from funding-rate drift.
By the end you will have a crypto perpetuals strategy that places leveraged long and short orders on Binance (the only live perpetuals venue today — Coinbase support is coming soon), with position sizing that accounts for leverage, funding-rate awareness, and a paper-tested webhook before any real capital is at risk.
Perpetuals can liquidate. Leverage amplifies both upside and downside. A 10x position is fully wiped out by a 10% adverse move (less, after exchange fees and funding). Nyria places the orders your alerts request — it does not add stops, brackets, or margin top-ups. Liquidation is enforced by the exchange, not by Nyria. Test with Binance Testnet before sending real money.
Prerequisites
- A Nyria account with an active subscription. New here? Start with the Quick Start.
- A connected Binance account (Testnet or Live). Coinbase perpetuals support is coming soon.
- For Binance: Binance Futures enabled on the account (a one-time opt-in inside Binance). Spot-only accounts cannot trade perpetuals.
- An alert source that emits long/short entry and exit signals. This tutorial uses TradingView, but the strategy works with any source documented in Alert Sources.
- A clear answer to: what leverage am I willing to lose at? If you cannot answer this, stop and read Risk Disclosure first.
Long vs short — what changes on a perpetual
A perpetual future is a derivative that tracks the underlying spot price but never expires. You can hold a long or a short indefinitely, paid for via the funding rate (see below).
| Long | Short | |
|---|---|---|
| Profits when | Price rises | Price falls |
| Loses when | Price falls | Price rises |
| Funding paid when | Funding rate is positive (longs pay shorts) | Funding rate is negative (shorts pay longs) |
| Liquidation trigger | Price drops to your liquidation price | Price rises to your liquidation price |
| Nyria action key | buy / long | sell / short |
On Nyria, long and short are configured independently per direction in your strategy. You can:
- Enable long entries and short entries (a true two-way strategy).
- Enable only one direction (e.g. long-only momentum on BTC).
- Use one direction's entry alert to close the opposite direction (the Exit Opposite behavior — useful when your alert source emits "flip" signals rather than separate close signals).
Nyria does not support attached take-profit legs, bracket orders, OCO, OTO, or trailing stops on perpetuals. Your exits must come from your alert source as separate signals. If you need bracket-style protection, build it upstream in your alert generator — do not assume Nyria will manage it.
Funding rate — the cost of holding
Funding is the cash payment that keeps the perpetual price tethered to spot. Both Binance and Coinbase settle funding every 8 hours (3 times per day).
- Positive funding (the common case in bull markets): longs pay shorts. Holding a long costs you the funding rate every 8 hours.
- Negative funding (common in panic selldowns): shorts pay longs. Holding a short costs you.
- The dollar amount is
position_notional * funding_rate. On a $10,000 notional BTC long at 0.01% funding, you pay $1 every 8 hours — small, but compounds, and spikes during volatility.
Funding is paid out of your margin balance. Nyria does not pre-fund a buffer for funding payments — if funding drains your margin below the maintenance level, the exchange liquidates the position. Treat funding as a recurring tax on the position size, not on your account balance.
Check the live funding rate inside the exchange UI before sizing a position you plan to hold across multiple funding windows. Binance and Coinbase both publish it on the perpetual's contract page.
Position sizing for perpetuals
Sizing a perpetual is not the same as sizing a spot order. You are sizing two things at once:
- Notional exposure — the value of the position to the market (
quantity * mark_price). This is what moves with price. - Margin posted — the collateral the exchange holds against the position (
notional / leverage). This is what you can lose to liquidation.
Nyria's bot sizing config controls margin posted, not notional. Your strategy's leverage setting then multiplies that into notional exposure.
Worked example — BTC at $60,000, 5x leverage, $200 budget:
- Margin posted: $200.
- Notional exposure: $200 × 5 = $1,000.
- Quantity: $1,000 / $60,000 ≈ 0.01666 BTC.
- Approximate liquidation distance from entry: ~20% adverse move (less fees, less the exchange's maintenance margin buffer — exact number is shown in the exchange UI after the order fills).
The mental model: a higher leverage number means a smaller quantity is not placed — the same dollar budget is placed with a closer liquidation price. Doubling leverage from 5x to 10x on the same $200 budget moves you from a ~20% liquidation buffer to ~10%, while doubling the funding cost.
Nyria's per-bot position size is denominated in the bot's budget (margin posted), not contract count. If you set a fixed $100 budget on a 10x perpetual, every entry posts $100 of margin and opens $1,000 of notional exposure. Pyramiding multiple entries posts that margin repeatedly — three pyramided $100 entries at 10x = $3,000 notional and $300 of margin locked.
Margin warnings — read this before going live
Cross-margin vs isolated-margin is set on the exchange side, not in Nyria. On Binance and Coinbase, the default is usually cross-margin, meaning every open perpetual shares the same margin pool. A liquidation on any one symbol can cascade into the others. If you do not want this, switch the contracts to isolated margin inside the exchange UI before pointing Nyria at the account.
- Insufficient margin rejections appear in your bot logs as
No available balance (...). The order is dropped, the alert is not retried. If you see these during a planned entry, your margin posted plus existing positions exceeds the account's free collateral. - Funding-rate drain. A position held flat for a week at 0.03% positive funding across all eight-hour windows pays ~0.63% of notional in funding. On a 10x position that is ~6.3% of your margin gone with no price movement. Plan exit rules accordingly.
- Auto-deleveraging (ADL). When the exchange's insurance fund cannot cover a counterparty's liquidation, profitable opposing positions are forcibly closed at the bankruptcy price. ADL is rare but real on Binance perpetuals in extreme volatility. There is no Nyria-side mitigation.
- Maintenance-margin tier changes. Both exchanges tier maintenance margin by notional size. A position that grows (via pyramiding) into a higher tier may have a worse liquidation price than the first entry showed. Check the tier table in the exchange UI before scaling in.
Step 1: Decide the contract spec before you create the strategy
Pick one primary trading pair for the first iteration. Multi-symbol strategies are supported, but a one-symbol setup is faster to debug.
Worksheet — fill these in before continuing:
| Decision | Your value |
|---|---|
Pair (Binance: BTCUSDT) | |
| Direction(s): long, short, or both | |
| Long leverage (1×–125× on Binance, per-pair tier limits) | |
| Short leverage (same range) | |
| Per-entry budget (margin posted, USD) | |
| Pyramiding: single entry, or multiple? | |
| Exit rule: alert-driven, or funding-time-based? |
Symbol formatting is normalized by Nyria. You can write BTCUSDT,
BTC-USD, BTC, or BTCUSD in your alert. Nyria converts to the
correct exchange-native format (BTCUSDT on Binance perpetuals).
See Binance for the per-broker mapping.
Step 2: Create the strategy in Nyria
Open the Nyria app, go to My Strategies, and click Create Strategy.
Fill in the basics:
- Name — for example,
BTC Perp Long/Short. - Public URL — for example,
btc-perp-long-short. - Alert Source — TradingView (or your source).
- Visibility — Private, until you have paper-validated it.
On the Parameters screen, choose Cryptocurrency as the equity type, then choose Perpetual Futures as the crypto type. The leverage fields appear only after you choose Perpetual Futures — they are hidden for Spot.
Set Long Leverage and Short Leverage independently. The values you enter must be within the connected broker's allowed range: Binance allows 1×–125× (per-pair tier limits apply). Out-of-range values are rejected at order placement with a broker error in the bot log.
Configure Trading Behavior for each direction. For a textbook two-way strategy:
- Long: Enter Direction on entry, Enabled on exit, Market order type.
- Short: Enter Direction on entry, Enabled on exit, Market order type.
For a long-only with auto-flip behavior:
- Long: Enter Direction on entry, Enabled on exit.
- Short: Exit Opposite on entry (a short signal closes any open long), Disabled on exit.
On Allowed Instruments, select your pair. For crypto strategies you can additionally filter by pairing — USDT for Binance, USD for Coinbase — to constrain the strategy to one quote currency.
Click Create Strategy to save. The strategy starts in the Validation Pending state — it is not yet live.
Step 3: Validate the alert format
Nyria requires that you send a sample alert for each direction you enabled, so it can confirm the parser extracts the symbol and direction correctly. The validator runs the alert through the same parser the live webhook uses.
Open the strategy's Integration tab and copy the webhook URL.
It has the form https://trades.nyria.io/webhooks/{strategy_token}.
Never share this URL — anyone with it can trigger your strategy.
On the Validation panel, paste one sample alert per enabled
direction. The minimum payload is two fields, ticker and action.
Click Validate. Nyria simulates the full lifecycle (entry parsed → bot would size → broker would accept → exit parsed → bot would flatten). All four steps must pass. Failures are shown inline with the parser's reasoning.
Sample long entry — JSON payload:
{
"ticker": "BTCUSDT",
"action": "buy",
"direction": "long"
}Sample short entry — JSON payload:
{
"ticker": "BTCUSDT",
"action": "sell",
"direction": "short"
}Sample long exit — JSON payload:
{
"ticker": "BTCUSDT",
"action": "exit",
"direction": "long"
}Sample short exit — JSON payload:
{
"ticker": "BTCUSDT",
"action": "exit",
"direction": "short"
}For the complete payload field list (price overrides, position size overrides, strategy variants), see Webhook Reference.
Step 4: Wire the alert source
The Pine Script below is a template — it emits a single message that Nyria's parser turns into the JSON above. Replace the strategy.entry / strategy.close lines with your own signal logic.
//@version=5
strategy("Nyria Perp Long/Short Template", overlay=true)
// --- your signal logic goes here ---
longCondition = ta.crossover(ta.sma(close, 9), ta.sma(close, 21))
shortCondition = ta.crossunder(ta.sma(close, 9), ta.sma(close, 21))
if longCondition
strategy.close("short", comment='{"ticker":"BTCUSDT","action":"exit","direction":"short"}')
strategy.entry("long", strategy.long, comment='{"ticker":"BTCUSDT","action":"buy","direction":"long"}')
if shortCondition
strategy.close("long", comment='{"ticker":"BTCUSDT","action":"exit","direction":"long"}')
strategy.entry("short", strategy.short, comment='{"ticker":"BTCUSDT","action":"sell","direction":"short"}')
// In your TradingView alert: set "Message" to {{strategy.order.comment}}
// and "Webhook URL" to your strategy's https://trades.nyria.io/webhooks/... URL.To use this:
- Paste it into the Pine editor and Add to chart.
- Click the alert clock on the strategy, set Condition to
Any alert() function call, set Message to{{strategy.order.comment}}, and set the Webhook URL to your Nyria strategy webhook. - Save the alert. TradingView will now POST the JSON in the
commentfield whenever Pine firesstrategy.entryorstrategy.close.
For the cURL equivalent (useful when testing without TradingView):
curl -X POST https://trades.nyria.io/webhooks/REPLACE_WITH_YOUR_STRATEGY_TOKEN \
-H "Content-Type: application/json" \
-d '{"ticker":"BTCUSDT","action":"buy","direction":"long"}'Replace REPLACE_WITH_YOUR_STRATEGY_TOKEN with the token from your strategy's Integration tab.
Step 5: Deploy a bot on Testnet (or a tiny live budget)
Do not point this at a real-money account on its first live alert. Use Binance Testnet first.
Go to Bots → Create Bot. Select the strategy you just validated.
Choose the connected Binance Testnet account. Confirm the account shows non-zero free margin.
Set the Budget Mode to Fixed Dollar with the per-entry margin value from your worksheet in Step 1. Remember: this is margin posted, not notional.
Set Multiple Entries to Disabled for the first 24 hours. Pyramiding multiplies margin usage; turn it on only after one-entry-at-a-time behavior is proven.
Click Deploy. The bot is now subscribed to your strategy's webhook and will act on the next inbound alert.
Step 6: Watch the first round-trip
When your first alert hits the webhook, two log streams update:
- Strategy logs (visible to anyone with view access to the strategy) record that the alert was parsed.
- Bot logs (visible only to you) record that your bot sized the order and the broker accepted, rejected, or errored.
Open both tabs side-by-side for the first entry. Common first-time issues:
| Symptom | Cause | Fix |
|---|---|---|
Strategy log says parsed but no bot log appears | Bot is paused, or has zero free margin | Resume the bot, or top up the account |
Bot log says Insufficient budget (...) | Per-entry budget is below the exchange's minimum order size | Increase the budget, or pick a higher-priced contract |
Bot log says No available balance (...) | Broker reports zero free margin — often a token refresh issue on the broker side | Re-authenticate the broker in Integrations |
| Order fills but reverses immediately | TradingView repaint on the alert candle | See TradingView repainting |
| Leverage on the exchange does not match the strategy setting | Pair was previously set to a different leverage in the exchange UI | Nyria sets leverage at order placement, but some exchanges cache it per-symbol. Force a re-set inside the exchange UI before the next entry. |
Step 7: Promote to live
Only after you have observed at least five full round-trips on Testnet (or a tiny live budget) with no error-level bot logs:
- Stop the Testnet bot.
- Create a new bot pointing at the Live Binance account.
- Start with a budget no larger than what you are willing to lose entirely on the first trade. Liquidation is a real outcome, not a theoretical one.
- Monitor for the first 24 hours, especially across a funding window (every 8 hours on the hour, UTC-aligned on both exchanges).
Nyria does not pause the bot if the exchange enters a maintenance window, halts the contract, or changes margin tiers. Your bot will keep forwarding alerts. If the exchange rejects the orders, the rejections surface in bot logs but no alert is sent. Subscribe to the exchange's status page directly.
Reference — Binance vs Coinbase perpetuals on Nyria
Coinbase columns describe the planned integration — Coinbase perpetuals are coming soon and cannot be connected yet.
| Binance | Coinbase (coming soon) | |
|---|---|---|
| Paper trading | Testnet (separate API key) | Not offered |
| Max leverage | 1×–125× (per-pair tiered) | 1×–10× |
| Funding interval | 8 hours | 8 hours |
| Pair format (alert) | BTCUSDT, BTC, BTCUSD — all accepted | BTCUSDT, BTC, BTC-USD — all accepted |
| Pair format (exchange) | BTCUSDT | BTC-PERP |
| Quote currencies | USDT, USDC | USD |
| Connection method | API key + secret (HMAC) | OAuth |
| Sub-account support | Yes (one Nyria integration per Binance sub-account) | Yes (one Nyria integration per Coinbase portfolio) |
For broker-side setup details, see the per-broker pages: Binance, Coinbase. For the exact webhook payload schema, see Webhook Reference.
Common pitfalls
- Sizing in dollars-of-notional instead of dollars-of-margin. Nyria's budget is margin. A
$1,000budget at 10× is$10,000of notional. If you meant$1,000of notional, set the budget to$100. - Forgetting that pyramiding compounds margin, not just notional. Three pyramided 10× entries at
$100each =$3,000notional and$300of margin tied up. The fourth entry can fail withInsufficient marginlong before you intended. - Holding through funding without a budget for it. A 10× long held for 30 days at 0.01% per 8-hour window (the long-run BTC average) pays roughly 0.09% per day of notional, or ~2.7% per month. On 10× margin that is ~27% of margin lost to funding alone, before any price movement.
- Assuming exit alerts close all entries. Nyria's exit logic closes positions in the direction the exit alert specifies. If you pyramided three long entries, a single long-exit alert closes all three (Nyria flattens by direction, not by entry). If you want partial closes, you must send multiple exits with explicit quantities — see Webhook Reference.
- Switching leverage after the position is open. Both exchanges only allow leverage changes on flat positions. Changing the strategy's leverage field while a bot has an open position has no effect on that position — it only applies to the next entry.
Next steps
- Bots — pyramiding, budget modes, and pause rules.
- Trading Behavior — the full matrix of entry/exit/flip behaviors.
- Risk Disclosure — read before going live.
- Binance broker reference
- Coinbase broker reference
- Webhook Reference — every field the parser will recognize.