### Quick Start Examples Source: https://github.com/quantoracledev/quantoracle/blob/main/cli/README.md Demonstrates common quantoracle-cli commands for various financial calculations. ```bash # Black-Scholes with 10 Greeks quantoracle bs --spot 185 --strike 190 --expiry 0.25 --vol 0.25 ``` ```bash # Kelly criterion quantoracle kelly --win-rate 0.55 --avg-win 120 --avg-loss 100 ``` ```bash # Monte Carlo simulation quantoracle mc --value 80000 --return 0.10 --vol 0.18 --years 2 ``` ```bash # Implied volatility quantoracle iv --spot 195 --strike 200 --expiry 0.5 --price 12.50 ``` ```bash # Bond pricing quantoracle bond --coupon 0.05 --ytm 0.04 --years 10 ``` ```bash # CAGR quantoracle cagr --start 80000 --end 120000 --years 3 ``` ```bash # Liquidation price quantoracle liq --entry 50000 --collateral 5000 --size 50000 --leverage 10 --direction long ``` -------------------------------- ### Quick Start with Vercel AI SDK Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/vercel-ai/README.md Use the default 5-tool core bundle with `generateText` to price options and get deterministic results from the QuantOracle API. ```typescript import { generateText } from "ai"; import { openai } from "@ai-sdk/openai"; import { quantoracleTools } from "@quantoracle/ai-tools"; const result = await generateText({ model: openai("gpt-4o"), tools: quantoracleTools(), maxSteps: 5, prompt: "Price a 30-day SPY $500 call with vol=18%, spot=$498, rate=5%.", }); console.log(result.text); ``` -------------------------------- ### Install LangChain and QuantOracle Packages Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/langchain/cookbook/quantoracle_risk_analyst.ipynb Installs necessary libraries for building the LangChain agent with QuantOracle integration. Restart the kernel if prompted after installation. ```python %pip install --quiet langchain-quantoracle langchain-openai langgraph ``` -------------------------------- ### Install @quantoracle/ai-tools Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/vercel-ai/README.md Install the @quantoracle/ai-tools package along with a model provider like @ai-sdk/openai. ```bash pnpm add @quantoracle/ai-tools ai zod # plus a model provider, e.g.: pnpm add @ai-sdk/openai ``` -------------------------------- ### Install QuantOracle CLI Source: https://github.com/quantoracledev/quantoracle/blob/main/cli/README.md Install the quantoracle-cli globally using npm. ```bash npm install -g quantoracle-cli ``` -------------------------------- ### Install @quantoracle/goat-plugin Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/goat/README.md Install the @quantoracle/goat-plugin along with @goat-sdk/core and zod. Additional adapters and wallets like @goat-sdk/adapter-vercel-ai and @goat-sdk/wallet-viem are also shown. ```bash pnpm add @quantoracle/goat-plugin @goat-sdk/core zod # plus an adapter and wallet, e.g.: pnpm add @goat-sdk/adapter-vercel-ai @goat-sdk/wallet-viem viem ``` -------------------------------- ### Install QuantOracle CLI Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Install the QuantOracle command-line interface globally or use npx for on-demand execution. ```bash npm install -g quantoracle-cli ``` ```bash npx quantoracle-cli ``` -------------------------------- ### Install langchain-quantoracle Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/langchain/README.md Install the library using pip. This is the first step to using QuantOracle tools with LangChain. ```bash pip install langchain-quantoracle ``` -------------------------------- ### CLI Usage Examples Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Examples of how to use the QuantOracle CLI for various financial calculations and data retrieval. ```APIDOC ## CLI Usage Examples ### Black-Scholes Calculator ```bash npx quantoracle-cli bs --spot 185 --strike 190 --expiry 0.25 --vol 0.25 ``` ### Kelly Criterion ```bash qo kelly --win-rate 0.55 --avg-win 120 --avg-loss 100 ``` ### Monte Carlo Simulation ```bash qo mc --value 80000 --return 0.10 --vol 0.18 --years 2 ``` ### JSON Output for Scripting ```bash qo bs --spot 185 --strike 190 --expiry 0.25 --vol 0.25 --json | jq '.greeks.delta' ``` ### Risk Portfolio from File ```bash qo risk portfolio --returns @returns.txt ``` ### All Commands ```bash qo help ``` ``` -------------------------------- ### Install QuantOracle via ClawHub Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Install QuantOracle using the ClawHub package manager. ```bash clawhub install quantoracle ``` -------------------------------- ### Example Claude Desktop Session - Options Pricing Source: https://github.com/quantoracledev/quantoracle/blob/main/mcp-server/README.md An example of how an AI agent like Claude might call the 'options/price' tool to get pricing details for an option. ```text Price: $4.92 Greeks: Δ 0.43, Γ 0.043, ν 0.21, Θ -0.034, ρ 0.12 Breakeven: $189.92 ``` -------------------------------- ### Scripting Example: Portfolio Scan Source: https://github.com/quantoracledev/quantoracle/blob/main/cli/README.md Loop through different portfolio optimization modes and execute the quantoracle optimize command for each. ```bash # Portfolio scan for mode in max_sharpe min_vol risk_parity; do echo "=== $mode ===" quantoracle optimize --file returns.csv --mode $mode done ``` -------------------------------- ### Install QuantOracle MCP Server Source: https://github.com/quantoracledev/quantoracle/blob/main/mcp-server/README.md Install the QuantOracle MCP server using npx for immediate use or globally for persistent access. ```bash npx quantoracle-mcp ``` ```bash npm install -g quantoracle-mcp quantoracle-mcp ``` -------------------------------- ### Install and Run quantoracle-cli Source: https://context7.com/quantoracledev/quantoracle/llms.txt Install the quantoracle-cli globally using npm or run it directly with npx. This CLI provides access to all QuantOracle calculators and composites from the terminal. ```bash npm install -g quantoracle-cli # or run without installing: npx quantoracle-cli bs --spot 185 --strike 190 --expiry 0.25 --vol 0.25 ``` -------------------------------- ### Install Solana Agent Kit and Zod Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/solana-agent-kit/README.md Install the necessary packages for using the QuantOracle integration with Solana Agent Kit. ```bash pnpm add solana-agent-kit zod ``` -------------------------------- ### Install LangChain and QuantOracle Libraries Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/langchain/DEVTO_TUTORIAL.md Installs the necessary Python packages for integrating QuantOracle tools with LangChain and OpenAI. ```bash pip install langchain-quantoracle langchain-openai langchain ``` -------------------------------- ### Quick Start with GOAT SDK (Solana) Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/goat/README.md Sets up QuantOracle tools for a GOAT agent on Solana. Uses the Solana wallet adapter and specifies included tool bundles like 'core' and 'defi'. ```typescript import { Keypair, Connection } from "@solana/web3.js"; import { solana } from "@goat-sdk/wallet-solana"; import { quantoracle } from "@quantoracle/goat-plugin"; const connection = new Connection(process.env.SOLANA_RPC_URL!) const keypair = Keypair.fromSecretKey(/* ... */) const tools = await getOnChainTools({ wallet: solana({ keypair, connection }), plugins: [...quantoracle({ include: ["core", "defi"] })], }); ``` -------------------------------- ### Self-Host QuantOracle API Locally Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Clone the repository, install dependencies, and run the FastAPI application using uvicorn for local development. Alternatively, use Docker Compose for a containerized setup. ```bash git clone https://github.com/QuantOracledev/quantoracle.git cd quantoracle pip install fastapi uvicorn uvicorn api.quantoracle:app --host 0.0.0.0 --port 8000 ``` ```bash docker compose up -d ``` -------------------------------- ### QuantOracle CLI Output Example Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Example output from the QuantOracle CLI for a Black-Scholes calculation, showing price, intrinsic value, time value, breakeven, probability in the money, and Greeks. ```text QuantOracle · Black-Scholes (call) ──────────────────────────────────── Price $8.02 Intrinsic $0.00 Time Value $8.02 Breakeven $198.02 Prob ITM 43.0% Greeks ──────────────────────────────────── Delta 0.4797 Gamma 0.0172 Theta -0.0615/day Vega 0.3685 ──────────────────────────────────── ⏱ 0.05ms · api.quantoracle.dev ``` -------------------------------- ### AgentKit Setup with Wallet Provider and Action Providers (TypeScript) Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/dev-to/agentkit-vs-langchain-vs-http.md Illustrates initializing AgentKit with an EVM wallet provider and custom action providers. This setup is for agents requiring wallet-native authentication and payment, particularly within the Coinbase ecosystem. ```typescript import { AgentKit, CdpEvmWalletProvider } from "@coinbase/agentkit"; import { quantoracleActionProvider } from "./quantoracle"; const walletProvider = await CdpEvmWalletProvider.configureWithWallet({ apiKeyId: process.env.CDP_API_KEY_ID!, apiKeySecret: process.env.CDP_API_KEY_SECRET!, networkId: "base-mainnet", }); const agentkit = await AgentKit.from({ walletProvider, actionProviders: [quantoracleActionProvider()], }); // LLM picks `calculate_kelly` because the Zod schema's .describe() // text matches "Kelly fraction" / "win rate" / "payoff" const tools = await getLangChainTools(agentkit); ``` -------------------------------- ### Install @quantoracle/plugin-quantoracle Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/eliza/plugin-quantoracle/README.md Install the plugin using npm or pnpm. This command adds the necessary package to your project dependencies. ```bash npm install @quantoracle/plugin-quantoracle # or pnpm add @quantoracle/plugin-quantoracle ``` -------------------------------- ### Install and Run Strategy Optimizer Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Install the necessary Python package and execute the strategy optimizer script. This script performs extensive parameter optimization across multiple assets. ```bash pip install requests python examples/strategy_optimizer.py ``` -------------------------------- ### Install QuantOracle Action Provider Files Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/agentkit/README.md Use these commands to copy the necessary QuantOracle action provider files into your AgentKit project. Alternatively, clone the QuantOracle repository and copy the directory. ```bash npx create-onchain-agent mkdir -p src/quantoracle curl -sL https://raw.githubusercontent.com/QuantOracledev/quantoracle/main/integrations/agentkit/quantoracleActionProvider.ts -o src/quantoracle/quantoracleActionProvider.ts curl -sL https://raw.githubusercontent.com/QuantOracledev/quantoracle/main/integrations/agentkit/schemas.ts -o src/quantoracle/schemas.ts curl -sL https://raw.githubusercontent.com/QuantOracledev/quantoracle/main/integrations/agentkit/constants.ts -o src/quantoracle/constants.ts curl -sL https://raw.githubusercontent.com/QuantOracledev/quantoracle/main/integrations/agentkit/index.ts -o src/quantoracle/index.ts ``` ```bash git clone https://github.com/QuantOracledev/quantoracle cp -r quantoracle/integrations/agentkit ./src/quantoracle ``` -------------------------------- ### Install Dependencies and Set API Key Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/langchain/cookbook/README.md Installs necessary Python packages and sets the OpenAI API key for running LangChain agents locally. Ensure you have a valid OpenAI API key. ```bash pip install langchain-quantoracle langchain-openai langgraph jupyter export OPENAI_API_KEY=sk-... ``` -------------------------------- ### Initialize QuantOracle Tools for LangChain Source: https://context7.com/quantoracledev/quantoracle/llms.txt Import and initialize `QuantOracleToolkit` to get all available tools. You can also filter tools by category. ```python from langchain_quantoracle import QuantOracleToolkit, get_tools # All tools (63 calculators + 10 composites) tools = QuantOracleToolkit().get_tools() # Filter by category tools = QuantOracleToolkit(categories=["options", "risk"]).get_tools() ``` -------------------------------- ### Build and Execute a LangChain Agent with QuantOracle Tools Source: https://context7.com/quantoracledev/quantoracle/llms.txt Create a LangChain agent using `ChatOpenAI`, `create_tool_calling_agent`, and `AgentExecutor`. This example demonstrates how to invoke the agent with a financial query. ```python from langchain_openai import ChatOpenAI from langchain.agents import AgentExecutor, create_tool_calling_agent from langchain_core.prompts import ChatPromptTemplate # All tools (63 calculators + 10 composites) tools = QuantOracleToolkit().get_tools() # Build agent llm = ChatOpenAI(model="gpt-4o") prompt = ChatPromptTemplate.from_messages([ ("system", "You are a quant analyst. Use QuantOracle tools for all financial math."), ("human", "{input}"), ("placeholder", "{agent_scratchpad}"), ]) agent = create_tool_calling_agent(llm, tools, prompt) executor = AgentExecutor(agent=agent, tools=tools) result = executor.invoke({ "input": "Price a 30-day call on NVDA: spot $185, strike $190, 25% vol" }) print(result["output"]) ``` -------------------------------- ### Install QuantOracle MCP Source: https://github.com/quantoracledev/quantoracle/blob/main/mcp-server/SKILL.md Use npx to install the QuantOracle MCP package. This command-line tool allows direct interaction with the QuantOracle services. ```bash npx quantoracle-mcp ``` -------------------------------- ### Quick Start with GOAT SDK (Base) Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/goat/README.md Integrates QuantOracle tools into a GOAT agent for pricing financial instruments. Requires setting up a Viem wallet client and using the adapter-vercel-ai for tool retrieval. ```typescript import { generateText } from "ai"; import { openai } from "@ai-sdk/openai"; import { getOnChainTools } from "@goat-sdk/adapter-vercel-ai"; import { viem } from "@goat-sdk/wallet-viem"; import { createWalletClient, http } from "viem"; import { privateKeyToAccount } from "viem/accounts"; import { base } from "viem/chains"; import { quantoracle } from "@quantoracle/goat-plugin"; const walletClient = createWalletClient({ account: privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`), transport: http(), chain: base, }); const tools = await getOnChainTools({ wallet: viem(walletClient), plugins: [...quantoracle()], }); const result = await generateText({ model: openai("gpt-4o"), tools, maxSteps: 5, prompt: "Price a 30-day SPY $500 call with vol=18%, spot=$498, rate=5%.", }); ``` -------------------------------- ### Data Input Methods Source: https://github.com/quantoracledev/quantoracle/blob/main/cli/README.md Examples of providing data input to quantoracle-cli commands. ```bash # Inline comma-separated quantoracle stats sharpe --returns "0.01,-0.005,0.008,-0.012,0.015" ``` ```bash # From file (one value per line) quantoracle risk portfolio --returns @returns.txt ``` ```bash # CSV file (header = asset names, columns = returns) quantoracle optimize --file portfolio.csv ``` -------------------------------- ### Scripting Example: Backtest Loop Source: https://github.com/quantoracledev/quantoracle/blob/main/cli/README.md Iterate through monthly returns files, process them with quantoracle kelly, and extract the half Kelly criterion. ```bash # Backtest loop for month in jan feb mar apr; do returns=$(cat returns_${month}.csv | tr '\n' ',') quantoracle kelly --returns "$returns" --json | jq '.half_kelly' done ``` -------------------------------- ### Publish @quantoracle/agentkit package Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/PUBLISHING.md Publish the '@quantoracle/agentkit' package to npm. Run 'npm install' first if necessary. ```bash cd D:/Quantcalc/integrations/agentkit npm install npm publish --access=public ``` -------------------------------- ### QuantOracle Bundle Selection Examples Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/goat/README.md Demonstrates how to include specific QuantOracle tool bundles in your GOAT agent configuration. Options include 'core', 'options', 'risk', 'defi', or 'all'. ```typescript // Default — 5 core tools plugins: [...quantoracle()] // Options-focused agent — 9 tools plugins: [...quantoracle({ include: ["core", "options"] })] // Onchain DeFi trading agent — 7 tools + Uniswap + ERC20 plugins: [ ...quantoracle({ include: ["core", "defi"] }), uniswap(), erc20(), ] // Quant research agent — 13 tools plugins: [...quantoracle({ include: ["core", "risk", "options"] })] // All 15 tools plugins: [...quantoracle({ include: "all" })] ``` -------------------------------- ### Agent Backtest Workflow Example Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Illustrates a typical agent backtest workflow chaining multiple QuantOracle calls per iteration. Each call is a pure calculator with no state or side effects. ```plaintext 1. /v1/indicators/technical -- generate signals (SMA, RSI, MACD) 2. /v1/risk/position-size -- size the trade (fixed fractional) 3. /v1/risk/transaction-cost -- estimate execution costs 4. /v1/options/price -- price the hedge (Black-Scholes) 5. /v1/risk/portfolio -- compute running Sharpe, drawdown, VaR 6. /v1/stats/probabilistic-sharpe -- is the Sharpe statistically significant? 7. /v1/tvm/cagr -- compute CAGR of the equity curve ``` -------------------------------- ### Scripting Example: Conditional Trade Sizing Source: https://github.com/quantoracledev/quantoracle/blob/main/cli/README.md Fetch RSI using quantoracle ta, and if it's below 30, execute a trade sizing command. ```bash # Conditional trade sizing rsi=$(quantoracle ta --prices "$(cat spy.txt | tr '\n' ',')" --json | jq '.rsi') if (( $(echo "$rsi < 30" | bc -l) )); then quantoracle size --account 80000 --entry 440 --stop 430 fi ``` -------------------------------- ### QuantOracle CLI - Common Commands Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Examples of various QuantOracle CLI commands, including Kelly criterion, Monte Carlo simulation, JSON output for scripting, risk analysis from file, and help command. ```bash # Kelly criterion qo kelly --win-rate 0.55 --avg-win 120 --avg-loss 100 # Monte Carlo qo mc --value 80000 --return 0.10 --vol 0.18 --years 2 # JSON output for scripting qo bs --spot 185 --strike 190 --expiry 0.25 --vol 0.25 --json | jq '.greeks.delta' # Data from file qo risk portfolio --returns @returns.txt # All commands qo help ``` -------------------------------- ### Hedge Recommendation Tool Response Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/dev-to/chained-x402-tool-calls.md Example JSON output from the `recommend_hedge` tool, providing details on different hedging structures, their costs, and potential outcomes. This informs the agent's final recommendation. ```json { "recommendations": [ { "structure": "10% OTM protective put", "cost_pct": 1.8, "max_loss_pct": -11.8, "breakeven_move": -1.8, "rank": 1 }, { "structure": "Collar (10% OTM put + 10% OTM call)", "cost_pct": 0.3, "max_loss_pct": -11.8, "max_gain_pct": 8.2, "rank": 2 }, { "...": "..." } ] } ``` -------------------------------- ### Initialize QuantOracle Toolkit and LangChain Agent Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/langchain/DEVTO_TUTORIAL.md Loads all QuantOracle tools and sets up a LangChain agent with a specific system prompt for financial analysis. ```python from langchain_quantoracle import QuantOracleToolkit from langchain_openai import ChatOpenAI from langchain.agents import AgentExecutor, create_tool_calling_agent from langchain_core.prompts import ChatPromptTemplate # Load every QuantOracle tool — all 73 endpoints become LangChain tools tools = QuantOracleToolkit().get_tools() llm = ChatOpenAI(model="gpt-4o") prompt = ChatPromptTemplate.from_messages([ ("system", "You are a quant analyst. Use QuantOracle tools for all financial math — never compute in-context."), ("human", "{input}"), ("placeholder", "{agent_scratchpad}"), ]) agent = create_tool_calling_agent(llm, tools, prompt) executor = AgentExecutor(agent=agent, tools=tools, verbose=True) ``` -------------------------------- ### Publish @quantoracle/goat-plugin package Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/PUBLISHING.md Publish the '@quantoracle/goat-plugin' package to npm. Ensure you have run 'npm install' if it's a fresh setup. ```bash cd D:/Quantcalc/integrations/goat npm install npm publish --access=public ``` -------------------------------- ### Create and Execute a LangChain Agent with QuantOracle Tools Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/langchain/README.md Integrate QuantOracle tools into a LangChain agent using an OpenAI LLM. This example demonstrates setting up the agent prompt, creating the agent, and invoking the executor with a financial query. ```python from langchain_openai import ChatOpenAI from langchain.agents import AgentExecutor, create_tool_calling_agent from langchain_core.prompts import ChatPromptTemplate llm = ChatOpenAI(model="gpt-4o") prompt = ChatPromptTemplate.from_messages([ ("system", "You are a quant analyst. Use QuantOracle tools for all financial math."), ("human", "{input}"), ("placeholder", "{agent_scratchpad}"), ]) agent = create_tool_calling_agent(llm, tools, prompt) executor = AgentExecutor(agent=agent, tools=tools) result = executor.invoke({"input": "Price a call option: spot 100, strike 105, 6 months, 20% vol"}) ``` -------------------------------- ### Full Agent Setup with Chained Tool Calls Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/dev-to/chained-x402-tool-calls.md Initializes the AgentKit, integrates LangChain tools, and sets up a multi-prompt agent for financial analysis. Uses MemorySaver to maintain state between turns. Ensure CDP_API_KEY_ID and CDP_API_KEY_SECRET environment variables are set. ```typescript import { AgentKit, CdpEvmWalletProvider } from "@coinbase/agentkit"; import { getLangChainTools } from "@coinbase/agentkit-langchain"; import { ChatOpenAI } from "@langchain/openai"; import { createReactAgent } from "@langchain/langgraph/prebuilt"; import { MemorySaver } from "@langchain/langgraph"; import { HumanMessage } from "@langchain/core/messages"; import { quantoracleActionProvider } from "./quantoracle"; const walletProvider = await CdpEvmWalletProvider.configureWithWallet({ apiKeyId: process.env.CDP_API_KEY_ID!, apiKeySecret: process.env.CDP_API_KEY_SECRET!, networkId: "base-mainnet", }); const agentkit = await AgentKit.from({ walletProvider, actionProviders: [quantoracleActionProvider()], }); const tools = await getLangChainTools(agentkit); const llm = new ChatOpenAI({ model: "gpt-4o", temperature: 0 }); const agent = createReactAgent({ llm, tools, checkpointSaver: new MemorySaver(), messageModifier: /* see above */, }); // Scripted 3-prompt sequence const PROMPTS = [ `I have a $100,000 long NVDA position. Here are the last 60 daily returns: [0.012, -0.025, 0.034, ...]. Audit the risk. I'm specifically concerned about max drawdown and tail risk.`, `Given that risk profile, recommend the cheapest hedge structure to protect against a 10%+ drawdown over the next 30 days. Compare collar vs protective put.`, `Based on both the risk audit and the hedge analysis, what would you actually do — and what's the expected cost vs the expected protection benefit?`, ]; const config = { configurable: { thread_id: "demo" } }; for (const prompt of PROMPTS) { const stream = await agent.stream( { messages: [new HumanMessage(prompt)] }, config, ); for await (const chunk of stream) { if ("agent" in chunk) { const last = chunk.agent.messages[chunk.agent.messages.length - 1]; if (last?.content) console.log(` Agent: ${last.content} `); } else if ("tools" in chunk) { for (const msg of chunk.tools.messages || []) { console.log(` [tool ${msg.name}]:`, msg.content.slice(0, 200)); } } } } ``` -------------------------------- ### AgentCash Fetch Example Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Example of fetching data using AgentCash with a POST request to the full-analysis endpoint. ```APIDOC ## AgentCash Fetch Example ### Description Example of fetching data using AgentCash with a POST request to the full-analysis endpoint. ### Command npx agentcash fetch https://api.quantoracle.dev/v1/risk/full-analysis \ -m POST --payment-network solana \ --body '{"returns":[0.01,-0.02,0.03,0.005,-0.01,0.02,-0.015,0.025,0.01,-0.005,0.015]}' ``` -------------------------------- ### Run QuantOracle CLI without Installation Source: https://github.com/quantoracledev/quantoracle/blob/main/cli/README.md Execute quantoracle-cli commands directly using npx without a global installation. ```bash npx quantoracle-cli bs --spot 185 --strike 190 --expiry 0.25 --vol 0.25 ``` -------------------------------- ### Load QuantOracle Risk, Portfolio, and Stats Tools Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/langchain/cookbook/quantoracle_risk_analyst.ipynb Loads specific categories of tools from QuantOracle to keep the agent's toolset focused. This example loads 25 tools related to risk, portfolio, and statistics. ```python from langchain_quantoracle import QuantOracleToolkit tools = QuantOracleToolkit(categories=["risk", "portfolio", "stats"]).get_tools() print(f"Loaded {len(tools)} tools") for t in tools[:5]: print(f" • {t.name}") print(" ...") ``` -------------------------------- ### Example Claude Desktop Session - Monte Carlo Simulation Source: https://github.com/quantoracledev/quantoracle/blob/main/mcp-server/README.md An example of an AI agent invoking the 'simulate/montecarlo' tool for a portfolio simulation, with the response including various performance metrics. ```text Response includes terminal-value distribution (P5/P25/median/P75/P95), probability of loss, probability of ruin, and CAGR. ``` -------------------------------- ### Get JSON Output from CLI for Scripting Source: https://context7.com/quantoracledev/quantoracle/llms.txt Execute CLI commands with the --json flag to get structured output, which can be piped to tools like jq for further processing in scripts. ```bash qo bs --spot 185 --strike 190 --expiry 0.25 --vol 0.25 --json | jq '.greeks.delta' ``` -------------------------------- ### Configure Cursor/Cline/Continue for MCP Server Source: https://github.com/quantoracledev/quantoracle/blob/main/mcp-server/README.md Set up the MCP server in your agent's settings by providing the command and arguments. No environment variables are required for the free tier. ```text - Command: npx - Arguments: -y quantoracle-mcp - Environment: none required for the free tier ``` -------------------------------- ### Download QuantOracle Action Provider Files Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/agentkit/DEVTO_TUTORIAL.md Download the necessary TypeScript files for the QuantOracle action provider into your project's src/quantoracle directory. These files add financial math tools without new npm dependencies. ```bash mkdir -p src/quantoracle curl -sL https://raw.githubusercontent.com/QuantOracledev/quantoracle/main/integrations/agentkit/quantoracleActionProvider.ts -o src/quantoracle/quantoracleActionProvider.ts curl -sL https://raw.githubusercontent.com/QuantOracledev/quantoracle/main/integrations/agentkit/schemas.ts -o src/quantoracle/schemas.ts curl -sL https://raw.githubusercontent.com/QuantOracledev/quantoracle/main/integrations/agentkit/constants.ts -o src/quantoracle/constants.ts curl -sL https://raw.githubusercontent.com/QuantOracledev/quantoracle/main/integrations/agentkit/index.ts -o src/quantoracle/index.ts ``` -------------------------------- ### LangChain Integration - Get All Tools Source: https://context7.com/quantoracledev/quantoracle/llms.txt Retrieves all available QuantOracle tools (calculators and composites) for use with LangChain. ```APIDOC ```python from langchain_quantoracle import QuantOracleToolkit # Get all tools tools = QuantOracleToolkit().get_tools() ``` ``` -------------------------------- ### Build LangChain Agent with QuantOracle Tools Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/langchain/cookbook/quantoracle_risk_analyst.ipynb Creates a ReAct agent using a chat model and the loaded QuantOracle tools. The system prompt instructs the agent to use QuantOracle tools for all financial calculations and to provide plain English explanations and recommendations. ```python from langchain_openai import ChatOpenAI from langgraph.prebuilt import create_react_agent llm = ChatOpenAI(model="gpt-4o-mini", temperature=0) SYSTEM = ( "You are a quantitative analyst. For ANY financial calculation — Sharpe, " "VaR, drawdown, Kelly, position sizing, regression — you MUST call a " "QuantOracle tool. Never compute math in your head. After tools return, " "explain the result in plain English and recommend an action." ) agent = create_react_agent(llm, tools, prompt=SYSTEM) ``` -------------------------------- ### Batch Endpoint Request Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Example of a POST request to the /v1/batch endpoint to execute multiple computations in a single request. ```APIDOC ## Batch Endpoint Request Run up to 100 computations in a single HTTP request. One round trip instead of 100. ```bash curl -X POST https://api.quantoracle.dev/v1/batch \ -H "Content-Type: application/json" \ -d '{ "requests": [ {"endpoint": "options/price", "params": {"S": 100, "K": 105, "T": 0.25, "r": 0.05, "sigma": 0.2}}, {"endpoint": "stats/zscore", "params": {"series": [10, 12, 14, 11, 13, 15]}}, {"endpoint": "tvm/cagr", "params": {"start_value": 100, "end_value": 150, "years": 3}} ] }' ``` ``` -------------------------------- ### Create AgentKit Project Source: https://github.com/quantoracledev/quantoracle/blob/main/integrations/agentkit/DEVTO_TUTORIAL.md Use npx to create a new AgentKit project and navigate into its directory. This sets up the basic AgentKit template with CDP wallet provisioning and a LangChain ReAct loop. ```bash npx create-onchain-agent cd your-agent-name ``` -------------------------------- ### Batch Endpoint Response Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Example JSON response from the /v1/batch endpoint, containing results for multiple requests and the total price. ```APIDOC ## Batch Endpoint Response Returns all results in one response with the total price: ```json { "batch_size": 3, "total_price_usdc": 0.009, "results": [ {"endpoint": "options/price", "status": 200, "data": {"price": 2.4779, "greeks": {"delta": 0.377, "..."}}}, {"endpoint": "stats/zscore", "status": 200, "data": {"mean": 12.5, "std_dev": 1.87, "..."}}, {"endpoint": "tvm/cagr", "status": 200, "data": {"cagr": 0.1447, "doubling_time_years": 5.13, "..."}} ], "ms": 42.13 } ``` ``` -------------------------------- ### 402 Payment Required Response Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Example of a 402 Payment Required response when the free tier limit is exceeded, including the PAYMENT-REQUIRED header. ```APIDOC ## 402 Payment Required Response After 1,000 calls, the API returns `402 Payment Required` with an x402 payment header. Any x402-compatible agent automatically pays and continues: ``` HTTP/1.1 402 Payment Required PAYMENT-REQUIRED: ``` ``` -------------------------------- ### Run Black-Scholes Calculator via CLI Source: https://context7.com/quantoracledev/quantoracle/llms.txt Calculate options pricing using the Black-Scholes model via the quantoracle-cli. Specify spot price, strike, expiry, and volatility. ```bash qo bs --spot 185 --strike 190 --expiry 0.25 --vol 0.25 ``` -------------------------------- ### Onboard AgentCash for Solana Payments Source: https://context7.com/quantoracledev/quantoracle/llms.txt Use this command to onboard AgentCash for testing x402 payments on the Solana network. No additional setup is required. ```bash npx agentcash@latest onboard ``` -------------------------------- ### API Rate Limit Headers Source: https://github.com/quantoracledev/quantoracle/blob/main/README.md Example of rate limit headers returned by the QuantOracle API. These headers help agents self-manage their call volume. ```http X-RateLimit-Limit: 1000 X-RateLimit-Remaining: 847 X-RateLimit-Reset: 2025-01-15T00:00:00Z ```