Skip to content

Repository files navigation

SIPPM Algorithm Documentation

Systematic Investment Plan for Precious Metals
Version: 1.2
Author: Swapnil Sharma
Last Updated: May 18, 2025


Objective

The SIPPM algorithm is designed to automatically monitor a user's precious metal portfolio (Gold, Silver, Platinum, Palladium) and rebalance it based on configurable thresholds, volatility factors, and market price changes—ensuring an optimized and diversified investment strategy.


Core Inputs

Parameter Description
investment_amount Total user investment (e.g., ₹100,000)
rates Current metal rates (₹ per gram)
previous_rate Rate used during last purchase or rebalance
allocation_percent User's target allocation for each metal
volatility_factor Adjustment factor based on historical price volatility
transaction_cost Fixed % per buy/sell trade for that metal
min_trade_amount Minimum trade amount to be executed (e.g., ₹200)
delta_threshold Acceptable % deviation before triggering rebalance

Walkthrough: How It Works

Step 1: Load User Portfolio

  • Retrieve user metals with fields: symbol, weight (grams), previous_rate, allocation_percentage.
  • Calculate current_value = weight * current_rate.

Step 2: Market Rate Update

  • Fetch real-time INR rate for all metals.
  • Recalculate total current value of the portfolio.

Step 3: Delta Calculation

For each metal:

actualPercent = (currentValueOfMetal / totalPortfolioValue) * 100  
delta = actualPercent - allocationPercent  
adjustedDelta = delta * volatilityFactor  
  • If abs(adjustedDelta) > deltaThreshold, the metal qualifies for rebalance.

Step 4: Weighted Dynamic Selling

  • Metals above allocation → mark for SELL.
  • Calculate how much to sell to move back to target allocation.
  • Account for transactionCost and skip trades under min_trade_amount.

Step 5: Dynamic Buying

  • Distribute freed cash from selling among under-allocated metals.
  • Instead of equal buy, prioritize metals with:
    • Highest negative delta
    • Lower volatility (safer bets)
  • Use weightage proportional to:
(abs(delta) * (1 - volatilityFactor))

Step 6: Transaction Simulation

  • Simulate buy/sell based on cash available.
  • Calculate expected new weights & project new portfolio allocation.
  • Apply transactionCost to both buy and sell amounts.

Step 7: Persist and Log

  • Record all rebalanced units and new weights.
  • Log transactions with:
    • metal, units, action, price, value
    • date/time, user_id, delta breached

Features Implemented

Feature Description
Capped Daily Rebalancing Limit rebalance to once/day/user
Volatility-Based Delta Adjusts sensitivity per metal
Transaction Cost Simulation Includes trading fees in logic
Minimum Trade Amount Skips micro trades
Threshold Tolerances Prevents over-rebalancing
Weighted Dynamic Selling Sell based on deviation magnitude
Dynamic Buying Buy based on need, not equally
INR-Based Investment All values calculated in ₹

Sample Snapshot (Before Rebalance)

[
  {
    "metal": "GOLD",
    "weight": 5.2,
    "previous_rate": 9215.72,
    "current_rate": 9250.0,
    "allocation_percent": 40.0,
    "actual_percent": 45.0,
    "delta": 5.0,
    "volatility_factor": 1.1,
    "transaction_cost": 0.01
  }
]

Smart Behaviors

  • Cash pool is retained if not enough under-allocated metals are found.
  • Trade batcher accumulates trades until they meet the min_trade_amount.
  • Cap limit: Only X metals rebalanced per cycle (e.g., 3).

Future Enhancements

  • Machine Learning-based prediction for weight adjustment.
  • User-level volatility override.
  • Threshold auto-adjustment based on market activity.

About

Dynamic Metal Investment Platform Automated Diversification for Maximum Returns

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages