Oracle3
Open-source trading engine and MCP server for prediction markets. Fee-aware no-arbitrage trading across related contracts, live on Kalshi, Polymarket and Solana or on paper.
Stop reading documents. Start making decisions.
Translation pending
FinancePython · TypeScriptGitHub @AdarshMuraliOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
No updates detected yet. GitHub releases will appear here.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
Agentic, event-driven platform automating the margin call lifecycle - LLM agent orchestration, RAG over legal/policy docs, real-time streaming, human-in-the-loop approvals.
Taken from the repository README
Loading the full README. The saved excerpt is shown below.
An agentic, event-driven platform that automates the end-to-end margin call lifecycle — from market event to client notification, escalation, and audit — using LLM agent orchestration, a RAG pipeline over legal/policy documents, and a real-time streaming backbone.Read the full README ↗An agentic, event-driven platform that automates the end-to-end margin call lifecycle — from market event to client notification, escalation, and audit — using LLM agent orchestration, a RAG pipeline over legal/policy documents, and a real-time streaming backbone.
Status: ✅ Live on Google Cloud. API, MCP servers and event consumers on Cloud Run; Cloud SQL Postgres + pgvector; Gemini on Vertex AI; the "Ask the Desk" ADK agent on Agent Platform; frontend on Firebase App Hosting + Vercel. The project was first built and fully deployed as a standalone production stack on AWS — EC2, Secrets Manager, S3, IAM — with Azure SQL and OpenAI driving the same agent pipeline, proving the architecture end to end before it was adapted to the GCP-native services below. See
docs/gcp/GCP_ROADMAP.mdanddocs/gcp/GCP_PROGRESS.mdfor the GCP track,docs/ROADMAP.md/docs/PROGRESS.mdfor the original AWS-era phases.
This is the Google Cloud deployment (the hackathon submission) — everything below runs on Cloud Run, Cloud SQL and Vertex AI, not AWS.
| App (Google Cloud) | https://marginmaestro-web--marginmaestro-demo.us-central1.hosted.app |
| App (mirror) | https://marginmaestro.vercel.app — identical frontend, same Google Cloud API behind it |
| API | https://marginmaestro-api-pkjc2r5ivq-uc.a.run.app (/health, /docs for the OpenAPI schema) |
Cloud Run scales to zero when idle, so the first request after a quiet period can take 10-20s to cold-start — that's expected, not a hang.
Sign in at /login with one of the seeded demo accounts (also the default values of demo_approver_password / demo_manager_password / demo_analyst_password / demo_auditor_password in src/config/settings.py — nothing sensitive, these exist purely to gate the demo dashboard):
| Username | Password | Role | Can do |
|---|---|---|---|
approver | MarginMaestro!Approver1 | Approver | Approve / reject / adjust a margin call; respond to its SLA |
manager | MarginMaestro!Manager1 | Manager | Everything approver can, plus the required second sign-off on elite-tier counterparties |
analyst1 | MarginMaestro!Analyst1 | Margin analyst (viewer) | Read-only, own book only: CP-1 … CP-4 |
analyst2 | MarginMaestro!Analyst1 | Margin analyst (viewer) | Read-only, own book only: CP-5 … CP-8 |
auditor | MarginMaestro!Auditor1 | Auditor | Read-only, every counterparty incl. system-level audit rows |
Every page except the public landing page needs a login, and the backend scopes every read to the caller: on Postgres, row-level security in the database itself hides other analysts' counterparties (MM-106). The approver, manager and auditor see all counterparties.
This is a portfolio demo running on the project owner's own Google Cloud/Slack/WhatsApp accounts — please don't script/load-test it. A handful of clicks is exactly what it's for.
approver (elite-tier counterparties additionally need manager's second sign-off before the client notice goes out).Prefer to watch it happen end-to-end without clicking? Clone the repo and run the same scenario the API itself uses for demos:
pip install -e ".[dev]"
python -m demo.run_demo --base-url https://marginmaestro-api-pkjc2r5ivq-uc.a.run.app
In capital markets, a margin call is the process of demanding additional collateral when market moves erode the coverage on a portfolio of derivatives, repo, or financed positions. The call itself is simple arithmetic — but everything around it is not: interpreting bespoke legal agreements (CSAs), reconciling disputed valuations, choosing which collateral to post, notifying the counterparty, chasing non-response, escalating, and keeping a defensible audit trail.
Historically this is done with spreadsheets, email, and phone calls, and it is dangerously blind to the future — firms can tell you today's call but struggle to anticipate tomorrow's, which is exactly what caused margin-driven blow-ups in 2008, March 2020, the 2022 UK LDI crisis, Archegos, and LME nickel.
MarginMaestro models the full lifecycle as a mesh of specialized AI agents coordinated by an orchestrator, reacting to market events in real time, grounding its decisions in the actual legal and policy documents via RAG, and keeping a human in the loop for the decisions that matter.
docs/architecture/functional-architecture.svg — the business-process view, in the same visual language as the tech diagrams below: detect & evaluate → decide (approval + second sign-off) → notify (WhatsApp + Slack) → respond & escalate (SLA timer → ServiceNow) → transparency (audit, lineage, reporting), with the actual touchpoints (WhatsApp, Slack, ServiceNow, Gemini, Firebase) called out where a real product is used.docs/architecture/functional-lifecycle.svg — the same lifecycle at the implementation level: every LangGraph node from compute_exposure through approval, notification, and SLA/escalation, color-coded by CLAUDE.md's golden rule (deterministic code vs. LLM reasoning/RAG vs. hybrid vs. the human-approval gate).docs/architecture/tech-architecture.svg — the original AWS deployment the project was first built and fully proven on: AWS (EC2 + Elastic IP, Secrets Manager, S3, IAM), Vercel, Azure SQL, the CI/CD pipeline, and the third-party integrations (OpenAI, Slack, ServiceNow), with a clearly separated box for what's local-dev-only (Kafka/Redpanda, OTel/Prometheus/Grafana) and not part of either deployment.docs/architecture/gcp-tech-architecture-blue.svg and gcp-tech-architecture-multicolor.svg — the live Google Cloud architecture (the GCP track in docs/gcp/GCP_ROADMAP.md): Cloud Run services (API, MCP tool servers private to the desk agent), Firebase App Hosting + Firestore live status, Pub/Sub and Cloud Tasks, Gemini on Vertex AI with Agent Platform (Sessions, Memory Bank, Gen AI evaluation in CI), Model Armor and Sensitive Data Protection, Cloud SQL + pgvector with row-level security, BigQuery + Dataplex + Data Lineage, the security/operations layer (including CodeQL/Dependabot/SonarCloud/Trivy/Checkov/gitleaks in CI), WhatsApp/Slack/ServiceNow, and the GitHub Actions → Docker Hub → Cloud Run (keyless WIF) deploy path. Same diagram in two icon styles: Google Cloud's official blue product icons, and its official four-colour core/category icons. PNG copies sit alongside each SVG.See docs/ARCHITECTURE.md for the full written design, and docs/AGENT_ORCHESTRATION_FAQ.md for which parts are deterministic code vs. LLM-driven, and what happens end-to-end when a real (not simulated) market move triggers a run.
| Layer | Choice | Notes |
|---|---|---|
| Agent orchestration | LangGraph (margin-call workflow) + Google ADK (desk assistant) | Fixed, auditable state-graph for the lifecycle on Cloud Run; a conversational ADK agent on Agent Platform for analyst Q&A (ADR-0019) |
| LLM | Gemini on Vertex AI | Reasoning, retrieval and drafting only, never math; every call screened by Model Armor + in-code guardrails, with Sensitive Data Protection masking (OpenAI remains a supported fallback via LLM_PROVIDER) |
| Embeddings | Vertex AI text embeddings | Query/document embeddings share one model |
| RAG + relational store | Cloud SQL Postgres + pgvector | Positions, ratings, calls, audit log and RAG chunks in one database, with row-level security scoping every read to the analyst's counterparties; LangGraph checkpoints persisted here |
| Documents | Cloud Storage | CSA, policy, dispute and escalation documents (30-day retention, scanned by SDP) |
| Eventing | Pub/Sub + Cloud Tasks + Cloud Scheduler | Live price refresh, impact events, one SLA timer per call, the daily margin run |
| API | FastAPI on Cloud Run | Scales to zero; IAM database login; OIDC for internal callers |
| Frontend | Next.js on Firebase App Hosting + Vercel | Real-time ops dashboard and the "Ask the Desk" chat; the same app on both hosts against the same API, each git-linked to auto-deploy on push to main (App Hosting: managed Cloud Run, scales to zero; MM-145, ADR-0021) |
| Real-time status | Firestore + Firebase Auth | One small status doc per margin call, pushed to every open Approvals page and dashboard the moment a call changes; per-user scope via custom-token claims and security rules; Postgres stays the source of truth (MM-146, ADR-0021) |
| Agent platform | Vertex AI Agent Runtime | The desk assistant: Sessions + Memory Bank, min_instances=0; evaluated with Gen AI evaluation in CI |
| Tool interface | MCP servers on Cloud Run |
MarginMaestro/
├── README.md
├── CLAUDE.md # Agent operating guide (read first, every session)
├── CONTRIBUTING.md
├── TESTING.md
├── .env.example
├── .gitignore
├── src/ # Backend: agents, calc, streaming, rag, api, mcp_servers, ports/adapters,
│ # config, persistence, governance, warehouse, realtime, observability, ops
├── frontend/ # Next.js dashboard + "Ask the Desk" chat (Firebase App Hosting + Vercel)
├── tests/ # Unit, contract and integration tests (coverage gate ≥ 80%)
├── migrations/ # Alembic migrations (dual-dialect: SQL Server + Postgres)
├── infra/ # Terraform: gcp/ (live Google Cloud stack) + the original AWS stack,
│ # Prometheus/Grafana provisioning
├── firebase/ # Firestore security rules (real-time call status, MM-146)
├── tableau/ # G7 reporting workbook (Margin_Dashboard.twb) + its screenshots
├── scripts/ # One-off ops scripts (Cloud SQL bootstrap, RAG ingest, secret migration)
└── docs/
├── ARCHITECTURE.md # Lifecycle, agent mesh, streaming, data flow
├── AGENTS.md # Each agent: responsibility, IO, tools
├── DATA_SOURCES.md # Structured vs unstructured data map + free sources
├── ROADMAP.md # Original (pre-GCP) phased plan, mapped to Jira epics/stories
├── PROGRESS.md # Original-track living handoff log
├── AGENT_ORCHESTRATION_FAQ.md # Code vs. LLM breakdown; real vs. simulated trigger parity
├── data_catalog.yaml # Governance catalog: every table/document family, class, owner (G8)
├── architecture/ # Functional + technical architecture diagrams (see above)
├── assets/ # Hackathon deck screenshots + brand assets
├── warehouse/ # BigQuery warehouse guide + Tableau workbook guide (G7)
├── hackathon/ # AI Builder Cup submission materials
├── adr/ # Architecture Decision Records (original stack, ADR-0001…0007)
└── gcp/ # The live GCP track
├── GCP_ROADMAP.md # Phases G0–G10, service catalog, Jira mapping
├── GCP_PROGRESS.md # GCP-track living handoff log — read this first for current state
└── adr/ # GCP-specific ADRs (ADR-0008…0021)
The fastest way to see the app is the live demo above — this section is for running your own copy.
git clone https://github.com/AdarshMurali/MarginMaestro.git
cd MarginMaestro
cp .env.example .env # fill in OPENAI_API_KEY at minimum; see file for the rest
pip install -e ".[dev]"
docker compose up -d sqlserver redpanda chroma # skip the `app` service -- run the API locally instead, below
alembic upgrade head
python -m persistence.seed_users # seeds approver / viewer / manager (see table above)
python -m persistence.batch_loader # seeds counterparties, positions, CSA/RAG documents
uvicorn api.main:app --reload
Then, separately:
cd frontend
cp .env.example .env.local # points at your local API + NextAuth config
npm install
npm run dev # http://localhost:3000
make test / make lint run the backend test suite and linters (see CONTRIBUTING.md for the full contributor workflow). Frontend checks: npx tsc --noEmit and npx eslint . from frontend/.
MarginMaestro is a portfolio / proof-of-concept project. It uses free and synthetic data, and its margin calculations (VM/IM/SIMM) are directionally correct approximations for demonstration, not production-grade risk models. It is not affiliated with any employer and uses no proprietary data.
| Read-only market data, CSA/policy search and margin-call status; private, invoked only by the desk agent |
| Notifications | WhatsApp Cloud API + Slack | Client notices on WhatsApp (approved template, signed webhook for replies and delivery status); Slack for internal approvals, alerts and escalations |
| Escalation | ServiceNow | Real incident opened when an SLA is breached (see ADR-0007) |
| Governance | Dataplex catalog + Data Lineage + Cloud Audit Logs | Every table and document family catalogued and classified; lineage per margin call; data-access audit logs; append-only audit trail |
| Warehouse / reporting | BigQuery + Tableau | Finance star schema: the live book loaded after every daily margin run, plus a 1,000-counterparty, 5-year simulated book for backtesting, with row access policies and column masking matching Cloud SQL RLS; five pre-built reports in-app at /reports, and a Tableau workbook (tableau/Margin_Dashboard.twb, guide in docs/warehouse/tableau.md) for deeper analysis |
| Observability | Cloud Trace + Cloud Logging + Cloud Monitoring | One trace per margin-call run; structured logs; incident alert |
| Dev-story tracker | Jira | MM-# tickets for this project's own development — not an agent-facing tool |
| Secrets/config | Secret Manager | One JSON secret per environment (marginmaestro-<env>) |
| CI/CD | GitHub Actions + Docker Hub → Cloud Run | Lint, test, coverage, quality gate, security scans, build, push, and keyless (WIF) deploy on every merge to main |
| Quality | SonarCloud + pytest-cov | Coverage + quality gate |
| Security scanning | CodeQL, Dependabot, secret scanning, pip-audit, gitleaks, Trivy, Checkov | SAST, dependency CVEs, leaked secrets, image and IaC misconfiguration — free alternatives to Checkmarx / Black Duck (see ADR-0018) |
| IaC | Terraform | infra/gcp/ provisions the Google Cloud deployment (the original AWS stack lives in infra/) |