Due to SEBI regulations, market orders are blocked on Stratzy. This causes two problems when placing manual credit spread orders with LTP-based limit orders:
Problem 1 — Sell fills before buy:
If the sell leg executes first, the broker rejects it due to margin shortfall (hedge not in place yet). Order missed.
Problem 2 — Buy fills, sell never does:
If the buy leg fills but the sell leg price never hits, the hedge is broken and the spread is incomplete.
Two Fixes:
-
Slippage input — Let the user set a slippage % (e.g. 5%). Adjust the limit price by that % so orders fill faster. At 0% slippage, behaviour stays exactly as today.
-
Sequential order placement with Retry — Send the buy leg first. Only after it confirms filled, send the sell leg. This ensures the hedge is always in place before the sell goes out.
Expected Order Flow
STEP 1: Fetch LTP of buy leg (Nifty 24400 CE)
ltp_buy = getLTP("Nifty 24400 CE") → 20
if slippage == 0%:
buy_price = ltp_buy → 20
else:
buy_price = ltp_buy * (1 + slippage) → 20 * 1.05 = 21
PLACE LIMIT BUY ORDER → Nifty 24400 CE @ 21
STEP 2: Wait & monitor buy leg order status
if status == FILLED:
→ proceed to STEP 3
if status == PENDING after timeout:
→ CANCEL order
→ re-fetch LTP, recalculate price, RETRY (max 3 attempts)
if status == REJECTED:
→ LOG error, ABORT entire spread (do NOT place sell leg)
STEP 3: Buy leg confirmed FILLED → Now place sell leg
ltp_sell = getLTP("Nifty 24000 CE") → 100 (re-fetch fresh LTP)
if slippage == 0%:
sell_price = ltp_sell → 100
else:
sell_price = ltp_sell * (1 - slippage) → 100 * 0.95 = 95
PLACE LIMIT SELL ORDER → Nifty 24000 CE @ 95
STEP 4: Wait & monitor sell leg order status
poll order status every N seconds
if status == FILLED:
→ SPREAD COMPLETE
→ LOG entry price = sell_price - buy_price = 95 - 21 = 74 (net credit)
if status == PENDING after timeout:
→ CANCEL order
→ re-fetch LTP, recalculate price, RETRY (max 3 attempts)
if status == REJECTED after all retries:
→ CRITICAL ALERT
→ hedge is BROKEN (buy leg filled, sell leg failed)
→ NOTIFY user immediately

