Hi Support team,
Please check this below stratagy conditions, the FIA GPT also not able to create the stratagy.
Stratagy:
Please update the BANK NIFTY weekly Short Strangle automation with the following complete logic.
STRATEGY:
- Underlying: NSE:NIFTYBANK-INDEX
- Trade type: WEEKLY OPTIONS
- This is NOT an intraday strategy.
- Do not use intraday-only assumptions.
- Positions can remain open through the trading session until the defined strategy exit.
==================================================
Select the current weekly BANK NIFTY options:
CE:
- Select the strike whose delta is closest to +0.15.
- SELL the selected CE.
PE:
- Select the strike whose delta is closest to -0.15.
- SELL the selected PE.
Store the initial values in runtime variables:
Initial_CE_Strike
Initial_PE_Strike
Initial_CE_Symbol
Initial_PE_Symbol
Initial_CE_Entry_Premium
Initial_PE_Entry_Premium
Initial_Quantity
Also maintain the CURRENT position variables:
Current_CE_Strike
Current_PE_Strike
Current_CE_Symbol
Current_PE_Symbol
Current_CE_LTP
Current_PE_LTP
==================================================
- INITIAL PREMIUM AND 80% PROFIT TARGET
Immediately after the initial CE and PE entries, calculate:
Combined Initial Premium =
Initial_CE_Entry_Premium + Initial_PE_Entry_Premium
Initial Premium Value =
Combined Initial Premium × Initial_Quantity
Overall Target Value =
Initial Premium Value × 80%
Store this target in a runtime variable:
Overall_Target_Value
IMPORTANT:
Overall_Target_Value must be calculated ONLY from the INITIAL CE and PE entry premiums.
Do NOT recalculate the 80% target using replacement option premiums after an adjustment.
The target remains fixed for the entire weekly strategy.
Example:
Initial CE entry premium = ₹100
Initial PE entry premium = ₹80
Quantity = 30
Combined Initial Premium =
₹100 + ₹80 = ₹180
Initial Premium Value =
₹180 × 30 = ₹5,400
Overall Target Value =
₹5,400 × 80% = ₹4,320
The strategy target remains ₹4,320 even if CE or PE is subsequently adjusted.
==================================================
- COMPLETE STRATEGY P&L
Continuously calculate the TOTAL STRATEGY P&L.
The total strategy P&L must include:
A. Realized P&L from every option leg that has already been exited.
B. Unrealized P&L of the currently open CE and PE positions.
For a short option:
Current Unrealized P&L =
Entry Premium - Current LTP
× Quantity
For an exited short option:
Realized P&L =
Entry Premium - Exit Premium
× Quantity
TOTAL STRATEGY P&L =
Total Realized P&L from all completed legs
+
Unrealized P&L from all currently open legs
Do NOT calculate P&L only from the current CE and PE.
Do NOT reset P&L after an adjustment.
Do NOT reset the target after an adjustment.
All previous realized profits/losses must continue to be included.
==================================================
- 80% PROFIT TARGET EXIT
Continuously compare:
Total_Strategy_PnL >= Overall_Target_Value
IF TRUE:
- Exit ALL currently open CE and PE positions.
- Square off the complete strategy.
- Stop the automation.
- Send a notification showing:
- Initial Premium Value
- Fixed 80% Target Value
- Final Total Strategy P&L
- Number of adjustments performed
Example:
Initial Premium Value = ₹5,400
80% Target = ₹4,320
After adjustments:
Realized P&L = ₹1,200
Current CE unrealized P&L = ₹1,700
Current PE unrealized P&L = ₹1,500
Total Strategy P&L =
₹1,200 + ₹1,700 + ₹1,500
= ₹4,400
Since:
₹4,400 >= ₹4,320
→ EXIT ALL OPEN POSITIONS
→ STOP AUTOMATION
==================================================
- PREMIUM IMBALANCE ADJUSTMENT
Continuously monitor:
Current_CE_LTP
Current_PE_LTP
Adjustment condition:
IF Current_CE_LTP >= 2 × Current_PE_LTP
Then:
- CE is approximately 100% higher than PE.
- PE is the smaller-premium leg.
- Exit ONLY the current PE position.
- Keep CE open.
Then select a new weekly BANK NIFTY PE.
The replacement PE:
- Must be the same option type: PE.
- Must have premium near to or below Current_CE_LTP.
- Must NOT have premium greater than Current_CE_LTP.
- Must be dynamically selected from the weekly option chain.
After the replacement PE SELL is successfully completed:
Update:
Current_PE_Strike = New PE Strike
Current_PE_Symbol = New PE Symbol
Current_PE_LTP = New PE LTP
Do NOT continue monitoring the old PE contract.
Similarly:
IF Current_PE_LTP >= 2 × Current_CE_LTP
Then:
- PE is approximately 100% higher than CE.
- CE is the smaller-premium leg.
- Exit ONLY the current CE position.
- Keep PE open.
Then select a new weekly BANK NIFTY CE.
The replacement CE:
- Must be the same option type: CE.
- Must have premium near to or below Current_PE_LTP.
- Must NOT have premium greater than Current_PE_LTP.
After the replacement CE SELL is successfully completed:
Update:
Current_CE_Strike = New CE Strike
Current_CE_Symbol = New CE Symbol
Current_CE_LTP = New CE LTP
Do NOT continue monitoring the old CE contract.
==================================================
- IMPORTANT — P&L AFTER ADJUSTMENT
When a leg is adjusted:
Example:
Original PE:
SELL PE at ₹100
EXIT PE at ₹40
Realized PE profit =
₹100 - ₹40 = ₹60 × quantity
Then a new PE is sold at ₹90.
The ₹60 realized profit must remain part of Total Strategy P&L.
The new PE starts its own unrealized P&L calculation from ₹90.
Therefore:
Total Strategy P&L =
Previous Realized P&L
+
Current CE Unrealized P&L
+
New PE Unrealized P&L
+
Any other realized P&L from previous adjustments.
The automation MUST NOT lose or reset the previous realized P&L.
==================================================
- ADJUSTMENT EXECUTION LOCK
Once an adjustment condition becomes TRUE:
- Exit the smaller-premium leg.
- Wait until the exit is confirmed.
- Select the replacement option.
- Sell the replacement option.
- Wait until the replacement entry is confirmed.
- Update the appropriate runtime symbol and strike variables.
- Update the current LTP reference.
- Only then resume premium monitoring.
Do not trigger another adjustment while the previous adjustment is still executing.
Do not repeatedly exit/re-enter the same leg because the condition remains TRUE.
==================================================
- STRADDLE CONDITION
If:
Current_CE_Strike == Current_PE_Strike
then identify the position as a STRADDLE.
If the position becomes a straddle:
- Do not automatically replace a leg just because the strikes are equal.
- Continue monitoring the current CE and PE LTP.
If either leg reaches:
CE_LTP >= 2 × PE_LTP
OR
PE_LTP >= 2 × CE_LTP
then:
→ EXIT THE COMPLETE STRATEGY
→ Square off all open positions
→ Stop automation.
==================================================
- 03:10 PM PREMIUM BALANCE CHECK
At 03:10 PM, calculate:
Premium Difference % =
ABS(Current_CE_LTP - Current_PE_LTP)
/
MIN(Current_CE_LTP, Current_PE_LTP)
× 100
If the difference is 30% or less:
→ Continue according to the normal strategy exit rules.
If the difference is greater than 30%:
- Identify the smaller-premium leg using the runtime LTP comparison.
- Exit ONLY the smaller-premium leg.
- Keep the higher-premium leg open.
- Select a new weekly option of the SAME option type as the exited leg.
- The replacement premium must be near to or below the higher-premium leg’s current LTP.
- The replacement premium MUST NOT be greater than the higher-premium leg.
- Sell the replacement option.
- Update the appropriate Current_CE/Current_PE runtime variables.
- Continue monitoring.
The 03:10 PM adjustment must also preserve all previously realized P&L.
==================================================
- WEEKLY EXPIRY EXIT
This is a weekly-options strategy.
At the defined weekly expiry/end-of-day exit time:
- Calculate the complete Total Strategy P&L.
- Exit all remaining open positions.
- Stop the automation.
The final P&L must include:
- All realized P&L from previous adjustments.
- Unrealized P&L from the final open CE.
- Unrealized P&L from the final open PE.
- Any applicable charges if available in the P&L calculation.
==================================================
- CRITICAL RUNTIME VARIABLE REQUIREMENT
The automation must maintain the CURRENT active contracts.
Initial:
Current_CE_Symbol = Initial CE
Current_PE_Symbol = Initial PE
After PE adjustment:
Current_PE_Symbol = New PE
After CE adjustment:
Current_CE_Symbol = New CE
All subsequent LTP checks and P&L calculations must use the CURRENT active contracts.
Never continue querying the original contracts after they have been replaced.
Do not hard-code:
- Option symbols
- Replacement strikes
- Replacement premiums
- ₹200 premium placeholders
Use runtime variables wherever the Automate nodes support runtime references.
==================================================
- PRIORITY OF EXIT CONDITIONS
The 80% target is the primary strategy-level profit exit.
At every monitoring cycle, evaluate:
-
Total Strategy P&L >= Overall Target Value
→ EXIT COMPLETE STRATEGY. -
Straddle condition as defined above
→ EXIT COMPLETE STRATEGY when its specified 2× condition occurs. -
Premium imbalance >= 2×
→ Adjust only the smaller-premium leg unless the straddle rule applies. -
03:10 PM premium difference >30%
→ Adjust the smaller-premium leg according to the defined 03:10 PM rule. -
Weekly expiry/end-of-day
→ EXIT COMPLETE STRATEGY.
IMPORTANT:
The Overall_Target_Value is fixed from the INITIAL premium and quantity.
It must never be recalculated after adjustments.
Please implement this using runtime variables and runtime references wherever supported. Do not replace runtime values with static placeholders.