AI Automation · Claude Agent SDK

Running a Trading Bot on Cron With the Claude Agent SDK
How subscriptions bill, and who pays when the run crashes

2026-08-13·12 min read

You saw someone on X stuffing a Claude Code subscription into GitHub Actions, running an hourly cron to read on-chain whale trades and firing webhooks off to an exchange for order placement — in other words, letting an AI turn "you should buy" into a POST request aimed at an execution service. It looks like $20 a month buys you a 24/7 quant researcher. What nobody told you first: Anthropic's "SDK-only credit" plan was scheduled to take effect on June 15, and it was paused the same day.

This post doesn't compare which AI writes code better, and it doesn't judge your strategy. It gives you three things: how the SDK is billed, what your cron should actually run, and why the split of "Claude decides, webhook carries the signal, TVSBot places the order" is safer than letting Claude hold the API key directly. The API key is the thing that can actually move real money on your exchange — leaving that in an LLM's hands, on a cron that crashes easily, is the problem this post is trying to solve.

The short version:
You may have heard about a "$20 SDK-only credit" — it never actually launched. Running the Agent SDK on your subscription draws from the subscription's own 5-hour rolling window; if you want stable cron runs or plan to wrap this into a product for other people, Anthropic explicitly asks you to switch to an API key. Tokens burned before a crash are still billed — the official cost tracking docs spell it out.

That "Agent SDK-only Credit" You Heard About — Paused on the Day It Was Supposed to Ship

Anthropic's support article, as of 2026-08-13, now carries an update pinned to the top. Verbatim:

Official wording (Anthropic support article, June 16, 2026)
"Update June 15: We're pausing the changes to Claude Agent SDK usage described below. For now, nothing has changed: Claude Agent SDK, claude -p, and third-party app usage still draw from your subscription's usage limits. The previously announced monthly credit, which would have been available to eligible claimants in connection with these changes, isn't available."

In plain terms: the "SDK-only credit" that was supposed to arrive on 6/15 — the separate pool that would have carved SDK usage out of your subscription window — is gone. Right now claude, claude -p, and any Python or TypeScript script you wrote with the Agent SDK all draw from the same 5-hour window. Once you burn through it, you wait for the next window. There is no second pool giving you extra life.

$0
Agent SDK-only credit (paused on the day it was supposed to launch)
5 hours
Rolling window subscribers actually share
$20 / $100 / $200
Pro / Max 5x / Max 20x monthly price (unchanged)

If you see something online along the lines of "$20 Pro subscription comes with $20 of SDK credit," that's almost certainly the pre-6/15 version — the author didn't come back to check the follow-up. The numbers listed in the doc before it was paused are still visible on the page, but they aren't in effect. The tail of the support article reads "We're working to update the plan to better support how users build with Claude subscriptions" — no new timeline, no new details. In practice, treat it as if it doesn't exist.

You Can Run the SDK on a Subscription — But That Path Has Two Limits

A subscription can still run the Agent SDK; Anthropic explicitly allows personal use. But two limits are worth pinning down before you commit:

ScenarioOfficial stanceWhat actually bites
Personal use — a single bot running a few strategies for yourselfOK on a subscription, draws from the 5-hour windowA few dense Sonnet 5 loops and you hit the rate limit; whatever else you had running in Cursor in the same window suffers too
Wrapped as a product for other people (placing orders for them, taking subscriptions)Not allowed via a subscription — you have to use an API keyIf caught, you can be suspended, and previously accumulated usage is frozen along with it
Cron running every 5 minutes as a background automationTechnically possible, not forbidden by AnthropicOne bot can eat the whole window; you get nothing left in your IDE

Sources: Anthropic Agent SDK Overview and Quickstart pages (verified August 2026). The wording behind "not allowed" is: Unless previously approved, Anthropic does not allow third party developers to offer claude.ai login or rate limits for their products.

The Overview page is unambiguous: "Unless previously approved, Anthropic does not allow third party developers to offer claude.ai login or rate limits for their products, including agents built on the Claude Agent SDK. Use the API key authentication methods described in the Quickstart instead."

If you're packaging this as a service for others, you use an API key — pay per token you use. The Quickstart page lists five providers — Anthropic Console direct, Amazon Bedrock (env var CLAUDE_CODE_USE_BEDROCK=1), Claude Platform on AWS (CLAUDE_CODE_USE_ANTHROPIC_AWS=1), Google Vertex (CLAUDE_CODE_USE_VERTEX=1), and Microsoft Foundry (CLAUDE_CODE_USE_FOUNDRY=1). None of them is a claude.ai OAuth path.

API Key Pricing: What a Cron Job Roughly Burns Per Day

Running via API key means paying by token. Input tokens are what you send the model (system prompt, conversation history, tool results); output tokens are what the model returns. The two have different rates. Verbatim from the official pricing page as of 2026-08-13:

ModelInput (per 1M tokens)Output (per 1M tokens)
Haiku 4.5$1$5
Sonnet 5$2$10
Opus 5$5$25
Fable 5 (multimodal flagship)$10$50

Source: claude.com/pricing (verified August 2026). Actual bills factor in prompt caching discounts and batch API discounts on top.

A single agent that "runs once an hour, reads on-chain whale trades, produces a signal, decides whether to fire an order" on Sonnet 5 works out roughly like this. These are my numbers, not Anthropic's:

8k / 2k
Input / output tokens per run (including 3 tool call round-trips)
$0.036
Per-run cost estimate (Sonnet 5: 8k×$2 + 2k×$10 per million)
$26 / month
Hourly cron × 24 × 30 days estimate

This number shifts with system prompt length, tool call count, and how deep the agent thinks. For a real invoice, go to "platform.claude.com/usage" — the SDK's own reported total_cost_usd is a local estimate that can drift from the actual bill (official wording: "client-side estimates, not authoritative billing data"). The order of magnitude here tells you something: if that $20 Pro subscription had been carved into an SDK-only credit, one hourly bot would've eaten it whole — start another quant researcher in the same window and you're out immediately. Paying per token via API key gives you the predictability the subscription window doesn't.

Tokens Burned Before a Crash Are Still Billed

This is the easiest cost to underestimate. Anthropic's Cost Tracking page has a "Track costs on failed conversations" section that spells it out:

Official wording (Cost Tracking, verified August 2026)
"Both success and error result messages include usage and total_cost_usd. If a conversation fails midway, you still consumed tokens up to the point of failure. Read cost data from every result message, whether its subtype is success or one of the error subtypes."

Meaning: the agent gets to its 8th tool call, the exchange returns 429 (rate limit), and it dies. The input and output tokens for the previous 7 tool calls are all on you.

There's a nastier version: process crash. The same document notes separately that when the claude subprocess crashes, the final error_during_execution result message may return usage, total_cost_usd, and modelUsage all zeroed out — the wording is "every cost field may be zeroed". But that's only the SDK-side report being broken; Anthropic's billing on the other end still deducts.

Don't trust the SDK's self-reported cost
The total_cost_usd the SDK hands you is calculated locally from the pricing table baked in at build time — it can drift from the Anthropic bill. When you need to reconcile, go to platform.claude.com/usage — that's the authoritative invoice.

Cron Runs the "Decision," Not the "Order" — Why the Two Layers Should Be Split

This is the easiest part of the design to get wrong. When you see the learnwithmeai Hyperliquid copy-trading bot stuffing the whole flow into Claude Code + GitHub Actions, it's natural to want to copy it. But that bot is paper trading — $10,000 in virtual capital on a ledger; when it's wrong the ledger is wrong, and nothing actually gets liquidated. For real money, the two layers have to be split.

DesignClaude does everything (fetches data, decides, places orders)Split into two layers (Claude only sends signals to an execution service)
Who holds your exchange API keyClaude Agent runtimeThe execution service (e.g. something like TVSBot)
Claude hallucinates or the output format driftsMay place the wrong order directlyWebhook payload fails schema check, execution service rejects the order
Rate limit or crashOrder half-sent, state unknownSignal that reached the execution service queues up and can be re-sent idempotently
Fan out to multiple machines and multiple API keysYou write it inside the agent yourselfThe execution service is designed for many-to-many from day one
Testing a new strategySpin up a fresh agent and new keyThe execution service flips the strategy into dry-run mode

For example, TVSBot's execution service does four things before placing an order after a webhook lands. First, verify the webhook_token in the URL (a random token issued per strategy). Second, verify the secret inside the payload, compared with hmac.compare_digest for constant-time comparison. Third, run rate limits (60 per token per minute). Fourth, drop any signal with the same dedup_hash arriving within 60 seconds. You could rewrite all four inside a Claude Agent yourself, but writing them correctly is hard — the idempotency and dedup boundary cases in particular.

How Often Should Your Cron Fire? Back-Solve From Model Call Latency

What actually decides your cadence isn't "how often you want to check" — it's the round-trip latency of the model call, meaning the time from the agent asking a question to receiving the full response. A single Sonnet 5 call carrying 8k input / 2k output plus 3 tool call round-trips lands somewhere in 15–45 seconds in practice, moved by prompt caching hit rate and output token length.

1
How fast does your strategy need to react?
Second-level (market making, sniping)Agent SDK is completely unfit — go back to a rule-based execution service and only use Claude for offline post-mortem
Minute-level (trend breakouts, funding-rate arbitrage)You can put it on cron every 5–15 minutes, paired with idempotent signals
Hour or day-level (on-chain whale copy trading, macro rotation)Cron once an hour to once a day; switch models up to Opus 5 for sharper judgment
2
Should a human eyeball the signal before it goes out?
Yes (semi-automated)Claude writes the signal to Slack or Telegram, and it only fires the webhook after you press a button
No (fully automated)Claude fires straight to the execution service — turn on dry-run mode for the first week and reconcile from the log

Second-level strategies do not touch the Agent SDK. It's not that it can't — it's that doing so is expensive, because every call is a full LLM inference and what you actually need is sub-100ms reaction. That's the domain of a rule-based execution service. The model helps you think through the rules offline. That's where it earns its keep.

Anthropic's Own Advice for "Long-Running" Points at a Different Product

The decision table on Anthropic's Agent SDK Overview page actively pushes the "long-running or asynchronous agents" use case at a different product:

Official wording (Agent SDK Overview, verified August 2026)
"Running long-running or asynchronous agents without managing your own sandbox or session infrastructure → Managed Agents → Hosted REST API, a separate product from the Agent SDK. Anthropic runs the agent and the sandbox."

Managed Agents is currently priced at $0.08 per session-hour active runtime, with tokens billed separately (same pricing page). Anthropic doesn't say the Agent SDK can't run on cron — the Hosting the Agent SDK doc has an explicit "Long-running sessions" section, which is exactly about putting the SDK inside a container for long runs, and even provides a SessionStore so you can persist session files to S3, Redis, or Postgres. It's technically supported, but you carry the infra yourself. If you don't want to manage that, Managed Agents is the official answer, at the cost of $0.08 per hour plus tokens.

If You Insist on Letting Claude Place Orders Directly, Watch These Traps First

  • Session storage has to use a durable adapter. The SDK stores sessions to local disk by default; restart the container and they're gone. Anthropic ships S3, Redis, and Postgres as reference implementations — pick one and wire it in.
  • Don't fire and forget. For anything as consequential as placing an order, you have to confirm usage.output_tokens is present in the result message before continuing — during a crash that field can be 0, and you also don't know if the order went out or not.
  • Bring your own idempotency key. Rerunning the agent with the same prompt doesn't produce an identical sequence of tool calls, so you have to compute a hash yourself (signal timestamp + strategy id + symbol) as the dedup key so the execution service can reject duplicates.
  • The kill switch lives on the execution side, not on Claude's side. You have to be able to stop all orders with a single button, and that button cannot depend on Claude checking anything — it could be rate-limited, mid-crash, or hallucinating a very persuasive reason to keep running.
  • Rate limit errors are retryable; schema errors are terminal. HTTP 429 gets retried after 5–60 seconds; tool_use failures fail outright, because they're usually a schema mismatch and retrying won't change that.

The Honest Section: We Don't Cover the Claude-Side Bill

This post walks through SDK cost, rate limits, and crash billing as if TVSBot's execution service could absorb them for you — it can't. What we cover is the segment after the webhook lands. Your Claude Agent crashing, your API key getting rate-limited, your subscription burning through its 5-hour window — those all happen before you fire the webhook. The execution service never received the signal, so there's nothing to report back to you.

We also don't publish any SLA around Agent SDK cost — every estimate above is mine, computed against the current official pricing page, and Anthropic can change it any time. TVSBot, as of August 2026, supports the order-placement APIs for Binance, OKX, Bitget, Bybit, Gate.io, BingX, and Hyperliquid — seven venues total — non-custodial (you bring your own API key, stored Fernet-encrypted), with strategy-level dry-run and kill-switch controls. But Anthropic's bill is on you to watch; we don't collect it on your behalf, and we don't pay it for you.

Common Questions

I've seen people running Claude Code 24/7 for free on GitHub Actions — can I do that too?
You can, with two caveats.First, GitHub Actions silently skips high-frequency cron jobs — the learnwithmeai author himself concedes free scheduler is unreliable, silently skips around 80% of frequent jobs, and later wired in cron-job.org as an external trigger.Second, the subscription draws from a 5-hour window, so one bot will eat the same budget your own IDE is trying to use in that same window. If you want stability, move to an API key.
Is the official "$20 SDK-only credit" ever coming back?
Unknown. The support article says only We're working to update the plan to better support how users build with Claude subscriptions— no timeline, no details of the new plan. Treat it as if it doesn't exist; if you have to plan a budget, go API key.
How dangerous is it to let Claude hold my exchange API key directly?
Two layers.Technical: LLM output format drifts occasionally — you thought it would call place_order(symbol, side, qty), and it might hand you "action: buy, amount: small" instead. How does your tool interpret "small"?Compliance: subscription-side use of the SDK for "financial decisions" carries additional terms by default, and if something goes wrong the responsibility split gets messy. When you split the two layers, Claude just writes "buy this / sell this" into a payload humans can read, and the execution service enforces a schema — it rejects malformed orders rather than placing bad ones.
How fast does TVSBot place orders after receiving a webhook?
TVSBot is the execution layer for minute-to-day-level strategies —it's not what you use for sniping or market making— those need sub-100ms reaction and only a rule-based execution service can deliver that. As for the actual internal processing latency, I don't have a public number to quote right now; if you need one, timestamp it yourself in dry-run mode.
How exactly does Anthropic bill tokens burned before a crash?
By what was actually consumed up to the point of failure — the official cost tracking doc says so verbatim: you still consumed tokens up to the point of failure. When the process crashes, the SDK's local usage may be all zeros, but platform.claude.com/usage is the authoritative invoice — reconcile from there.

Get started

Ready to ship what you just learned?

Pipe signals Claude produces into TVSBot via webhook, and hand off the order-placement segment — non-custodial, use your own API key, seven exchanges supported, dry-run before you go live, account-level kill switch under your control.

Start free