reedem or buy, stcg after 2pm, knwing % raise nifty50
# Inputs
nifty_pct = 3.3 # Example: 2.3% rise till 2PM
nifty_pe = 24.0 # High valuation
total_capital = 5_00_000
sip_component = 3_00_000
dip_component = 5_00_000
liquid_component = 2_00_000
# Assumed values for logic
buy_pct = 0.0
redeem_pct = 0.0
buy_reason = ""
redeem_reason = ""
# Assumed gains and holding info
# You should track how long your investments are held
estimated_redeem_profit = 1.5 * 1e5 # ₹1.5L profit
is_short_term = True # True = STCG
# Buy logic
if nifty_pct <= -1.0:
if nifty_pe < 18:
buy_pct = 0.5
buy_reason = "š Deep dip + undervalued"
elif nifty_pe <= 23:
buy_pct = 0.3
buy_reason = "š Dip + fair valuation"
else:
buy_pct = 0.1
buy_reason = "š Dip + overvalued market"
# Redeem logic
if nifty_pct >= 2.0 and nifty_pe > 23:
redeem_pct = 0.3
redeem_reason = "š Big rally + high PE → book profits"
# Calculate amounts
buy_amount = int(buy_pct * dip_component)
redeem_amount = int(redeem_pct * dip_component)
# Tax logic
if is_short_term:
tax = 0.15 * estimated_redeem_profit # 15% STCG
else:
gain_above_exempt = max(0, estimated_redeem_profit - 1e5)
tax = 0.10 * gain_above_exempt # 10% LTCG if applicable
# Final net redemption
net_redeem = redeem_amount - int(tax)
# Output
print("š Nifty Today:", nifty_pct, "%")
print("š Nifty PE:", nifty_pe)
print("\nš° Buy Recommendation:")
print(f"→ {buy_reason}, Buy ₹{buy_amount} from dip reserve.")
print("\nšø Redeem Recommendation:")
print(f"→ {redeem_reason}, Redeem ₹{redeem_amount}")
print(f"š¦ Estimated Gain: ₹{int(estimated_redeem_profit)}")
print(f"šø Tax Applied: ₹{int(tax)} ({'STCG' if is_short_term else 'LTCG'})")
print(f"✅ Net Amount Redeemable: ₹{net_redeem}")