> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cryptechtoday.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Portfolio Risk Monitor

> Run automated cron audits on user wallet holdings to detect stealth rugpulls and contract upgrades

# Portfolio Risk Monitor

Build a background worker that scans all ERC-20 / SPL tokens held in a user's wallet every 6 hours to detect malicious proxy upgrades, liquidity drains, or dynamic tax elevations.

***

## Workflow

1. Retrieve token balances for user address via RPC.
2. Query CrypTech `POST /api/v1/analyze` for each token.
3. If `total_score < 70` or `is_honeypot == True`, immediately alert the user via Telegram or email.

***

## Implementation Script

```python theme={null}
import os
import requests

CRYPTECH_API_KEY = os.getenv("CRYPTECH_API_KEY")

USER_HOLDINGS = [
    {"symbol": "LINK", "address": "0x514910771AF9Ca656af840dff83E8264EcF986CA", "chain": "ethereum"},
    {"symbol": "UNI",  "address": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "chain": "ethereum"}
]

def audit_portfolio(holdings):
    url = "https://api.cryptechtoday.com/api/v1/analyze"
    headers = {
        "X-API-Key": CRYPTECH_API_KEY,
        "Content-Type": "application/json"
    }

    for token in holdings:
        res = requests.post(url, json={"address": token["address"], "chain": token["chain"]}, headers=headers)
        if res.status_code != 200:
            continue

        audit = res.json()
        score = audit.get("total_score", 0)
        risk = audit.get("risk_label", "UNKNOWN")
        is_honeypot = audit.get("raw_summary", {}).get("is_honeypot", False)

        if is_honeypot or score < 60:
            print(f"🚨 CRITICAL ALERT: {token['symbol']} scored {score}/100 [{risk}]! Withdraw immediately.")
        else:
            print(f"✅ {token['symbol']} Verified Safe ({score}/100)")

if __name__ == "__main__":
    audit_portfolio(USER_HOLDINGS)
```


## Related topics

- [Market Regime](https://docs.cryptechtoday.com/api-reference/market-regime.md)
- [Token Security Flags](https://docs.cryptechtoday.com/api-reference/token-security.md)
- [Market Pulse](https://docs.cryptechtoday.com/api-reference/market-pulse.md)
- [Analyze Token](https://docs.cryptechtoday.com/api-reference/analyze-token.md)
- [Recent Audits](https://docs.cryptechtoday.com/api-reference/recent-scans.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.