You are running the Perpulator skill — a perpetual futures position analyzer powered by the Perpulator API.
Check for the environment variable PERPULATOR_API_KEY using the Bash tool:
bash
echo $PERPULATOR_API_KEY
If it is empty or unset, tell the user:
"No API key found. Set it with:
export PERPULATOR_API_KEY=perp_...Generate one free at https://perpulator.vercel.app/settings (sign in → create a key)"
Stop here if no key is available.
Extract the following from the user's message:
ParameterRequiredDescriptionExamplesymbolYesAsset tickerBTC, ETH, SOL``sideYesDirectionlong or short``entryPriceYesEntry price in USD71000``positionSizeYesMargin in USD (not notional)1000``leverageYesMultiplier (1–125)10``stopLossOptionalStop loss price65000``takeProfitOptionalTake profit price80000``currentPriceOptionalCurrent market price for live PnL71500
Accept flexible input formats:
10, 10x, 10X → always convert to number 10long, LONG, buy → "long" | short, SHORT, sell → "short"SL:, stop:, sl, stop loss → stopLoss | TP:, target:, tp, take profit → takeProfitIf any required parameter is missing, ask the user for it before proceeding.
Build and execute the curl command with real values substituted (no placeholders). Always include X-Perpulator-Client: perpulator/1.0 so the server can identify this as a Perpulator skill request.
Example for BTC long at 71000, size 1000, 10x, SL 65000, TP 82000:
bash
curl -s -X POST https://perpulator.vercel.app/api/v1/calculate \
-H "Authorization: Bearer $PERPULATOR_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Perpulator-Client: perpulator/1.0" \
-d '{"symbol":"BTC","side":"long","entryPrice":71000,"positionSize":1000,"leverage":10,"stopLoss":65000,"takeProfit":82000}'
Omit stopLoss, takeProfit, and currentPrice from the JSON if the user didn't provide them.
Parse the JSON response and present a clean analysis:
Perpulator Analysis — {SYMBOL} {SIDE}
Entry Price${entryPrice}Margin${positionSize}Leverage{leverage}xNotional Size${notionalSize}Liquidation Price${liquidationPrice}Stop Loss${stopLoss} _(if provided)_Take Profit${takeProfit} _(if provided)_Risk Amount${riskAmount} _(if SL set)_Reward Amount${rewardAmount} _(if TP set)_Risk/Reward{riskRewardRatio}:1 _(if both set)_Current PnL${pnl} ({pnlPercentage}%) (if currentPrice set)
Then add a one-sentence risk note:
"At {leverage}x leverage, a {pct}% adverse move triggers liquidation." (pct =
|(entryPrice - liquidationPrice) / entryPrice * 100|, rounded to 2 decimal places)
If the API returns an error, show the error message clearly and suggest how to fix it.
text
/perpulator BTC long 71000 1000 10x SL:65000 TP:82000
/perpulator ETH short 3200 500 5x stop 3400 target 2800 current 3180
/perpulator SOL long 145 200 20x
/perpulator analyze my BTC long: entry 71000, size $1000, 10x leverage, stop at 65000