Skip to content

upendra-tess/rwa_agent

Repository files navigation

RWA Agent — Real-World Asset Investment Analysis Engine

An autonomous multi-agent system for macro-level analysis of tokenized real-world asset (RWA) investments. Five specialized sub-agents pull live data from 15+ free APIs and synthesize a unified macro score, sector recommendations, and investment strategy.


Architecture

run_macro_analysis(customer_profile)
│
├── IndustryAnalysisAgent      ← CoinGecko + DeFiLlama
├── FinancialAnalysisAgent     ← Treasury.gov + WorldBank + FRED + ECB + DeFiLlama
├── CashFlowAgent              ← DeFiLlama Yields API + GeckoTerminal
├── GeopoliticalAnalysisAgent  ← GDELT + OFAC + IMF + Comtrade + ECB + CoinGecko
└── MarketAnalysisAgent        ← CoinGecko + Fear&Greed + GDELT + Reddit + GeckoTerminal
         │
         ▼
   MacroAgent (aggregator)
   → overall_macro_score (0–100)
   → recommended_asset_types
   → investment summary

Live Data Sources (15+)

# Source What it provides Agent(s)
1 FRED API Fed funds rate, Treasury yields, CPI, VIX, NFCI, GDP Industry, Financial
2 IMF Data API Global GDP, inflation, debt, current account Industry, Financial, Geo
3 World Bank API 16,000+ country indicators (GDP, FDI, credit) All agents
4 Chicago Fed NFCI Financial conditions index (via FRED) Financial
5 ECB Data Portal Euro-area rates, EURIBOR, FX Financial, Geo
6 Atlanta Fed GDPNow US real-time GDP nowcast (via FRED) Industry
7 GDELT Global news/events, geopolitical shocks Geo, Market
8 OFAC Sanctions Sanctions list screening, blocked jurisdictions Geo
9 UN Comtrade Trade flows, cross-border exposure Cash Flow, Geo
10 DeFiLlama TVL, protocols, yield pools, stablecoins All agents
11 CoinGecko Token prices, market caps, RWA category Industry, Financial, Market
12 GeckoTerminal DEX liquidity, trending pools, on-chain volume Cash Flow, Market
13 Alternative.me Crypto Fear & Greed Index Market
14 RWA.xyz Tokenized asset metrics, holders, networks All agents
15 Alpha Vantage News & sentiment API Market
16 Reddit API Public discussion, narrative sentiment Market

Quick Start

1. Install dependencies

pip install -r requirements.txt

2. Set API keys (optional — agents degrade gracefully without them)

export FRED_API_KEY=your_fred_key           # https://fred.stlouisfed.org/docs/api/api_key.html
export ALPHA_VANTAGE_KEY=your_av_key        # https://www.alphavantage.co/support/#api-key
export COMTRADE_KEY=your_comtrade_key       # https://comtradeapi.un.org

3. Run analysis

from agents.macro_analysis import run_macro_analysis

profile = {
    "risk_tolerance": "moderate",       # conservative | moderate | aggressive
    "investment_horizon": "medium",     # short | medium | long
    "target_roi_pct": 15.0,
    "budget_usd": 10000,
    "jurisdiction": "US",               # US | EU | SG | CH | AE | HK | JP | UK
}

result = run_macro_analysis(profile)
print(result["overall_macro_score"])        # 0-100
print(result["recommended_asset_types"])    # e.g. ['TokenizedTreasury', 'PrivateCredit']
print(result["summary"])                    # human-readable narrative

4. Run API server

python main.py

Endpoints:

  • POST /analyze — run macro analysis with a customer profile
  • GET /health — health check

Agent Details

Industry Analysis Agent

Classifies tokenized RWA sectors (Treasury/Yield, Private Credit, Real Estate, Commodities, DeFi) from live CoinGecko RWA token data and DeFiLlama protocol TVL. Scores each sector against the customer's risk tolerance and target ROI.

Financial Analysis Agent

Analyzes macroeconomic financial conditions: interest rates (Treasury.gov + FRED), inflation and GDP (World Bank + IMF), financial conditions (Chicago Fed NFCI), euro-area context (ECB), and DeFi yield environment (DeFiLlama). Recommends investment duration.

Cash Flow Agent

Evaluates yield opportunities from DeFiLlama's pools API (50+ pools). Scores each pool by APY adequacy, TVL/liquidity depth, stablecoin stability, and organic yield ratio. Projects annual income against the customer's budget.

Geopolitical Analysis Agent

Scores 9 global jurisdictions on regulatory clarity, political stability, framework maturity, and sanctions risk. Augments with live GDELT news events, OFAC sanctions list, IMF data, UN Comtrade trade flows, and ECB rates for macro transmission.

Market Analysis Agent

Detects market regime (Risk-On / Neutral / Risk-Off / Capitulation) using live Fear & Greed index, BTC 30d price changes, and volatility estimates. Incorporates GDELT headlines, Reddit sentiment, GeckoTerminal DEX liquidity, and CoinGecko RWA token momentum.


Output Structure

{
  "overall_macro_score": 59,
  "agents_completed": "5/5",
  "recommended_asset_types": ["PrivateCredit", "TokenizedCommodities", "TokenizedRealEstate", "TokenizedTreasury"],
  "summary": "🟡 Macro environment is NEUTRAL — selective opportunities exist...",
  "industry_analysis": { ... },
  "financial_analysis": { ... },
  "cash_flow_analysis": { ... },
  "geopolitical_analysis": { ... },
  "market_analysis": { ... }
}

Project Structure

rwa_agent/
├── agents/
│   └── macro_analysis/
│       ├── __init__.py
│       ├── data_pipeline.py          ← All 15+ API integrations
│       ├── macro_agent.py            ← Orchestrator / aggregator
│       ├── industry_analysis_agent.py
│       ├── financial_analysis_agent.py
│       ├── cash_flow_agent.py
│       ├── geopolitical_analysis_agent.py
│       └── market_analysis_agent.py
├── agent_graph.py                    ← LangGraph workflow
├── api.py                            ← FastAPI server
├── main.py                           ← Entry point
├── state.py                          ← Shared state types
├── requirements.txt
├── frontend/                         ← React frontend
└── tess-flow/                        ← Vite/React frontend (TessFlow)

Graceful Degradation

APIs that require keys or have network restrictions fail silently — agents still complete using available open sources:

API Status without key
FRED Skipped (returns empty dict)
Alpha Vantage Skipped (returns empty articles)
RWA.xyz Falls back to DeFiLlama RWA data
UN Comtrade Requires free API key registration
IMF Returns 403 on some IPs — fallback to World Bank
GDELT Rate-limited (429) — returns empty articles
Reddit Network timeout on some hosts — gracefully skipped

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors