Maxxit Lazy Trader
Execute perpetual trades on Ostium, Aster, and Avantis via Maxxit's Lazy Trading API, and trade Indian stocks through Zerodha Kite. Includes programmatic end...
Execute perpetual trades on Ostium, Aster, and Avantis via Maxxit's Lazy Trading API, and trade Indian stocks through Zerodha Kite. Includes programmatic end...
Real data. Real impact.
Growing
Developers
Per week
Open source
Skills give you superpowers. Install in 30 seconds.
Execute perpetual futures trades on Ostium, Aster DEX, and Avantis DEX through Maxxit's Lazy Trading API. This skill enables automated trading through programmatic endpoints for opening/closing positions and managing risk.
The skill includes standalone Python strategy scripts. Use them when the user wants the agent to run a predefined trading system instead of manually specifying each trade.
ema-strategy.py
rsi-bollinger-strategy.py
donchian-adx-strategy.py
taker-strategy.py - Aggressive Taker (Order Flow) HFT strategy. Analyzes Binance taker buy/sell ratios to detect aggressive market participants and catch rapid momentum shifts.mean-reversion-strategy.py - RSI + Bollinger Band mean-reversion strategy. A technical approach using price exhaustion points optimized for high-frequency scalping in sideways or boring markets.breakout-strategy.py - Volatility breakout strategy with ATR filter. Enters trades when price breaks out of a standard deviation channel while ATR confirms increasing volatility and momentum.vwap-strategy.py - VWAP crossover institutional momentum strategy. Uses volume-weighted average price and EMA to confirm institutional trend alignment and confirm trade strength with volume.All scripts:
https://api.binance.com/api/v3/klinesMAXXIT_API_URL and MAXXIT_API_KEYExample invocations:
python3 ema-strategy.py --symbol BTCUSDT --interval 5m --venue avantis python3 rsi-bollinger-strategy.py --symbol ETHUSDT --interval 5m --venue ostium python3 donchian-adx-strategy.py --symbol BTCUSDT --interval 15m --venue avantis
npx clawhub@latest install maxxit-lazy-trading --force
isTestnet: true on Ostium endpoints.NEVER assume, guess, or hallucinate values for API request parameters. Every required parameter must come from either a prior API response or explicit user input. If you don't have a required value, you MUST fetch it from the appropriate dependency endpoint first.
The following shows where each required parameter comes from. Always resolve dependencies before calling an endpoint.
| Parameter | Source | Endpoint to Fetch From |
|---|---|---|
/ | response → | |
| response → | |
| response → OR response → | or |
| response → OR response → symbol | or |
| response → OR response → | or |
/ | User specifies token OR response → (e.g. ) | User input or |
| User specifies or | User input (required) |
| User specifies the USDC amount | User input (required) |
| User specifies the multiplier | User input (required) |
| User specifies (e.g., 0.30 = 30%) | User input (required) |
| User specifies (e.g., 0.10 = 10%) | User input (required) |
(for copy-trader-trades) | response → or | |
(Alpha) | response → | |
(Alpha) | response → | |
, (Alpha) | Phase 2 response → , | + header |
(Alpha) | response → | |
/user-details first to get user_wallet (used as userAddress/address). Cache it for the session — it doesn't change./user-details as identity-first. It always returns user_wallet for a valid API key, even if no lazy-trading agent exists yet./user-details is sparse. It omits fields that are empty, null, or false. Missing fields mean “not applicable” and should not be treated as an error or missing configuration by themselves.ostium_agent_address when the venue needs an agent. Ostium and Avantis require it. Zerodha does not. Aster only needs user_wallet, but aster_configured must be present and true./user-details./api/lazy-trading/research, /api/lazy-trading/indian-stocks, /market-data, or /price as appropriate), present it to the user, get explicit confirmation plus trade parameters (collateral, leverage, side, TP, SL), then execute.
/symbols returns pairs like ETH/USD, but /open-position expects market as base token only (e.g. ETH). Convert by taking the base token before /.actualTradeIndex from the /open-position response. If you don't have it (e.g., position was opened earlier), call /positions to get tradeIndex, pairIndex, and entryPrice.tradeIndex — always call /positions first to look up the correct one for the user's specified market/position./symbols before trading if you're unsure whether a token is available on Ostium./alpha/agents → /alpha/listings → /alpha/purchase (402) → /alpha/pay → /alpha/purchase (with X-Payment) → /alpha/verify → /user-details → /alpha/execute. Never skip steps. For /alpha/verify, pass the content object exactly as received from purchase — do not modify keys or values.✅ Do I have the user's wallet address? → If not, call /user-details ✅ Does this flow require an agent address? → If yes, call /user-details and verify ostium_agent_address is present ✅ Does this endpoint need a tradeIndex? → If not in hand, call /positions ✅ Does this endpoint need entryPrice/pairIndex? → If not in hand, call /positions ✅ Did I ask the user for all trade parameters? → collateral, leverage, side, TP%, SL% ✅ Is the market/symbol valid? → If unsure, call /symbols to verify ✅ (Alpha) Do I have commitment? → If not, call /alpha/agents ✅ (Alpha) Do I have listingId? → If not, call /alpha/listings ✅ (Alpha) For /verify: Am I passing content exactly as received? → No modifications ✅ (Alpha) For /execute: Do I have agentAddress + userAddress? → Call /user-details
All requests require an API key with prefix
lt_. Pass it via:
X-API-KEY: lt_your_api_keyAuthorization: Bearer lt_your_api_keyWhen the user asks for market research, use the Maxxit market research endpoint instead of writing the research from scratch.
Endpoint:
POST /api/lazy-trading/researchPOST /api/lazy-trading/indian-stocks for Indian equities research queriesRules:
content prompt from the user's ask.deepResearch to true when the user asks for deep research, a comprehensive comparison, a detailed diligence-style breakdown, or explicitly wants more thorough research.deepResearch to false for standard market summaries, quick trade briefs, or normal tactical research requests.POST /api/lazy-trading/indian-stocks, OpenClaw must decide the request options from the user's query and should not ask the user to choose chat_model, response_length, or thinking_level.question plus the inferred request options:
chat_model: analytical or strategicresponse_length: short, medium, or longthinking_level: only include this when chat_model is strategicchat_model: "strategic" when the user wants a trading plan, swing-trade setups, long/short ideas, entry zones, stop loss, target levels, timing for this week, or tactical positioning. In strategic mode, include thinking_level automatically:
balanced by defaultlow for quick, lightweight tactical asksdeep only when the user explicitly asks for a more thoughtful or more detailed strategy answerchat_model: "analytical" for screens, rankings, fundamentals, valuation, sector comparisons, capex-cycle beneficiaries, earnings quality, balance sheet analysis, and diligence-style research. Do not send thinking_level in analytical mode.response_length from the user’s ask:
short for quick answers, concise trade ideas, and direct setup requestsmedium by default for normal research requestslong for ranked lists, detailed comparisons, deep dives, or multi-factor explanationsstrategic; if the answer is mainly screening, ranking, valuation, or fundamental comparison, choose analytical.Prompt construction examples:
Analyze BTC for a swing-long setup. Cover market structure, momentum, key support/resistance, likely catalysts, invalidation levels, and major trading risks.Summarize ETH market structure for today, including trend, momentum, key support/resistance, important catalysts, and trading risks for intraday positioning.Analyze SOL for a potential short setup. Cover current market structure, weakness signals, resistance levels, downside levels to watch, catalysts, and key squeeze/invalidation risks.Example call:
curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/research" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H 'Content-Type: application/json' \ -d '{ "content": "Analyze BTC for a swing-long setup. Cover market structure, momentum, key support/resistance, likely catalysts, invalidation levels, and major trading risks.", "deepResearch": false }'
Indian stocks example:
curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/indian-stocks" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H 'Content-Type: application/json' \ -d '{ "question": "Screen for Indian IT stocks with strong profit growth and low debt.", "chat_model": "analytical", "response_length": "medium" }'
Indian stocks tactical example:
curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/indian-stocks" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H 'Content-Type: application/json' \ -d '{ "question": "Which Indian banking stocks look strongest for a swing trade this week? Give long ideas only, with entry zone, stop loss, target range, and the reasoning behind each setup.", "chat_model": "strategic", "response_length": "short", "thinking_level": "balanced" }'
When discussing Indian equities, NSE/BSE orders, holdings, targets, stop losses, or portfolio values:
₹ in user-facing responses (for example, ₹2,450, ₹1.2 lakh)/api/lazy-trading/programmatic/*)All endpoints under
are for Ostium unless explicitly prefixed with/api/lazy-trading/programmatic/*./aster/
Retrieve lazy trading user information including wallet identity, agent status, Telegram connection, and trading preferences.
curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/user-details" \ -H "X-API-KEY: ${MAXXIT_API_KEY}"
Response:
{ "success": true, "user_wallet": "0x...", "lazy_trading_ready": true, "agent": { "id": "agent-uuid", "name": "Lazy Trader - Username", "venue": "ostium", "status": "active" }, "telegram_user": { "id": 123, "telegram_user_id": "123456789", "telegram_username": "trader" }, "deployment": { "id": "deployment-uuid", "status": "active", "enabled_venues": ["ostium"] }, "trading_preferences": { "risk_tolerance": "medium", "trade_frequency": "moderate" }, "ostium_agent_address": "0x...", "aster_configured": true }
If the user has not set up a lazy-trading agent yet,
/user-details still returns 200 and identity data, for example:
{ "success": true, "user_wallet": "0x..." }
Retrieve all available trading symbols from the Ostium exchange. Use this to discover which symbols you can trade.
curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/symbols" \ -H "X-API-KEY: ${MAXXIT_API_KEY}"
Response:
{ "success": true, "symbols": [ { "id": 0, "symbol": "BTC/USD", "group": "crypto", "maxLeverage": 150 }, { "id": 1, "symbol": "ETH/USD", "group": "crypto", "maxLeverage": 100 } ], "groupedSymbols": { "crypto": [ { "id": 0, "symbol": "BTC/USD", "group": "crypto", "maxLeverage": 150 }, { "id": 1, "symbol": "ETH/USD", "group": "crypto", "maxLeverage": 100 } ], "forex": [...] }, "count": 45 }
Retrieve USDC and ETH balance for the user's Ostium wallet address.
⚠️ Dependency: The
field is the user's Ostium wallet address (address). You MUST fetch it fromuser_walletfirst — do NOT hardcode or assume any address./user-details
curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/balance" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d "{"address": "0x..."}"
Response:
{ "success": true, "address": "0x...", "usdcBalance": "1000.50", "ethBalance": "0.045" }
Get all open positions for the user's Ostium trading account. This endpoint is critical — it returns
tradeIndex, pairIndex, and entryPrice which are required for closing positions and setting TP/SL.
⚠️ Dependency: The
field must come fromaddress→/user-details. NEVER guess it.user_wallet🔑 This endpoint provides values needed by:
(needs/close-position),tradeIndex(needs/set-take-profit,tradeIndex,pairIndex),entryPrice(needs/set-stop-loss,tradeIndex,pairIndex).entryPrice
curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/positions" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d "{"address": "0x..."}"
Request Body:
{ "address": "0x..." // REQUIRED — from /user-details → user_wallet. NEVER guess this. }
Response:
{ "success": true, "positions": [ { "market": "BTC", "marketFull": "BTC/USD", "side": "long", "collateral": 100.0, "entryPrice": 95000.0, "leverage": 10.0, "tradeId": "12345", "tradeIndex": 2, "pairIndex": "0", "notionalUsd": 1000.0, "totalFees": 2.50, "stopLossPrice": 85500.0, "takeProfitPrice": 0.0 } ], "totalPositions": 1 }
Key fields to extract from each position:
— needed fortradeIndex,/close-position,/set-take-profit/set-stop-loss — needed forpairIndex,/set-take-profit/set-stop-loss — needed forentryPrice,/set-take-profit/set-stop-loss — needed forside,/set-take-profit/set-stop-loss
### Get Position HistoryGet trading history for a wallet.
(default): uses Ostium history.venue: "OSTIUM" : returns normalized closed-trade history from Avantisvenue: "AVANTIS".v2/history/portfolio/historyNote: The user's Ostium wallet address can be fetched from the
endpoint (see Get Account Balance section above)./api/lazy-trading/programmatic/user-detailscurl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/history" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{"venue":"OSTIUM","address":"0x...","count":50}' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "venue": "OSTIUM", // Optional: "OSTIUM" (default) or "AVANTIS" "address": "0x...", // Required for OSTIUM; also accepted for AVANTIS as alias of userAddress "count": 50 // Number of recent orders to retrieve (default: 50) } </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "history": [ { "market": "ETH", "side": "long", "collateral": 50.0, "leverage": 5, "price": 3200.0, "pnlUsdc": 15.50, "profitPercent": 31.0, "totalProfitPercent": 31.0, "rolloverFee": 0.05, "fundingFee": 0.10, "executedAt": "2025-02-10T15:30:00Z", "tradeId": "trade_123" } ], "count": 25, "venue": "OSTIUM" } </code></pre> <p><strong>Avantis history example (same <code>/history</code> endpoint):</strong></p> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/history" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{"venue":"AVANTIS","userAddress":"0x...","count":50}' </code></pre> <p>Returns normalized records like: <code>id</code>, <code>tradeId</code> (<code><pairIndex>:<tradeIndex></code>), <code>market</code>, <code>side</code>, <code>collateralUsdc</code>, <code>positionSizeUsdc</code>, <code>leverage</code>, <code>entryPrice</code>, <code>closePrice</code>, <code>usdcSentToTrader</code>, <code>grossPnlUsdc</code>, <code>closedAt</code>, <code>timestamp</code>.</p> <h3>Open Position</h3> <p>Open a new perpetual futures position on Ostium.</p> <blockquote> <p><strong>⚠️ Dependencies — ALL must be resolved BEFORE calling this endpoint:</strong></p> <ol> <li><code>agentAddress</code> → from <code>/user-details</code> → <code>ostium_agent_address</code> (NEVER guess)</li> <li><code>userAddress</code> → from <code>/user-details</code> → <code>user_wallet</code> (NEVER guess)</li> <li><code>market</code> → validate via <code>/symbols</code> endpoint if unsure the token exists<!-- --> <ul> <li>If <code>/symbols</code> returns <code>ETH/USD</code>, pass <code>market: "ETH"</code> to <code>/open-position</code> (not <code>ETH/USD</code>)</li> </ul> </li> <li><code>side</code>, <code>collateral</code>, <code>leverage</code> → <strong>ASK the user explicitly</strong>, do not assume</li> </ol> <p><strong>📊 Recommended Pre-Trade Flow:</strong></p> <ol> <li>Call <code>/api/lazy-trading/research</code> for crypto trade research, or <code>/market-data</code> / <code>/price</code> for current market conditions</li> <li>Present the market context to the user (price, structure, momentum, volatility when available)</li> <li>Ask the user: "Do you want to proceed? Specify: collateral (USDC), leverage, long/short"</li> <li>Only after user confirms → call <code>/open-position</code></li> </ol> <p><strong>🔐 Verification Note:</strong> Every trade is analyzed by EigenAI for alignment with market conditions. Users can verify the cryptographic signatures and reasoning for all their trades at <a href="https://www.maxxit.ai/openclaw">maxxit.ai/openclaw</a>.</p> <p><strong>🔑 SAVE the response</strong> — <code>actualTradeIndex</code> and <code>entryPrice</code> are needed for setting TP/SL later.</p> </blockquote> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/open-position" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "agentAddress": "0x...", "userAddress": "0x...", "market": "BTC", "side": "long", "collateral": 100, "leverage": 10 }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "agentAddress": "0x...", // REQUIRED — from /user-details → ostium_agent_address. NEVER guess. "userAddress": "0x...", // REQUIRED — from /user-details → user_wallet. NEVER guess. "market": "BTC", // REQUIRED — Base token only for Ostium (e.g. "ETH", not "ETH/USD"). Validate via /symbols if unsure. "side": "long", // REQUIRED — "long" or "short". ASK the user. "collateral": 100, // REQUIRED — Collateral in USDC. ASK the user. "leverage": 10, // Optional (default: 10). ASK the user. "deploymentId": "uuid...", // Optional — associated deployment ID "signalId": "uuid...", // Optional — associated signal ID "isTestnet": false // Optional. Set true only when user explicitly asks for Ostium testnet / Arbitrum Sepolia. } </code></pre> <p><strong>Response (IMPORTANT — save these values):</strong></p> <pre><code class="language-json">{ "success": true, "orderId": "order_123", "tradeId": "trade_abc", "transactionHash": "0x...", "txHash": "0x...", "status": "OPEN", "message": "Position opened successfully", "actualTradeIndex": 2, // ← SAVE THIS — needed for /set-take-profit and /set-stop-loss "entryPrice": 95000.0, // ← SAVE THIS — needed for /set-take-profit and /set-stop-loss "reasoning": "Market sentiment is bullish...", // EigenAI trade alignment analysis "llmSignature": "0x..." // Cryptographic signature for auditability } </code></pre> <h3>Close Position</h3> <p>Close an existing perpetual futures position on Ostium.</p> <blockquote> <p><strong>⚠️ Dependencies — resolve BEFORE calling this endpoint:</strong></p> <ol> <li><code>agentAddress</code> → from <code>/user-details</code> → <code>ostium_agent_address</code></li> <li><code>userAddress</code> → from <code>/user-details</code> → <code>user_wallet</code></li> <li><code>tradeIndex</code> → call <code>/positions</code> first to find the position you want to close, then use its <code>tradeIndex</code></li> </ol> <p><strong>NEVER guess the <code>tradeIndex</code> or <code>tradeId</code>.</strong> Always fetch from <code>/positions</code> endpoint.</p> </blockquote> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/close-position" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "agentAddress": "0x...", "userAddress": "0x...", "market": "BTC", "tradeId": "12345" }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "agentAddress": "0x...", // REQUIRED — from /user-details → ostium_agent_address. NEVER guess. "userAddress": "0x...", // REQUIRED — from /user-details → user_wallet. NEVER guess. "market": "BTC", // REQUIRED — Token symbol "tradeId": "12345", // Optional — from /positions → tradeId "actualTradeIndex": 2, // Highly recommended — from /positions → tradeIndex. NEVER guess. "isTestnet": false // Optional. Set true only when user explicitly asks for Ostium testnet / Arbitrum Sepolia. } </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "result": { "txHash": "0x...", "market": "BTC", "closePnl": 25.50 }, "closePnl": 25.50, "message": "Position closed successfully", "alreadyClosed": false } </code></pre> <h3>Set Take Profit</h3> <p>Set or update take-profit level for an existing position on Ostium.</p> <blockquote> <p><strong>⚠️ Dependencies — you need ALL of these before calling:</strong></p> <ol> <li><code>agentAddress</code> → from <code>/user-details</code> → <code>ostium_agent_address</code></li> <li><code>userAddress</code> → from <code>/user-details</code> → <code>user_wallet</code></li> <li><code>tradeIndex</code> → from <code>/open-position</code> response → <code>actualTradeIndex</code>, <strong>OR</strong> from <code>/positions</code> → <code>tradeIndex</code></li> <li><code>entryPrice</code> → from <code>/open-position</code> response → <code>entryPrice</code>, <strong>OR</strong> from <code>/positions</code> → <code>entryPrice</code></li> <li><code>pairIndex</code> → from <code>/positions</code> → <code>pairIndex</code>, <strong>OR</strong> from <code>/symbols</code> → symbol <code>id</code></li> <li><code>takeProfitPercent</code> → <strong>ASK the user</strong> (default: 0.30 = 30%)</li> <li><code>side</code> → from <code>/positions</code> → <code>side</code> ("long" or "short")</li> </ol> <p><strong>If you just opened a position:</strong> Use <code>actualTradeIndex</code> and <code>entryPrice</code> from the <code>/open-position</code> response. <strong>If the position was opened earlier:</strong> Call <code>/positions</code> to fetch <code>tradeIndex</code>, <code>entryPrice</code>, <code>pairIndex</code>, and <code>side</code>.</p> </blockquote> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/set-take-profit" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "agentAddress": "0x...", "userAddress": "0x...", "market": "BTC", "tradeIndex": 2, "takeProfitPercent": 0.30, "entryPrice": 90000, "pairIndex": 0 }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "agentAddress": "0x...", // REQUIRED — from /user-details. NEVER guess. "userAddress": "0x...", // REQUIRED — from /user-details. NEVER guess. "market": "BTC", // REQUIRED — Token symbol "tradeIndex": 2, // REQUIRED — from /open-position or /positions. NEVER guess. "takeProfitPercent": 0.30, // Optional (default: 0.30 = 30%). ASK the user. "entryPrice": 90000, // REQUIRED — from /open-position or /positions. NEVER guess. "pairIndex": 0, // REQUIRED — from /positions or /symbols. NEVER guess. "side": "long", // Optional (default: "long") — from /positions. "isTestnet": false // Optional. Set true only when user explicitly asks for Ostium testnet / Arbitrum Sepolia. } </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "message": "Take profit set successfully", "tpPrice": 117000.0 } </code></pre> <h3>Set Stop Loss</h3> <p>Set or update stop-loss level for an existing position on Ostium.</p> <blockquote> <p><strong>⚠️ Dependencies — identical to Set Take Profit. You need ALL of these before calling:</strong></p> <ol> <li><code>agentAddress</code> → from <code>/user-details</code> → <code>ostium_agent_address</code></li> <li><code>userAddress</code> → from <code>/user-details</code> → <code>user_wallet</code></li> <li><code>tradeIndex</code> → from <code>/open-position</code> response → <code>actualTradeIndex</code>, <strong>OR</strong> from <code>/positions</code> → <code>tradeIndex</code></li> <li><code>entryPrice</code> → from <code>/open-position</code> response → <code>entryPrice</code>, <strong>OR</strong> from <code>/positions</code> → <code>entryPrice</code></li> <li><code>pairIndex</code> → from <code>/positions</code> → <code>pairIndex</code>, <strong>OR</strong> from <code>/symbols</code> → symbol <code>id</code></li> <li><code>stopLossPercent</code> → <strong>ASK the user</strong> (default: 0.10 = 10%)</li> <li><code>side</code> → from <code>/positions</code> → <code>side</code> ("long" or "short")</li> </ol> <p><strong>If you just opened a position:</strong> Use <code>actualTradeIndex</code> and <code>entryPrice</code> from the <code>/open-position</code> response. <strong>If the position was opened earlier:</strong> Call <code>/positions</code> to fetch <code>tradeIndex</code>, <code>entryPrice</code>, <code>pairIndex</code>, and <code>side</code>.</p> </blockquote> <pre><code class="language-bash"># Same dependency resolution as Set Take Profit (see above for full example) # Step 1: Get addresses from /user-details # Step 2: Get position details from /positions # Step 3: Set stop loss with user-specified stopLossPercent curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/set-stop-loss" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "agentAddress": "0x...", "userAddress": "0x...", "market": "BTC", "tradeIndex": 2, "stopLossPercent": 0.10, "entryPrice": 90000, "pairIndex": 0, "side": "long" }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "agentAddress": "0x...", // REQUIRED — from /user-details. NEVER guess. "userAddress": "0x...", // REQUIRED — from /user-details. NEVER guess. "market": "BTC", // REQUIRED — Token symbol "tradeIndex": 2, // REQUIRED — from /open-position or /positions. NEVER guess. "stopLossPercent": 0.10, // Optional (default: 0.10 = 10%). ASK the user. "entryPrice": 90000, // REQUIRED — from /open-position or /positions. NEVER guess. "pairIndex": 0, // REQUIRED — from /positions or /symbols. NEVER guess. "side": "long", // Optional (default: "long") — from /positions. "isTestnet": false // Optional. Set true only when user explicitly asks for Ostium testnet / Arbitrum Sepolia. } </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "message": "Stop loss set successfully", "slPrice": 81000.0, "liquidationPrice": 85500.0, "adjusted": false } </code></pre> <h3>Get All Market Data</h3> <p>Retrieve the complete market snapshot from Ostium, including all symbols and their current metrics. This is useful for market-wide scanning or analysis in a single request.</p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/market-data" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "data": [ { "id": 0, "symbol": "BTC/USD", "group": "crypto", "maxLeverage": 150, "metrics": { "price": "95000.12345678", "percent_change_24h": 2.45, "volatility": 0.032, "volume_24h": "45000000000.00000000", "market_cap": "1850000000000.00000000" }, "updated_at": "2026-02-14T08:30:00.000Z" }, ... ], "count": 45 } </code></pre> <h3>Get Token Price</h3> <p>Fetch the current market price for a token from Ostium price feed.</p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/price?token=BTC&isTestnet=false" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" </code></pre> <p><strong>Query Parameters:</strong></p> <table><thead><tr><th>Parameter</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>string</td><td>Yes</td><td>Token symbol to fetch price for (e.g., BTC, ETH, SOL)</td></tr><tr><td><code>isTestnet</code></td><td>boolean</td><td>No</td><td>Use Ostium testnet / Arbitrum Sepolia when explicitly requested by the user</td></tr></tbody></table> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "token": "BTC", "price": 95000.0, "isMarketOpen": true, "isDayTradingClosed": false } </code></pre> <h3>Discover Traders to Copy (Copy Trading — Step 1)</h3> <p>Discover other OpenClaw Traders and top-performing traders to potentially copy-trade. This is the <strong>first step</strong> in the copy-trading workflow — the returned wallet addresses are used as the <code>address</code> parameter in the <code>/copy-trader-trades</code> endpoint.</p> <blockquote> <p><strong>⚠️ Dependency Chain</strong>: This endpoint provides the wallet addresses needed by <code>/copy-trader-trades</code>. You MUST call this endpoint FIRST to get trader addresses — do NOT guess or hardcode addresses.</p> <p><strong>🚫 Self-copy guard</strong>: Never use your own <code>user_wallet</code> from <code>/user-details</code> as a copy-trader address.</p> </blockquote> <pre><code class="language-bash"># Get all traders (OpenClaw + Leaderboard) curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/copy-traders" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" # Get only OpenClaw Traders (prioritized) curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/copy-traders?source=openclaw" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" # Get only Leaderboard traders with filters curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/copy-traders?source=leaderboard&minImpactFactor=50&minTrades=100" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" </code></pre> <p><strong>Query Parameters:</strong></p> <table><thead><tr><th>Parameter</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>source</code></td><td>string</td><td><code>all</code></td><td><code>openclaw</code> (OpenClaw agents only), <code>leaderboard</code> (top traders only), <code>all</code> (both)</td></tr><tr><td><code>limit</code></td><td>int</td><td>20</td><td>Max results per tier (max 100)</td></tr><tr><td><code>minTrades</code></td><td>int</td><td>—</td><td>Min trade count filter (leaderboard only)</td></tr><tr><td><code>minImpactFactor</code></td><td>float</td><td>—</td><td>Min impact factor filter (leaderboard only)</td></tr></tbody></table> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "openclawTraders": [ { "agentId": "3dbc322f-...", "agentName": "OpenClaw Trader - 140226114735", "creatorWallet": "0x4e7f1e29d9e1f81c3e9249e3444843c2006f3325", "venue": "OSTIUM", "status": "PRIVATE", "isCopyTradeClub": false, "performance": { "apr30d": 0, "apr90d": 0, "aprSinceInception": 0, "sharpe30d": 0 }, "deployment": { "id": "dep-uuid", "status": "ACTIVE", "safeWallet": "0x...", "isTestnet": true } } ], "topTraders": [ { "walletAddress": "0xabc...", "totalVolume": "1500000.000000", "totalClosedVolume": "1200000.000000", "totalPnl": "85000.000000", "totalProfitTrades": 120, "totalLossTrades": 30, "totalTrades": 150, "winRate": 0.80, "lastActiveAt": "2026-02-15T10:30:00.000Z", "scores": { "edgeScore": 0.82, "consistencyScore": 0.75, "stakeScore": 0.68, "freshnessScore": 0.92, "impactFactor": 72.5 }, "updatedAt": "2026-02-17T06:00:00.000Z" } ], "openclawCount": 5, "topTradersCount": 20 } </code></pre> <p><strong>Key fields to use in next steps:</strong></p> <ul> <li><code>openclawTraders[].creatorWallet</code> → use as <code>address</code> in <code>/copy-trader-trades</code></li> <li><code>topTraders[].walletAddress</code> → use as <code>address</code> in <code>/copy-trader-trades</code></li> <li>Exclude any address equal to your own <code>/user-details.user_wallet</code></li> </ul> <h3>Get Trader's Recent Trades (Copy Trading — Step 2)</h3> <p>Fetch recent on-chain trades for a specific trader address. This queries the Ostium subgraph in real-time for fresh trade data.</p> <blockquote> <p><strong>⚠️ Dependency</strong>: The <code>address</code> parameter MUST come from the <code>/copy-traders</code> endpoint response:</p> <ul> <li>For OpenClaw traders: use <code>creatorWallet</code> from <code>openclawTraders[]</code></li> <li>For leaderboard traders: use <code>walletAddress</code> from <code>topTraders[]</code></li> </ul> <p><strong>NEVER guess or hardcode the address.</strong> Always call <code>/copy-traders</code> first.</p> </blockquote> <pre><code class="language-bash"># Step 1: Discover traders first TRADER_ADDRESS=$(curl -s -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/copy-traders?source=openclaw" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" | jq -r '.openclawTraders[0].creatorWallet') # Step 2: Fetch their recent trades curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/copy-trader-trades?address=${TRADER_ADDRESS}" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" # With custom lookback and limit curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/copy-trader-trades?address=${TRADER_ADDRESS}&hours=48&limit=50" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" </code></pre> <p><strong>Query Parameters:</strong></p> <table><thead><tr><th>Parameter</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>address</code></td><td>string</td><td><em>required</em></td><td>Trader wallet address (from <code>/copy-traders</code>)</td></tr><tr><td><code>limit</code></td><td>int</td><td>20</td><td>Max trades to return (max 50)</td></tr><tr><td><code>hours</code></td><td>int</td><td>24</td><td>Lookback window in hours (max 168 / 7 days)</td></tr></tbody></table> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "traderAddress": "0x4e7f1e29d9e1f81c3e9249e3444843c2006f3325", "trades": [ { "tradeId": "0x123...", "side": "LONG", "tokenSymbol": "BTC", "pair": "BTC/USD", "collateral": 500.00, "leverage": 10.0, "entryPrice": 95000.50, "takeProfitPrice": 100000.00, "stopLossPrice": 90000.00, "timestamp": "2026-02-17T14:30:00.000Z" } ], "count": 5, "lookbackHours": 24 } </code></pre> <p><strong>Trade Field Descriptions:</strong></p> <table><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><code>side</code></td><td><code>"LONG"</code> or <code>"SHORT"</code> — the trade direction</td></tr><tr><td><code>tokenSymbol</code></td><td>Token being traded (e.g., <code>BTC</code>, <code>ETH</code>)</td></tr><tr><td><code>pair</code></td><td>Full pair label (e.g., <code>BTC/USD</code>)</td></tr><tr><td><code>collateral</code></td><td>USDC amount used as collateral</td></tr><tr><td><code>leverage</code></td><td>Leverage multiplier (e.g., 10.0 = 10x)</td></tr><tr><td><code>entryPrice</code></td><td>Price at which the trade was opened</td></tr><tr><td><code>takeProfitPrice</code></td><td>Take profit price (null if not set)</td></tr><tr><td><code>stopLossPrice</code></td><td>Stop loss price (null if not set)</td></tr><tr><td><code>timestamp</code></td><td>When the trade was opened</td></tr></tbody></table> <blockquote> <p><strong>Next step</strong>: After reviewing the trades, use <code>/open-position</code> to open a similar position. You'll need your own <code>agentAddress</code> and <code>userAddress</code> from <code>/user-details</code>.</p> </blockquote> <h2>Signal Format Examples</h2> <p>The lazy trading system processes natural language trading signals. Here are examples:</p> <h3>Opening Positions</h3> <ul> <li><code>"Long ETH with 5x leverage, entry at 3200"</code></li> <li><code>"Short BTC 10x, TP 60000, SL 68000"</code></li> <li><code>"Buy 100 USDC worth of ETH perpetual"</code></li> </ul> <h3>With Risk Management</h3> <ul> <li><code>"Long SOL 3x leverage, entry 150, take profit 180, stop loss 140"</code></li> <li><code>"Short AVAX 5x, risk 2% of portfolio"</code></li> </ul> <h3>Closing Positions</h3> <ul> <li><code>"Close ETH long position"</code></li> <li><code>"Take profit on BTC short"</code></li> </ul> <hr/> <h2>Complete Workflow Examples</h2> <p>These are the mandatory step-by-step workflows for common trading operations. <strong>Follow these exactly.</strong></p> <h3>Workflow 1: Opening a New Position (Full Flow)</h3> <pre><code>Step 1: GET /user-details → Extract: user_wallet (→ userAddress), ostium_agent_address (→ agentAddress) → Cache these for the session Step 2: GET /symbols → Verify the user's requested token is available on Ostium → Extract exact symbol string and maxLeverage → Convert pair format to market token for /open-position: "ETH/USD" -> "ETH" Step 3: POST /api/lazy-trading/research (or GET /market-data or GET /price for current context) → Get trade context: market structure, momentum, support/resistance, catalysts, and current price → Present this data to the user: "BTC is trading around $95,000 with bullish structure and clear support/resistance levels. Do you want to proceed?" Step 4: ASK the user for trade parameters → "Please confirm: collateral (USDC), leverage, long or short?" → "Would you like to set TP and SL? If so, what percentages?" → Wait for explicit user confirmation before proceeding Step 5: POST /open-position → Use agentAddress and userAddress from Step 1 → Use market, side, collateral, leverage from Step 4 → IMPORTANT: Pass market as base token only (e.g. ETH), not pair format (ETH/USD) → SAVE the response: actualTradeIndex and entryPrice Step 6 (if user wants TP/SL): POST /set-take-profit and/or POST /set-stop-loss → Use tradeIndex = actualTradeIndex from Step 5 → Use entryPrice from Step 5 → For pairIndex, use the symbol id from Step 2 or call /positions → Use takeProfitPercent/stopLossPercent from Step 4 Step 7: ASK — "Would you like to list this trade as alpha on the marketplace?" → If user says NO → Done. → If user says YES → Continue to Step 8. → Also ask: "What price in USDC would you like to charge?" (e.g. 5 USDC) Step 8: POST /alpha/generate-proof → Body: { "tradeId": "{tradeId from Step 5}", "autoProcess": false } → tradeId comes from the /open-position response → autoProcess: false queues the proof for the worker (~3-5 min) → SAVE: proofId from the response Step 9: Wait for proof verification → If autoProcess was true and response has status: "VERIFIED" → go to Step 10 → If autoProcess was false or status is still PENDING/PROVING: Poll GET /alpha/proof-status?proofId={proofId} every 10 seconds → Wait until status === "VERIFIED" → If status === "FAILED" → inform the user and stop Step 10: POST /alpha/flag → Body: { "proofId": "{proofId from Step 8}", "priceUsdc": {price from Step 7}, "token": "{market from Step 5, e.g. ETH}", "side": "{side from Step 5, e.g. long}", "leverage": {leverage from Step 5} } → Show user the response: listingId, tradeId, proofMetrics → "Your trade is now listed as alpha! Listing ID: {listingId}" </code></pre> <h3>Workflow 2: Closing an Existing Position</h3> <pre><code>Step 1: GET /user-details → Extract: user_wallet, ostium_agent_address Step 2: POST /positions (address = user_wallet from Step 1) → List all open positions → Present them to the user if multiple: "You have 3 open positions: BTC long, ETH short, SOL long. Which one do you want to close?" → Extract the tradeIndex for the position to close Step 3: POST /close-position → Use agentAddress and userAddress from Step 1 → Use market and actualTradeIndex from Step 2 → Show the user the closePnl from the response </code></pre> <h3>Workflow 3: Setting TP/SL on an Existing Position</h3> <pre><code>Step 1: GET /user-details → Extract: user_wallet, ostium_agent_address Step 2: POST /positions (address = user_wallet from Step 1) → Find the target position → Extract: tradeIndex, entryPrice, pairIndex, side Step 3: ASK the user → "Position: BTC long at $95,000. Current TP: none, SL: $85,500." → "What TP% and SL% would you like to set?" Step 4: POST /set-take-profit and/or POST /set-stop-loss → Use ALL values from Steps 1-3 — NEVER guess any of them </code></pre> <h3>Workflow 4: Checking Portfolio & Market Overview</h3> <pre><code>Step 1: GET /user-details → Extract: user_wallet Step 2: POST /balance (address = user_wallet) → Show the user their USDC and ETH balances Step 3: POST /positions (address = user_wallet) → Show all open positions with PnL details Step 4 (optional): GET /market-data → Show market conditions for tokens they hold </code></pre> <h3>Workflow 5: Copy-Trading Another OpenClaw Agent (Full Flow)</h3> <pre><code>Step 1: GET /copy-traders?source=openclaw → Discover other OpenClaw Trader agents → Extract: creatorWallet from the trader you want to copy → Exclude your own wallet (`/user-details.user_wallet`) if it appears → IMPORTANT: This is a REQUIRED first step — you cannot call /copy-trader-trades without an address from this endpoint Step 2: GET /copy-trader-trades?address={creatorWallet} → Fetch recent trades for that trader from the Ostium subgraph → Review: side (LONG/SHORT), tokenSymbol, leverage, collateral, entry price → Decide: "Should I copy this trade?" → DEPENDENCY: The address param comes from Step 1 (creatorWallet or walletAddress) Step 3: GET /user-details → Get YOUR OWN userAddress (user_wallet) and agentAddress (ostium_agent_address) → These are needed to execute your own trade Step 4: POST /open-position → Mirror the trade from Step 2 using your own addresses from Step 3: - market = tokenSymbol from the copied trade - side = side from the copied trade (LONG/SHORT → long/short) - collateral = decide based on your own risk tolerance - leverage = match the copied trader's leverage or adjust → SAVE: actualTradeIndex and entryPrice from response Step 5 (optional): POST /set-take-profit and/or POST /set-stop-loss → Use actualTradeIndex and entryPrice from Step 4 → Match the copied trader's TP/SL ratios or set your own </code></pre> <p><strong>Dependency Chain Summary:</strong></p> <pre><code>/copy-traders → provides address → /copy-trader-trades → provides trade details /user-details → provides your addresses → /open-position → copies the trade </code></pre> <hr/> <h2>Automated Trading Strategies</h2> <p>Maxxit provides specialized scripts for different market conditions. These scripts require dynamic parameters passed via command line.</p> <h3>Execution Policy</h3> <ul> <li><strong>Dynamic Arguments</strong>: Scripts MUST be invoked with <code>--symbol</code> and <code>--venue</code>.</li> <li><strong>Agent Responsibility</strong>: If the user asks to start a strategy but does not provide the symbol (e.g., "BTC/USD") or the venue (e.g., "AVANTIS"), the agent MUST ask the user for the missing information before executing the script.</li> <li><strong>Example Command</strong>: <code>python taker-strategy.py --symbol BTC/USD --venue AVANTIS</code></li> </ul> <h3>1. Aggressive Taker (HFT / Order Flow)</h3> <ul> <li><strong>Script</strong>: <code>taker-strategy.py</code></li> <li><strong>Usage</strong>: <code>python taker-strategy.py --symbol <SYMBOL> --venue <VENUE></code></li> <li><strong>Logic Summary</strong>: Monitors the "Taker Buy Ratio" on Binance. When aggressive buyers (takers) dominate sellers beyond a threshold (0.60), it signals a high-conviction momentum move.</li> <li><strong>Best For</strong>: Capturing rapid price changes in high-volume environments (Active Scalping).</li> </ul> <h3>2. Mean Reversion (Sideways / Range)</h3> <ul> <li><strong>Script</strong>: <code>mean-reversion-strategy.py</code></li> <li><strong>Usage</strong>: <code>python mean-reversion-strategy.py --symbol <SYMBOL> --venue <VENUE></code></li> <li><strong>Logic Summary</strong>: Combines RSI (extreme oversold/overbought) with Bollinger Band touches. It identifies "exhaustion" points where the price is likely to bounce back to the average.</li> <li><strong>Best For</strong>: Range-bound or sideways markets where there is no clear trend.</li> </ul> <h3>3. Volatility Breakout (Momentum)</h3> <ul> <li><strong>Script</strong>: <code>breakout-strategy.py</code></li> <li><strong>Usage</strong>: <code>python breakout-strategy.py --symbol <SYMBOL> --venue <VENUE></code></li> <li><strong>Logic Summary</strong>: Enters a trade only when price breaks out of a standard deviation channel (Bollinger Bands) <em>and</em> volatility (ATR) is increasing. This filters out "fake" breakouts.</li> <li><strong>Best For</strong>: Catching the start of a strong trend after a period of consolidation.</li> </ul> <h3>4. VWAP Crossover (Institutional Momentum)</h3> <ul> <li><strong>Script</strong>: <code>vwap-strategy.py</code></li> <li><strong>Usage</strong>: <code>python vwap-strategy.py --symbol <SYMBOL> --venue <VENUE></code></li> <li><strong>Logic Summary</strong>: Uses Volume Weighted Average Price (VWAP) combined with a 20 EMA. A "Long" is triggered when price is above both the VWAP and the EMA, signaling that both volume and time-weighted momentum are positive.</li> <li><strong>Best For</strong>: Intraday momentum trading and confirming trend strength with volume.</li> </ul> <hr/> <h2>Aster DEX (BNB Chain) Endpoints</h2> <blockquote> <p>Aster DEX is a perpetual futures exchange on BNB Chain. Use Aster endpoints when the user wants to trade on BNB Chain. The Aster API uses <strong>API Key + Secret</strong> authentication (stored server-side) — you do NOT need <code>agentAddress</code>. You only need <code>userAddress</code> from <code>/user-details</code>.</p> </blockquote> <h3>Venue Selection</h3> <table><thead><tr><th>Venue</th><th>Chain</th><th>Symbol Format</th><th>Auth Required</th><th>When to Use</th></tr></thead><tbody><tr><td><strong>Ostium</strong></td><td>Arbitrum (mainnet by default, testnet on explicit request)</td><td><code>BTC</code>, <code>ETH</code></td><td><code>agentAddress</code> + <code>userAddress</code></td><td>Default for most trades</td></tr><tr><td><strong>Aster</strong></td><td>BNB Chain (testnet only)</td><td><code>BTCUSDT</code>, <code>ETHUSDT</code></td><td><code>userAddress</code> only</td><td>When user specifies BNB Chain or Aster</td></tr><tr><td><strong>Avantis</strong></td><td>Base (mainnet only)</td><td>Base token for orders (e.g. <code>BTC</code>), pair format in symbols/positions (e.g. <code>BTC/USD</code>)</td><td><code>agentAddress</code> + <code>userAddress</code></td><td>When user specifies Base chain or Avantis</td></tr></tbody></table> <blockquote> <p><strong>Network behavior rule:</strong> Do not ask users to choose mainnet/testnet for these venues by default. Ostium uses mainnet unless the user explicitly asks for testnet / Arbitrum Sepolia. Aster is fixed to testnet, and Avantis is fixed to Base mainnet.</p> </blockquote> <p><strong>How to check if Aster is configured:</strong> In the <code>/user-details</code> response, <code>aster_configured: true</code> means the user has set up Aster API keys. If <code>false</code>, direct them to set up Aster at maxxit.ai/openclaw.</p> <h3>Aster Symbols</h3> <p>Aster uses Binance-style symbol format: <code>BTCUSDT</code>, <code>ETHUSDT</code>, etc. The API auto-appends <code>USDT</code> if you pass just <code>BTC</code>.</p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/aster/symbols" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "symbols": [ { "symbol": "BTCUSDT", "baseAsset": "BTC", "quoteAsset": "USDT", "pricePrecision": 2, "quantityPrecision": 3, "contractType": "PERPETUAL", "status": "TRADING" } ], "count": 50 } </code></pre> <h3>Aster Price</h3> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/aster/price?token=BTC" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "token": "BTC", "symbol": "BTCUSDT", "price": 95000.50 } </code></pre> <h3>Aster Market Data</h3> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/aster/market-data?symbol=BTC" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" </code></pre> <h3>Aster Balance</h3> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/aster/balance" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "userAddress": "0x..." }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "userAddress": "0x..." // REQUIRED — from /user-details → user_wallet. NEVER guess. } </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "balance": 1000.50, "availableBalance": 800.25, "unrealizedProfit": 50.10 } </code></pre> <h3>Aster Positions</h3> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/aster/positions" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "userAddress": "0x..." }' </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "positions": [ { "symbol": "BTCUSDT", "positionAmt": 0.01, "entryPrice": 95000.0, "markPrice": 96000.0, "unrealizedProfit": 10.0, "liquidationPrice": 80000.0, "leverage": 10, "side": "long" } ], "count": 1 } </code></pre> <h3>Aster History (All Orders)</h3> <p>Fetch full order history for a symbol (includes active, canceled, and filled orders) from Aster.</p> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/aster/history" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "userAddress": "0x...", "symbol": "BTC", "limit": 100 }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "userAddress": "0x...", // REQUIRED — from /user-details → user_wallet "symbol": "BTC", // REQUIRED — token or full symbol (BTC or BTCUSDT) "limit": 100, // Optional — default depends on exchange (max 1000) "orderId": 12345, // Optional — fetch from this orderId onward "startTime": 1709251200000, // Optional — ms timestamp "endTime": 1709856000000 // Optional — ms timestamp } </code></pre> <blockquote> <p><code>POST /api/lazy-trading/programmatic/aster/history</code> now proxies to Aster <code>/fapi/v3/allOrders</code>. Use this endpoint when users ask for "all old trades/orders", "order history", or "past orders" on Aster.</p> </blockquote> <h3>Aster Open Position</h3> <blockquote> <p><strong>📋 LLM Pre-Call Checklist — Ask the user these questions before calling this endpoint:</strong></p> <ol> <li><strong>Symbol</strong>: "Which token do you want to trade?" (e.g. BTC, ETH, SOL)</li> <li><strong>Side</strong>: "Long or short?"</li> <li><strong>Quantity</strong>: "How much [TOKEN] do you want to trade?" — get the answer in base asset units (e.g. <code>0.01 BTC</code>, <code>0.5 ETH</code>).</li> <li><strong>Leverage</strong>: "What leverage? (e.g. 10x)"</li> <li><strong>Order type</strong>: "Market order or limit order?" (default: MARKET). If LIMIT, also ask for the limit price.</li> </ol> <p><strong>Aster requires <code>quantity</code> (base asset) for open-position. Do not use collateral.</strong> <strong>NEVER call this endpoint without a confirmed <code>quantity</code> in base asset units.</strong></p> </blockquote> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/aster/open-position" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "userAddress": "0x...", "symbol": "BTC", "side": "long", "quantity": 0.01, "leverage": 10 }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "userAddress": "0x...", // REQUIRED — from /user-details → user_wallet. NEVER guess. "symbol": "BTC", // REQUIRED — Token name or full symbol (BTCUSDT). ASK the user. "side": "long", // REQUIRED — "long" or "short". ASK the user. "quantity": 0.01, // REQUIRED — Position size in BASE asset (e.g. 0.01 BTC). ASK the user. "leverage": 10, // Optional — Leverage multiplier. ASK the user. "type": "MARKET", // Optional — "MARKET" (default) or "LIMIT". ASK the user. "price": 95000 // Required only for LIMIT orders. ASK the user if type is LIMIT. } </code></pre> <blockquote> <p>⚠️ <strong>IMPORTANT:</strong> <code>quantity</code> must always be specified in the <strong>base asset</strong> (e.g. <code>0.01</code> for 0.01 BTC).<br/> <!-- -->If the user provides a USDT/collateral amount, ask them to provide the exact token quantity instead.<br/> <!-- -->Do not convert collateral to quantity in this workflow.</p> </blockquote> <p><strong>Response (IMPORTANT — save these values):</strong></p> <pre><code class="language-json">{ "success": true, "orderId": 12345678, "symbol": "BTCUSDT", "side": "BUY", "status": "FILLED", "avgPrice": "95000.50", "executedQty": "0.010", "message": "Position opened: long BTCUSDT" } </code></pre> <h3>Aster Close Position</h3> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/aster/close-position" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "userAddress": "0x...", "symbol": "BTC" }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "userAddress": "0x...", // REQUIRED "symbol": "BTC", // REQUIRED "quantity": 0.005 // Optional — omit to close full position } </code></pre> <h3>Aster Set Take Profit</h3> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/aster/set-take-profit" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "userAddress": "0x...", "symbol": "BTC", "takeProfitPercent": 0.30, "entryPrice": 95000, "side": "long" }' </code></pre> <p><strong>Request Body (two options):</strong></p> <pre><code class="language-json">{ "userAddress": "0x...", "symbol": "BTC", "stopPrice": 123500 // Option A: exact trigger price } </code></pre> <pre><code class="language-json">{ "userAddress": "0x...", "symbol": "BTC", "takeProfitPercent": 0.30, // Option B: percentage (0.30 = 30%) "entryPrice": 95000, "side": "long" } </code></pre> <h3>Aster Set Stop Loss</h3> <p>Same pattern as take profit:</p> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/aster/set-stop-loss" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "userAddress": "0x...", "symbol": "BTC", "stopLossPercent": 0.10, "entryPrice": 95000, "side": "long" }' </code></pre> <h3>Aster Change Leverage</h3> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/aster/change-leverage" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "userAddress": "0x...", "symbol": "BTC", "leverage": 20 }' </code></pre> <h3>Aster Parameter Dependency Graph</h3> <table><thead><tr><th>Parameter</th><th>Source</th><th>How to Get</th></tr></thead><tbody><tr><td><code>userAddress</code></td><td><code>/user-details</code> → <code>user_wallet</code></td><td><code>GET /user-details</code></td></tr><tr><td><code>aster_configured</code></td><td><code>/user-details</code> → <code>aster_configured</code></td><td><code>GET /user-details</code> (must be <code>true</code>)</td></tr><tr><td><code>symbol</code></td><td>User specifies token</td><td>User input (auto-resolved: <code>BTC</code> → <code>BTCUSDT</code>)</td></tr><tr><td><code>side</code></td><td>User specifies <code>"long"</code> or <code>"short"</code></td><td>User input (required)</td></tr><tr><td><code>quantity</code></td><td>User specifies in base asset units (e.g. <code>0.01 BTC</code>)</td><td>User input (required). If user provides USDT/collateral amount, ask for quantity instead. Do not calculate in the workflow.</td></tr><tr><td><code>leverage</code></td><td>User specifies</td><td>User input</td></tr><tr><td><code>entryPrice</code></td><td><code>/aster/positions</code> → <code>entryPrice</code></td><td>From position data</td></tr><tr><td><code>stopPrice</code></td><td>User specifies or calculated from percent</td><td>User input or calculated</td></tr></tbody></table> <h3>Aster Workflow: Open Position on BNB Chain</h3> <pre><code>Step 1: GET /user-details → Extract: user_wallet → Check: aster_configured == true (if false, tell user to set up Aster at maxxit.ai/openclaw) Step 2: GET /aster/symbols → Verify the token is available on Aster Step 3: GET /aster/price?token=BTC → Get current price, present to user Step 4: ASK the user for ALL trade parameters → "Which token?" (e.g. BTC, ETH, SOL) → "Long or short?" → "How much [TOKEN] do you want to buy/sell?" — collect answer in BASE asset units (e.g. 0.01 BTC) • If user gives a USDT/collateral amount, ask them to provide token quantity instead. → "Leverage? (e.g. 10x)" → "Market or limit order?" — if LIMIT, also ask for the limit price Step 5: POST /aster/open-position → Use userAddress from Step 1 → Use symbol, side, quantity (base asset), leverage from Step 4 → SAVE orderId and avgPrice from response Step 6 (if user wants TP/SL): POST /aster/set-take-profit and/or POST /aster/set-stop-loss → Use entryPrice = avgPrice from Step 5 → Use side from Step 4 → Ask user for takeProfitPercent / stopLossPercent (or exact stopPrice) </code></pre> <h3>Aster Workflow: Close Position</h3> <pre><code>Step 1: GET /user-details → Extract user_wallet Step 2: POST /aster/positions (userAddress = user_wallet) → Show positions to user, let them pick which to close Step 3: POST /aster/close-position → Pass userAddress and symbol → Omit quantity to close full position </code></pre> <hr/> <h2>Avantis DEX (Base Chain) Endpoints</h2> <blockquote> <p>Avantis DEX is a perpetual futures exchange on Base chain. Use Avantis endpoints when the user wants to trade on Base. Avantis uses <strong>delegation-based auth</strong> (same pattern as Ostium) — you need both <code>agentAddress</code> and <code>userAddress</code> from <code>/user-details</code>.</p> </blockquote> <p><strong>How to check if Avantis is configured:</strong> Use <code>/user-details</code> and check <code>deployment.enabled_venues</code>. If it includes <code>"AVANTIS"</code>, Avantis is enabled for the current deployment. If not, direct the user to enable Avantis at maxxit.ai/openclaw.</p> <h3>Avantis Symbols</h3> <p>Avantis symbols are returned in pair format (e.g. <code>BTC/USD</code>, <code>ETH/USD</code>). The API endpoint maps the service's <code>/markets</code> route.</p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/avantis/symbols" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "markets": [ { "pairIndex": 0, "symbol": "BTC/USD", "group": "crypto" }, { "pairIndex": 1, "symbol": "ETH/USD", "group": "crypto" } ], "count": 50 } </code></pre> <h3>Avantis Get Token Price</h3> <p>Fetch the latest price for a specific token on Avantis.</p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/avantis/price?token=BTC" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" </code></pre> <p><strong>Query Parameters:</strong></p> <table><thead><tr><th>Parameter</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>string</td><td>Yes</td><td>Token symbol or pair (e.g. <code>BTC</code> or <code>BTC/USD</code>)</td></tr></tbody></table> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "token": "BTC", "market": "BTC/USD", "pairIndex": 0, "price": 95000.12 } </code></pre> <h3>Avantis Balance</h3> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/avantis/balance" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "userAddress": "0x..." }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "userAddress": "0x..." // REQUIRED — from /user-details → user_wallet. NEVER guess. } </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "usdcBalance": "1500.25", "ethBalance": "0.05" } </code></pre> <h3>Avantis Positions</h3> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/avantis/positions" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "userAddress": "0x...", "agentAddress": "0x..." }' </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "positions": [ { "market": "BTC/USD", "marketFull": "BTC/USD", "side": "long", "collateral": 100.0, "entryPrice": 95000.0, "leverage": 10.0, "tradeId": "0:2", "tradeIndex": 2, "pairIndex": 0 } ], "totalPositions": 1 } </code></pre> <h3>Avantis Open Position</h3> <blockquote> <p><strong>⚠️ Dependencies:</strong></p> <ol> <li><code>agentAddress</code> → from <code>/user-details</code> → <code>ostium_agent_address</code> (shared agent wallet; NEVER guess)</li> <li><code>userAddress</code> → from <code>/user-details</code> → <code>user_wallet</code> (NEVER guess)</li> <li><code>market</code> → validate via <code>/avantis/symbols</code>. Use base token only (e.g. <code>BTC</code>, not <code>BTC/USD</code>)</li> <li><code>side</code>, <code>collateral</code>, <code>leverage</code> → <strong>ASK the user explicitly</strong></li> </ol> <p><strong>Avantis uses <code>collateral</code> (USDC amount), similar to Ostium.</strong></p> <p><strong>TP/SL can be set at open (<code>takeProfitPercent</code> / <code>stopLossPercent</code>) or updated later via <code>/avantis/update-sl-tp</code>.</strong></p> </blockquote> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/avantis/open-position" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "agentAddress": "0x...", "userAddress": "0x...", "market": "BTC", "side": "long", "collateral": 100, "leverage": 10, "takeProfitPercent": 0.30, "stopLossPercent": 0.10 }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "agentAddress": "0x...", // REQUIRED — from /user-details → ostium_agent_address (shared wallet). NEVER guess. "userAddress": "0x...", // REQUIRED — from /user-details → user_wallet. NEVER guess. "market": "BTC", // REQUIRED — Base token only (e.g. "ETH", not "ETH/USD") "side": "long", // REQUIRED — "long" or "short". ASK the user. "collateral": 100, // REQUIRED — Collateral in USDC. ASK the user. "leverage": 10, // Optional (default: 10). ASK the user. "takeProfitPercent": 0.30, // Optional — set TP at open. ASK the user. "stopLossPercent": 0.10 // Optional — set SL at open. ASK the user. } </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "txHash": "0x...", "actualTradeIndex": 5, "entryPrice": 95000.0, "slSet": true, "tpSet": true, "message": "Trade submitted on Avantis", "result": { "market": "BTC", "side": "long", "collateral": 100, "leverage": 10, "slConfigured": true, "tpConfigured": true, "tpPrice": 123500.0, "slPrice": 85500.0 } } </code></pre> <h3>Avantis Close Position</h3> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/avantis/close-position" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "agentAddress": "0x...", "userAddress": "0x...", "market": "BTC" }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "agentAddress": "0x...", // REQUIRED — from /user-details. NEVER guess. "userAddress": "0x...", // REQUIRED — from /user-details. NEVER guess. "market": "BTC", // REQUIRED — Token symbol "tradeId": "0:2", // Optional — preferred composite ID from /avantis/positions (pairIndex:tradeIndex) "actualTradeIndex": 2 // Recommended — from /avantis/positions → tradeIndex } </code></pre> <h3>Avantis Update SL/TP</h3> <blockquote> <p><strong>TP/SL can be set at open time (via <code>takeProfitPercent</code>/<code>stopLossPercent</code> in open-position), or updated after opening using this endpoint.</strong></p> </blockquote> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/avantis/update-sl-tp" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "agentAddress": "0x...", "userAddress": "0x...", "market": "BTC", "takeProfitPercent": 0.30, "stopLossPercent": 0.10 }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "agentAddress": "0x...", // REQUIRED — from /user-details. NEVER guess. "userAddress": "0x...", // REQUIRED — from /user-details. NEVER guess. "market": "BTC", // REQUIRED — Token symbol "tradeIndex": 0, // Optional — specific trade index from /avantis/positions "takeProfitPrice": 100000, // Absolute TP price (use this OR takeProfitPercent) "stopLossPrice": 80000, // Absolute SL price (use this OR stopLossPercent) "takeProfitPercent": 0.30, // TP as % from entry (0.30 = 30%). Use this OR takeProfitPrice. "stopLossPercent": 0.10 // SL as % from entry (0.10 = 10%). Use this OR stopLossPrice. } </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "txHash": "0x...", "message": "TP/SL updated successfully", "result": { "market": "BTC", "tradeIndex": 0, "entryPrice": 95000.0, "takeProfitPrice": 123500.0, "stopLossPrice": 85500.0, "side": "long" } } </code></pre> <h3>Avantis Trade History</h3> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/history" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "venue": "AVANTIS", "userAddress": "0x...", "count": 50 }' </code></pre> <p><strong>Request Body:</strong></p> <pre><code class="language-json">{ "venue": "AVANTIS", // REQUIRED for Avantis via /history "userAddress": "0x...", // REQUIRED — the trader's wallet address "agentAddress": "0x...", // Alternative to userAddress "count": 50 // Optional — max results (default: 50) } </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "venue": "AVANTIS", "source": "avantis_api_v2_history", "history": [ { "id": "69a6e3b7...", "tradeId": "1:0", "market": "BTC/USD", "pairIndex": 1, "tradeIndex": 0, "side": "long", "collateralUsdc": 9.955, "positionSizeUsdc": 1772.544045, "leverage": 10.0, "entryPrice": 67120.23805881, "closePrice": 67014.2049318, "usdcSentToTrader": 9.765164, "closedAt": "2026-03-03T13:35:51.000Z", "timestamp": 1709000000, "grossPnlUsdc": -0.144682 } ], "count": 4 } </code></pre> <h3>Avantis Parameter Dependency Graph</h3> <table><thead><tr><th>Parameter</th><th>Source</th><th>How to Get</th></tr></thead><tbody><tr><td><code>userAddress</code></td><td><code>/user-details</code> → <code>user_wallet</code></td><td><code>GET /user-details</code></td></tr><tr><td><code>agentAddress</code></td><td><code>/user-details</code> → <code>ostium_agent_address</code></td><td><code>GET /user-details</code></td></tr><tr><td><code>avantis_enabled</code></td><td><code>/user-details</code> → <code>deployment.enabled_venues</code> includes <code>AVANTIS</code></td><td><code>GET /user-details</code></td></tr><tr><td><code>market</code></td><td>User specifies token</td><td>User input (e.g. <code>BTC</code>, <code>ETH</code>)</td></tr><tr><td><code>side</code></td><td>User specifies <code>"long"</code> or <code>"short"</code></td><td>User input (required)</td></tr><tr><td><code>collateral</code></td><td>User specifies USDC amount (must satisfy venue minimums)</td><td>User input (required)</td></tr><tr><td><code>leverage</code></td><td>User specifies</td><td>User input</td></tr><tr><td><code>tradeId</code></td><td><code>/avantis/positions</code> → <code>tradeId</code> (<code><pairIndex>:<tradeIndex></code>)</td><td>Preferred unique open-trade key</td></tr><tr><td><code>tradeIndex</code></td><td><code>/avantis/positions</code> → <code>tradeIndex</code></td><td>From position data</td></tr></tbody></table> <h3>Avantis Workflow: Open Position on Base Chain</h3> <pre><code>Step 1: GET /user-details → Extract: user_wallet, ostium_agent_address (shared agent wallet) → Check: deployment.enabled_venues includes AVANTIS (if not, tell user to enable Avantis at maxxit.ai/openclaw) Step 2: GET /avantis/symbols → Verify the token is available on Avantis Step 3: ASK the user for ALL trade parameters → "Which token?" (e.g. BTC, ETH) → "Long or short?" → "How much USDC collateral?" → "Leverage? (e.g. 10x)" → "Would you like to set TP/SL? If so, what percentages?" Step 4: POST /avantis/open-position → Use agentAddress and userAddress from Step 1 → Use market, side, collateral, leverage from Step 3 → SAVE: tradeIndex and entryPrice from response </code></pre> <h3>Avantis Workflow: Close Position</h3> <pre><code>Step 1: GET /user-details → Extract user_wallet, ostium_agent_address (shared agent wallet) Step 2: POST /avantis/positions (userAddress + agentAddress) → Show positions to user, let them pick which to close → Extract tradeIndex Step 3: POST /avantis/close-position → Pass agentAddress, userAddress, market → Optionally pass actualTradeIndex </code></pre> <hr/> <h2>Zerodha (Indian Stocks) Endpoints</h2> <blockquote> <p>Zerodha is an Indian stock broker supporting equities on NSE and BSE. Use Zerodha endpoints when the user wants to trade Indian stocks, mentions NSE/BSE, or says "Indian stocks", "equities", or "Zerodha".</p> </blockquote> <h3>When to Use Zerodha</h3> <ul> <li>User wants to trade Indian stocks on NSE or BSE</li> <li>User mentions "Indian stocks", "equities", "NSE", "BSE", "Zerodha", or "Kite"</li> <li>User asks about their Zerodha portfolio, holdings, or positions</li> <li>User wants to place, modify, or cancel orders on Indian exchanges</li> <li>User wants to fetch instrument lists or market data for Indian equities</li> </ul> <h3>Currency Convention</h3> <ul> <li>In Indian-market conversations, present prices, holdings, portfolio values, targets, and stop losses in <strong>₹</strong></li> <li>Prefer <code>₹</code> in normal user-facing replies</li> <li>Do not default to USD when the context is Zerodha, NSE, BSE, or Indian equities</li> </ul> <h3>TP/SL and GTT Guidance</h3> <ul> <li>When the user wants to set a take profit or stop loss for a Zerodha position, confirm whether they want to place a <strong>GTT</strong> order.</li> <li>Explain GTT briefly when needed: <strong>GTT (Good Till Triggered)</strong> is a Zerodha trigger order that stays active until the trigger condition is hit or the user cancels it, and it is commonly used to automate target and stop-loss execution for cash-market positions.</li> <li>If the user explicitly asks for GTT, use the Zerodha GTT flow directly.</li> <li>If the user asks for TP/SL but does not mention GTT, ask first instead of assuming they want a regular order or a GTT trigger.</li> </ul> <h3>Venue Routing</h3> <table><thead><tr><th>Keywords</th><th>Route</th></tr></thead><tbody><tr><td>"Indian stocks", "NSE", "BSE", "equities", "Zerodha", "Kite"</td><td>Zerodha endpoints</td></tr></tbody></table> <h3>Environment Variables</h3> <table><thead><tr><th>Variable</th><th>Description</th><th>Source</th></tr></thead><tbody><tr><td><code>KITE_API_KEY</code></td><td>Zerodha Kite Connect API key</td><td>SSM (set in OpenClaw UI)</td></tr><tr><td><code>KITE_API_SECRET</code></td><td>Zerodha Kite Connect API secret</td><td>SSM (set in OpenClaw UI)</td></tr><tr><td><code>KITE_ACCESS_TOKEN</code></td><td>Short-lived access token (expires daily)</td><td>SSM (auto-stored after OAuth)</td></tr><tr><td><code>KITE_USER_NAME</code></td><td>Zerodha display name for status/UI</td><td>SSM (auto-stored after OAuth)</td></tr></tbody></table> <h3>Auth Pre-Flight</h3> <p>Before any Zerodha trading call, check session validity:</p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/session" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" </code></pre> <p>If <code>authenticated: false</code> or <code>expired: true</code>, tell the user:</p> <blockquote> <p>"Your Zerodha session has expired. Please re-authenticate on the OpenClaw page at maxxit.ai/openclaw."</p> </blockquote> <p><strong>Important</strong>: All Zerodha requests must include:</p> <ul> <li><code>X-API-KEY</code> header (normal Maxxit auth)</li> <li><code>X-KITE-API-KEY</code> header</li> <li><code>X-KITE-ACCESS-TOKEN</code> header</li> <li>For wallet identity, call <code>/user-details</code> first and use <code>user_wallet</code>. Zerodha does <strong>not</strong> require <code>ostium_agent_address</code> or <code>lazy_trading_ready: true</code>.</li> </ul> <h3>Zerodha Endpoints</h3> <p>All base path: <code>${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/</code></p> <h4>GET /zerodha/login</h4> <p>Generate a Zerodha login URL for the user.</p> <p>Important:</p> <ul> <li>Do not tell the user to open a bare Kite URL like <code>https://kite.zerodha.com/connect/login?api_key=...&v=3</code>.</li> <li>The login flow must preserve the Maxxit user context so the callback can store the Zerodha session against the correct wallet.</li> <li>When the user asks for the login link, give them the <code>login_url</code> exactly as returned by the Maxxit API. That URL may use the Kite domain, but it must include the Maxxit user handoff in <code>redirect_params</code>.</li> <li>Preferred flow:<!-- --> <ol> <li>Call <code>GET /user-details</code> to resolve <code>user_wallet</code>.</li> <li>Call <code>GET /zerodha/login</code> with <code>X-API-KEY</code>.</li> <li>Send the returned <code>login_url</code> to the user.</li> </ol> </li> <li>Do <strong>not</strong> manually construct a <code>?userWallet=<wallet>&redirect=1</code> URL in the normal skill flow.</li> <li>If you present the returned <code>login_url</code>, only use it if it includes the user handoff, e.g. <code>redirect_params=userWallet%3D...</code>.</li> </ul> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/login" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" </code></pre> <p><strong>Response:</strong></p> <pre><code class="language-json">{ "success": true, "login_url": "https://kite.zerodha.com/connect/login?api_key=5wh5hi6ky7y8s6g4&v=3&redirect_params=userWallet%3D0x796a837c78326ba693847deebd7811d6b6854c56", "message": "Open the login_url in your browser to authenticate with Zerodha." } </code></pre> <h4>GET /zerodha/session</h4> <p>Check Zerodha session status. Returns <code>authenticated: true</code> if session is valid.</p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/session" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" </code></pre> <h4>DELETE /zerodha/session</h4> <p>Invalidate Zerodha session and remove token from SSM.</p> <h4>GET /zerodha/portfolio</h4> <p>Fetch portfolio data. Use <code>?type=profile|holdings|positions|margins</code> to select specific data. Default fetches all.</p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/portfolio" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" </code></pre> <p>With filter:</p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/portfolio?type=holdings" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" </code></pre> <h4>GET /zerodha/orders</h4> <p>List all orders. Use <code>?orderId=<id></code> for specific order history.</p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/orders" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" </code></pre> <h4>POST /zerodha/orders</h4> <p>Place a new order.</p> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/orders" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" \ -H 'Content-Type: application/json' \ -d '{ "variety": "regular", "exchange": "NSE", "tradingsymbol": "RELIANCE", "transaction_type": "BUY", "quantity": 1, "product": "CNC", "order_type": "MARKET" }' </code></pre> <p><strong>Required fields:</strong> <code>exchange</code>, <code>tradingsymbol</code>, <code>transaction_type</code>, <code>quantity</code>, <code>product</code>, <code>order_type</code></p> <p><strong>Common values:</strong></p> <table><thead><tr><th>Field</th><th>Values</th></tr></thead><tbody><tr><td><code>variety</code></td><td><code>regular</code>, <code>amo</code>, <code>co</code>, <code>iceberg</code>, <code>auction</code></td></tr><tr><td><code>exchange</code></td><td><code>NSE</code>, <code>BSE</code>, <code>NFO</code>, <code>BFO</code>, <code>CDS</code>, <code>MCX</code></td></tr><tr><td><code>transaction_type</code></td><td><code>BUY</code>, <code>SELL</code></td></tr><tr><td><code>product</code></td><td><code>CNC</code>, <code>NRML</code>, <code>MIS</code>, <code>MTF</code></td></tr><tr><td><code>order_type</code></td><td><code>MARKET</code>, <code>LIMIT</code>, <code>SL</code>, <code>SL-M</code></td></tr><tr><td><code>validity</code></td><td><code>DAY</code>, <code>IOC</code>, <code>TTL</code></td></tr></tbody></table> <p><strong>How to explain Zerodha order fields to a normal trader:</strong></p> <table><thead><tr><th>Field</th><th>Value</th><th>Meaning for a trader</th></tr></thead><tbody><tr><td><code>variety</code></td><td><code>regular</code></td><td>Standard exchange order placed during market hours. Use this by default unless the user asks for something more specific.</td></tr><tr><td><code>variety</code></td><td><code>amo</code></td><td>After Market Order. Place the order outside market hours so it gets queued for the next session.</td></tr><tr><td><code>variety</code></td><td><code>co</code></td><td>Cover Order. An intraday order paired with a compulsory stop loss. Use only if the user specifically wants a leveraged intraday order with a built-in risk stop.</td></tr><tr><td><code>variety</code></td><td><code>iceberg</code></td><td>Iceberg Order. Splits one large order into smaller legs so the full size is not sent at once. Useful for quantities above freeze limits or to reduce visible impact.</td></tr><tr><td><code>variety</code></td><td><code>auction</code></td><td>Auction Order. Used for exchange auction sessions, not for normal cash-market trading. Only use when the user explicitly wants auction participation.</td></tr><tr><td><code>order_type</code></td><td><code>MARKET</code></td><td>Buy or sell immediately at the best available price. Prioritizes execution over exact price.</td></tr><tr><td><code>order_type</code></td><td><code>LIMIT</code></td><td>Execute only at the specified price or better. Prioritizes price control over certainty of fill.</td></tr><tr><td><code>order_type</code></td><td><code>SL</code></td><td>Stop-loss limit order. Once the trigger is hit, Zerodha places a limit order. Gives price control, but the order may remain unfilled in fast moves.</td></tr><tr><td><code>order_type</code></td><td><code>SL-M</code></td><td>Stop-loss market order. Once the trigger is hit, Zerodha places a market order. Better for ensuring exit, but fill price can slip.</td></tr><tr><td><code>product</code></td><td><code>CNC</code></td><td>Cash and Carry. Standard delivery equity order for shares you want to hold, typically in NSE/BSE cash markets.</td></tr><tr><td><code>product</code></td><td><code>NRML</code></td><td>Normal order type commonly used for futures and options carry-forward positions, and other non-intraday derivatives exposure.</td></tr><tr><td><code>product</code></td><td><code>MIS</code></td><td>Margin Intraday Squareoff. Intraday-only product, typically for futures/options or same-day cash trading where the position is not meant to be carried overnight.</td></tr><tr><td><code>product</code></td><td><code>MTF</code></td><td>Margin Trading Facility. Broker-funded carry-forward equity position. Use only if the user explicitly asks for MTF and their account supports it.</td></tr><tr><td><code>validity</code></td><td><code>DAY</code></td><td>Order stays active for the current trading session unless filled or cancelled.</td></tr><tr><td><code>validity</code></td><td><code>IOC</code></td><td>Immediate or Cancel. Whatever can fill immediately will execute; the rest is cancelled right away.</td></tr><tr><td><code>validity</code></td><td><code>TTL</code></td><td>Time to Live. The order stays active only for the specified number of minutes, using <code>validity_ttl</code>.</td></tr><tr><td><code>market_protection</code></td><td><code>0</code></td><td>No market protection. Default behavior.</td></tr><tr><td><code>market_protection</code></td><td><code>0 - 100</code></td><td>Custom market-protection percentage for market and stop-market style execution. Helps cap how far execution can chase price. Example: <code>2</code> means 2%.</td></tr><tr><td><code>market_protection</code></td><td><code>-1</code></td><td>Automatic market protection chosen by the system based on Zerodha rules.</td></tr><tr><td><code>autoslice</code></td><td><code>true</code></td><td>Automatically split a large order into multiple slices when quantity is above freeze limits.</td></tr><tr><td><code>autoslice</code></td><td><code>false</code></td><td>Do not auto-slice. Default behavior.</td></tr></tbody></table> <p><strong>Extra order parameters supported by this route:</strong></p> <ul> <li><code>validity_ttl</code>: number of minutes when <code>validity</code> is <code>TTL</code></li> <li><code>iceberg_legs</code>: number of child legs for an iceberg order</li> <li><code>iceberg_quantity</code>: quantity per iceberg leg</li> <li><code>auction_number</code>: required when placing auction orders</li> <li><code>market_protection</code>: market protection setting for eligible orders</li> <li><code>autoslice</code>: whether Zerodha should automatically slice oversized orders</li> </ul> <p><strong>Agent guidance:</strong></p> <ul> <li>Default to <code>variety: regular</code>, <code>validity: DAY</code>, and either <code>MARKET</code> or <code>LIMIT</code> based on what the user asks.</li> <li>Do not choose <code>CO</code>, <code>iceberg</code>, <code>auction</code>, <code>MTF</code>, <code>TTL</code>, <code>market_protection</code>, or <code>autoslice</code> unless the user explicitly wants that behavior or it is clearly necessary for the order they described.</li> <li>If the user asks in plain English, translate the intent into these fields and explain the tradeoff briefly before placing the order.</li> </ul> <h4>PUT /zerodha/orders?orderId=<!-- --><id></h4> <p>Modify an existing order.</p> <pre><code class="language-bash">curl -L -X PUT "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/orders?orderId=ORD123" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" \ -H 'Content-Type: application/json' \ -d '{"variety": "regular", "price": 2500, "order_type": "LIMIT"}' </code></pre> <h4>DELETE /zerodha/orders?orderId=<!-- --><id></h4> <p>Cancel an order.</p> <pre><code class="language-bash">curl -L -X DELETE "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/orders?orderId=ORD123" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" \ -H 'Content-Type: application/json' \ -d '{"variety": "regular"}' </code></pre> <h4>GET /zerodha/gtt</h4> <p>List all GTT triggers. Use <code>?triggerId=<id></code> to fetch a specific trigger.</p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/gtt" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" </code></pre> <h4>POST /zerodha/gtt</h4> <p>Place a new GTT trigger.</p> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/gtt" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" \ -H 'Content-Type: application/json' \ -d '{ "trigger_type": "two-leg", "tradingsymbol": "SBIN", "exchange": "NSE", "trigger_values": [800, 840], "last_price": 835, "orders": [ { "transaction_type": "SELL", "quantity": 1, "product": "CNC", "order_type": "LIMIT", "price": 840 }, { "transaction_type": "SELL", "quantity": 1, "product": "CNC", "order_type": "LIMIT", "price": 800 } ] }' </code></pre> <p><strong>Required fields:</strong> <code>trigger_type</code>, <code>tradingsymbol</code>, <code>exchange</code>, <code>trigger_values</code>, <code>last_price</code>, <code>orders</code></p> <p><strong>Rules:</strong></p> <ul> <li><code>trigger_type: "single"</code> requires exactly 1 <code>trigger_values</code> item and 1 order</li> <li><code>trigger_type: "two-leg"</code> requires exactly 2 <code>trigger_values</code> items and 2 orders</li> </ul> <h4>PUT /zerodha/gtt?triggerId=<!-- --><id></h4> <p>Modify an existing GTT trigger.</p> <pre><code class="language-bash">curl -L -X PUT "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/gtt?triggerId=219118727" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" \ -H 'Content-Type: application/json' \ -d '{ "trigger_type": "two-leg", "tradingsymbol": "SBIN", "exchange": "NSE", "trigger_values": [800, 860], "last_price": 837, "orders": [ { "transaction_type": "SELL", "quantity": 1, "product": "CNC", "order_type": "LIMIT", "price": 860 }, { "transaction_type": "SELL", "quantity": 1, "product": "CNC", "order_type": "LIMIT", "price": 800 } ] }' </code></pre> <h4>DELETE /zerodha/gtt?triggerId=<!-- --><id></h4> <p>Delete an existing GTT trigger.</p> <pre><code class="language-bash">curl -L -X DELETE "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/gtt?triggerId=219118727" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" </code></pre> <h4>GET /zerodha/instruments</h4> <p>Fetch available instruments. Use <code>?exchange=NSE|BSE|NFO|BFO|CDS|MCX</code> to filter.</p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/zerodha/instruments?exchange=NSE" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-KITE-API-KEY: ${KITE_API_KEY}" \ -H "X-KITE-ACCESS-TOKEN: ${KITE_ACCESS_TOKEN}" </code></pre> <h3>Zerodha Workflow: Trading Indian Stocks</h3> <pre><code>Step 1: GET /zerodha/session → Check if authenticated. If not → tell user to re-auth on OpenClaw page. Step 2: GET /user-details → Extract: user_wallet → Ignore lazy_trading_ready / ostium_agent_address for Zerodha flows Step 3: GET /zerodha/instruments?exchange=NSE → Verify the symbol exists on the exchange. Step 4: GET /zerodha/portfolio?type=holdings → Show current holdings and positions to user. Step 5: ASK user for trade parameters → Exchange (NSE/BSE), symbol, BUY/SELL, quantity, product (CNC/MIS), order type Step 6: POST /zerodha/orders → Place the order with confirmed parameters. Step 7: GET /zerodha/orders?orderId=<id> → Verify order status. </code></pre> <h3>Zerodha Error Handling</h3> <table><thead><tr><th>Status</th><th>Meaning</th></tr></thead><tbody><tr><td>401</td><td>Session expired. Tell user to re-authenticate.</td></tr><tr><td>400</td><td>Missing or invalid parameters.</td></tr><tr><td>405</td><td>Wrong HTTP method.</td></tr><tr><td>500</td><td>Internal error or Zerodha API failure.</td></tr></tbody></table> <hr/> <p>Trustless ZK-verified trading signals. <strong>Producers</strong> generate proofs and flag positions as alpha; <strong>consumers</strong> discover agents by commitment, purchase alpha via x402, verify content, and execute.</p> <p><strong>Base path:</strong> <code>${MAXXIT_API_URL}/api/lazy-trading/programmatic/alpha/*</code><br/> <strong>Auth:</strong> <code>X-API-KEY</code> header (same as other endpoints).<br/> <strong>Payment:</strong> On-chain USDC on Arbitrum Sepolia (testnet) or Arbitrum One (mainnet).</p> <p><strong>Prerequisites for consuming alpha:</strong></p> <ul> <li>User must have completed Lazy Trading setup (agent deployed) — <code>/user-details</code> must return <code>ostium_agent_address</code>. The <code>/pay</code> endpoint uses this agent to send USDC; without it, <code>/pay</code> returns 400.</li> <li>Agent wallet must hold enough USDC for the listing price. If insufficient, <code>/pay</code> returns 402 with <code>required</code> and <code>available</code> amounts — inform the user to fund the agent address.</li> </ul> <h3>Alpha Endpoints Summary</h3> <table><thead><tr><th>Endpoint</th><th>Method</th><th>Purpose</th></tr></thead><tbody><tr><td><code>/alpha/agents</code></td><td>GET</td><td>Discover agents with verified metrics (commitment, winRate, totalPnl). Query: <code>minWinRate</code>, <code>minTrades</code>, <code>limit</code>.</td></tr><tr><td><code>/alpha/listings</code></td><td>GET</td><td>Browse active alpha listings (metadata + price, no trade content). Query: <code>commitment</code>, <code>maxPrice</code>, <code>limit</code>.</td></tr><tr><td><code>/alpha/purchase/:listingId</code></td><td>GET</td><td><strong>Phase 1</strong> (no <code>X-Payment</code> header): returns 402 + payment details. <strong>Phase 2</strong> (with <code>X-Payment: txHash</code>): verifies on-chain, returns alpha.</td></tr><tr><td><code>/alpha/pay/:listingId</code></td><td>POST</td><td><strong>Payment helper</strong>: sends USDC from your agent on-chain. Returns <code>txHash</code>. Call between Phase 1 and Phase 2.</td></tr><tr><td><code>/alpha/verify</code></td><td>POST</td><td>Body: <code>{ listingId, content }</code>. Verify purchased content hash matches commitment.</td></tr><tr><td><code>/alpha/execute</code></td><td>POST</td><td>Body: <code>{ alphaContent, agentAddress, userAddress, collateral, leverageOverride? }</code>. Execute alpha trade on the venue from <code>alphaContent.venue</code> (<code>OSTIUM</code> or <code>AVANTIS</code>).</td></tr><tr><td><code>/alpha/generate-proof</code></td><td>POST</td><td>(Producer) Generate ZK proof of trading performance. Body: `{ venue?: "OSTIUM"</td></tr><tr><td><code>/alpha/proof-status</code></td><td>GET</td><td>(Producer) Check proof processing status. Query: <code>proofId</code>.</td></tr><tr><td><code>/alpha/my-proof</code></td><td>GET</td><td>(Producer) Latest proof status and metrics.</td></tr><tr><td><code>/alpha/flag</code></td><td>POST</td><td>(Producer) Body: <code>{ proofId, priceUsdc, token, side, leverage? }</code>. List verified trade as alpha using the proof ID from generate-proof.</td></tr></tbody></table> <p><strong>Venue/trade reference notes:</strong></p> <ul> <li><code>tradeId</code> for <code>venue: "OSTIUM"</code> should be the trade index (example: <code>"123"</code>).</li> <li>For <code>venue: "AVANTIS"</code>, use tradeId from <code>/avantis/positions</code>: <code>"<pairIndex>:<tradeIndex>"</code> (example: <code>"1:0"</code>).</li> <li>Internally, proofs/listings are stored as a prefixed trade reference: <code><VENUE>:<ID></code> (for example, <code>OSTIUM:123</code>, <code>AVANTIS:1:0</code>).</li> </ul> <h3>How x402 Purchase Works (3 API Calls)</h3> <blockquote> <p><strong>⚠️ CRITICAL</strong>: To purchase alpha content you MUST call these 3 endpoints in this exact order. Do NOT skip steps. The <code>/pay</code> endpoint handles all wallet operations server-side — you do NOT need a private key.</p> </blockquote> <pre><code>Step A: GET /alpha/purchase/{listingId} → 402 + paymentDetails Step B: POST /alpha/pay/{listingId} → { txHash } Step C: GET /alpha/purchase/{listingId} → 200 + alpha content + Header: X-Payment: {txHash from Step B} </code></pre> <p><strong>Step A — Get payment details:</strong></p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/alpha/purchase/{listingId}" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" </code></pre> <p>Response: <code>402</code> with <code>paymentDetails.price</code>, <code>paymentDetails.payTo</code>, <code>paymentDetails.network</code>.<br/> <!-- -->If response is <code>200</code>: you already own this listing — alpha is returned directly, skip to Step 4.</p> <p><strong>Step B — Send USDC (server handles everything):</strong></p> <pre><code class="language-bash">curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/alpha/pay/{listingId}" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" </code></pre> <p>Response: <code>200</code> with <code>txHash</code>, <code>from</code>, <code>to</code>, <code>amount</code>.<br/> <!-- -->If <code>alreadyPaid: true</code>: use the returned <code>txHash</code> directly.<br/> <!-- -->If <code>402</code>: insufficient USDC balance — response has <code>required</code> and <code>available</code> amounts.</p> <p><strong>Step C — Retrieve alpha content:</strong></p> <pre><code class="language-bash">curl -L -X GET "${MAXXIT_API_URL}/api/lazy-trading/programmatic/alpha/purchase/{listingId}" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "X-Payment: {txHash from Step B}" </code></pre> <p>Response: <code>200</code> with <code>alpha</code> object (token, side, leverage, venue, entryPrice), <code>contentHash</code>, <code>payment</code> receipt.</p> <p><strong>SAVE from Step C:</strong> <code>alpha</code>, <code>contentHash</code>, <code>listingId</code> — needed for <code>/verify</code> and <code>/execute</code>.</p> <p><strong>Pass <code>content</code> exactly as received:</strong> For <code>/alpha/verify</code>, the <code>content</code> field must be the exact <code>alpha</code> object from Step C. Do not modify keys, values, or key order — the hash is computed using sorted keys and any change will cause verification to fail.</p> <h3>Alpha Dependency Chain</h3> <pre><code>/alpha/agents → commitment /alpha/listings → listingId (needs commitment) /alpha/purchase → 402 paymentDetails (needs listingId) /alpha/pay → txHash (needs listingId) /alpha/purchase → alpha content (needs listingId + txHash in X-Payment header) /alpha/verify → verified (needs listingId + alpha content) /user-details → agentAddress, userAddress /alpha/execute → trade result (needs alpha + addresses + collateral) </code></pre> <h3>Workflow: Consuming Alpha (Complete Flow)</h3> <pre><code>Step 1: GET /alpha/agents → Pick an agent by commitment, winRate, totalPnl → SAVE: commitment Step 2: GET /alpha/listings?commitment={commitment} → Browse listings, pick one → SAVE: listingId Step 3a: GET /alpha/purchase/{listingId} → If 200: already purchased, skip to Step 4 → If 402: need to pay → go to Step 3b Step 3b: POST /alpha/pay/{listingId} → Server sends USDC from your agent to the producer → If 402: insufficient USDC balance → fund your agent wallet and retry → If alreadyPaid: use the returned txHash → SAVE: txHash Step 3c: GET /alpha/purchase/{listingId} → Header: X-Payment: {txHash from Step 3b} → SAVE: alpha, contentHash, listingId Step 4: POST /alpha/verify → Body: { "listingId": "...", "content": { ...alpha from Step 3c } } → Check: verified === true Step 5: GET /user-details → Extract: user_wallet → userAddress → Extract: ostium_agent_address → agentAddress Step 6: POST /alpha/execute → Body: { "alphaContent": { ...alpha }, "agentAddress": "...", "userAddress": "...", "collateral": 100 } → alphaContent must include at least token and side (from alpha) → agentAddress = ostium_agent_address, userAddress = user_wallet (both from /user-details) → collateral: ask user or use default (e.g. 100 USDC) → Check: success === true </code></pre> <h3>Workflow: Producing Alpha</h3> <blockquote> <p><strong>⚠️ This is the standalone producer workflow.</strong> If the user just opened a position via Workflow 1, Steps 7-10 already handle alpha listing — you don't need to repeat this. Use this workflow only when the user wants to list an existing open position.</p> </blockquote> <pre><code>Step 1: POST /positions (address = user_wallet from /user-details) → List open positions → Let user pick which trade to feature → SAVE: tradeId, market (token), side, leverage from the chosen position Step 2: POST /alpha/generate-proof → Body: { "venue": "OSTIUM", "tradeId": "{tradeId from Step 1}", "autoProcess": true } → SAVE: proofId from response → If status is already VERIFIED → go to Step 4 Step 3: Poll GET /alpha/proof-status?proofId={proofId} → Wait until status === "VERIFIED" → Poll every 10 seconds (max ~5 min) → If FAILED → inform user and stop Step 4: ASK user for price → "What USDC price would you like to charge for this alpha?" Step 5: POST /alpha/flag → Body: { "proofId": "{proofId from Step 2}", "priceUsdc": {price from Step 4}, "token": "{market from Step 1}", "side": "{side from Step 1}", "leverage": {leverage from Step 1} } → Show user: listingId, proofMetrics (tradeCount, winRate, totalPnl) → "Your trade is listed as alpha! Listing ID: {listingId}" </code></pre> <p><strong>Example curl commands:</strong></p> <pre><code class="language-bash"># Generate proof with specific tradeId curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/alpha/generate-proof" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{"venue":"OSTIUM","tradeId":"1612509","autoProcess":false}' # Check proof status curl -G "${MAXXIT_API_URL}/api/lazy-trading/programmatic/alpha/proof-status" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ --data-urlencode "proofId=<proof_id>" # Flag as alpha using proofId curl -L -X POST "${MAXXIT_API_URL}/api/lazy-trading/programmatic/alpha/flag" \ -H "X-API-KEY: ${MAXXIT_API_KEY}" \ -H "Content-Type: application/json" \ -d '{"proofId": "<proof_id>", "priceUsdc": 5, "token": "ETH", "side": "long", "leverage": 6}' </code></pre> <hr/> <h2>Environment Variables</h2> <table><thead><tr><th>Variable</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>MAXXIT_API_KEY</code></td><td>Your lazy trading API key (starts with <code>lt_</code>)</td><td><code>lt_abc123...</code></td></tr><tr><td><code>MAXXIT_API_URL</code></td><td>Maxxit API base URL</td><td><code>https://maxxit.ai</code></td></tr></tbody></table> <h2>Error Handling</h2> <table><thead><tr><th>Status Code</th><th>Meaning</th></tr></thead><tbody><tr><td>401</td><td>Invalid or missing API key</td></tr><tr><td>404</td><td>Resource not found for the specific endpoint (not returned by <code>/user-details</code> just because an agent is missing)</td></tr><tr><td>400</td><td>Missing or invalid message / parameters</td></tr><tr><td>405</td><td>Wrong HTTP method</td></tr><tr><td>500</td><td>Server error</td></tr></tbody></table> <p><strong>Alpha-specific errors:</strong> | 400 | <code>/pay</code>: No agent address found (user must complete Lazy Trading setup). <code>/purchase</code>: Invalid X-Payment header or payment verification failed. | | 402 | Payment required (<code>/purchase</code> Phase 1) or insufficient USDC balance (<code>/pay</code> — check <code>required</code> and <code>available</code> in response). | | 409 | Transaction hash already used (replay protection — each tx can only purchase one listing). | | 410 | Alpha listing no longer active. |</p> <h2>Getting Started</h2> <ol> <li><strong>Set up Lazy Trading</strong>: Visit <a href="https://maxxit.ai/lazy-trading">https://maxxit.ai/lazy-trading</a> to connect your wallet and configure your agent</li> <li><strong>Generate API Key</strong>: Go to your dashboard and create an API key</li> <li><strong>Configure Environment</strong>: Set <code>MAXXIT_API_KEY</code> and <code>MAXXIT_API_URL</code></li> <li><strong>Start Trading</strong>: Use this skill to send signals!</li> </ol> <h2>Security Notes</h2> <ul> <li>Never share your API key</li> <li>API keys can be revoked and regenerated from the dashboard</li> <li>All trades execute on-chain with your delegated wallet permissions</li> </ul>
No automatic installation available. Please visit the source repository for installation instructions.
View Installation Instructions1,500+ AI skills, agents & workflows. Install in 30 seconds. Part of the Torly.ai family.
© 2026 Torly.ai. All rights reserved.