Connect to a broker and place orders without accidentally trading live money. TRIGGER - connect to Interactive Brokers, TWS, IB Gateway, ib_async, ib_insync, ibapi, Alpaca, Schwab, schwab-py, Tastytrade, Tradier or Robinhood; place, modify or cancel an order; read positions or balances; set up paper trading; order types, time-in-force, bracket or OCO orders, client order ID; FIX, quickfix, simplefix; "make sure I don't send a live order"; a broker connection being refused. Load before any code that can transmit an order. SKIP for crypto exchanges and ccxt (crypto-data-and-execution), and for vnpy, CTP, QMT or any Chinese broker gateway (china-trading-stack). This skill answers TWS/Gateway port and connection failures on its own - the fin-libraries deep dive is optional and most installs will not have it.
Ships in fin-core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Order-sending code is the one place in quant work where a bug spends real money instantly. The patterns in §3 are not optional extras — emit them by default in any code that can transmit an order, regardless of broker.
| Broker | Use | Status |
|---|---|---|
| Interactive Brokers | ib_async 2.1.0 | ✅ the successor. ⚠️ main last commit 2025-12-06; real work sits unreleased on next |
| IB, vendor code | ibapi 10.x from IB's own site | PyPI's 9.81.1 (2020-12-06) is badly stale. IB non-commercial licence |
| IB, reconciliation | ibflex | Parses IB Flex XML activity/trade reports — end-of-day truth |
| Alpaca | alpaca-py 0.44.0 | ✅ active. alpaca-trade-api is deprecated |
| Schwab | schwab-py 1.5.1 | ⚠️ works, but main stalled ~13 months, 39 open issues. See the 7-day token limit below |
| Tastytrade | tastytrade 13.2.3 | ✅ active, small |
| Crypto, any venue | ccxt 4.5.77 | ✅ MIT, ~daily releases, 100+ venues |
| FIX, full session | quickfix | The reference open FIX engine. Heavyweight, C++ toolchain |
| FIX, messages only | simplefix | No session layer — correct only when the venue handles the session |
🚨 ib_insync is dead and archived (2024-03-14). The repo's archive notice is from the author's
family: Ewald de Wit died on 2024-03-11. Last release 2023-07-02. Do not start new work on it and
do not fork it. ib_async moved to the ib-api-reloaded org because the maintainers could not get
access to the original repo, PyPI project, or docs.
🚨 ib_fut does not exist — no PyPI package, no plausible repo. If a doc or model mentions it,
that is an error; the real adjacent tool is ibflex.
Recommend against: robin_stocks (reverse-engineered private endpoints, no paper trading,
MFA/device-token friction, 322 open issues, account lockouts are the reported failure mode), pyrh
(dead 2024-08), tda-api (dead — TDA absorbed into Schwab).
✅ CCXT Pro is free. It was merged into the MIT ccxt package at v1.95 (2022). WebSocket methods
(watchTicker, watchOrderBook, watchOrders…) are no longer a paid product. Any tutorial
telling you to buy ccxt.pro is out of date. Today: ccxt (sync REST), ccxt.async_support,
ccxt.pro (async + WS) — all one package.
Read-Only API is ON by default — "an additional precautionary measure"; while active,
API orders are prevented. IB is the one broker whose default is safe. Leave it on until the
strategy is proven; turning it off is a deployment step with its own checklist.ib_async does NOT wrap ibapi — it implements the IBKR binary protocol internally. Strength:
one dependency, async-native. Risk: it must track IB's protocol changes itself (note the
next-protobuf branch — IB is migrating to protobuf).🚨 What accidentally sends a live order at IB:
clientId that has resting orders from another process.placeOrder() with MKT outside RTH on an illiquid contract.gtc and ioc;
options/OTC only gtc/day; fractional orders only day; extended hours requires
limit + day/gtc. ioc/fok on whole shares is gated.client_order_id is caller-supplied — this is your idempotency primitive.alpaca-py's default is SAFE — verified in the 0.44.0 wheel:
TradingClient.__init__(..., paper: bool = True, ...), so omitting the flag gives you paper.
🚨 The legacy alpaca-trade-api is the dangerous one — verified in the 3.2.0 wheel:
get_base_url() returns https://api.alpaca.markets, the LIVE host, unless
APCA_API_BASE_URL is set. Old tutorials and old code default to production.
🚨 In alpaca-py, url_override bypasses the paper→URL mapping while still setting
sandbox=paper — so the flag and the host can disagree. Assert on the account, not the flag.🚨 The refresh token hard-expires after 7 days. Access tokens last 30 minutes and schwab-py
auto-refreshes them, but nothing can extend the refresh token — after ~7 days you must complete
an interactive browser login again, and Schwab enforces this server-side. Fully unattended
long-running Schwab automation is not possible under the current OAuth model. There is also no
sandbox — treat all Schwab access as live.
The unified API normalizes common fields only; anything venue-specific goes through params
passthrough and implicit methods that are not portable. enableRateLimit must be on.
fetchOHLCV has per-exchange limit caps and inconsistent pagination. set_sandbox_mode(True)
exists but only some exchanges have testnets. Precision/rounding rules differ per venue and
silently reject orders. CCXT is connectivity, not a backtester — it has no simulation layer.
| Broker | Server-side proof |
|---|---|
| IB | Account ID prefix from managedAccounts — DU/DF = paper, U = live. Assert on the account ID, not the port |
| Alpaca | TradingClient.get_account() plus the base URL in use; paper keys cannot reach the live host |
| Schwab | Account hash from the accounts endpoint — no sandbox exists |
| freqtrade | dry_run: true and confirm no trade-scoped exchange keys are present |
| ccxt venues | set_sandbox_mode(True) and verify exchange.urls['api'] points at a testnet host |
# Fail closed, on a server-returned fact
acct = ib.managedAccounts()[0]
assert acct.startswith("DU"), f"REFUSING TO TRADE: {acct} is not a paper account"
LIVE = os.environ.get("TRADING_LIVE") == "1", defaulting to False, checked
inside the submission function. Environment beats config, because config files get committed.The failure: you submit, the response times out, you retry, you now hold 2× the position. Networks and broker gateways make this routine.
# Derive deterministically from strategy state — never from a clock or a UUID
coid = f"{strategy_id}-{symbol}-{bar_ts.isoformat()}-{side}" # replay-safe
A retry then either succeeds or is rejected as a duplicate — both safe. A UUID retry doubles your
position. Note IB's orderId is per-clientId and per-session (reusing a clientId across
processes is how duplicate/orphan orders happen), and IB's orderRef is a free-text tag, not an
idempotency key.
stoploss_on_exchange places the stop at the exchange, so it survives your
process dying. The most important line in retail crypto risk management — and it is off by default.RiskEngine states ACTIVE / HALTED / REDUCING, enforced in backtest and
live. REDUCING (position-reducing orders only) is the right state for a controlled wind-down.max_orders_per_minute and max_notional_per_day counters that flip the process to
flatten-and-halt. Neither depends on the broker cooperating.Never trust in-process state as the source of truth — restarts, partial fills, manual intervention and liquidations all desynchronize it.
reqPositions, reqOpenOrders, reqExecutions; ibflex for end-of-day truth.backtesting-engines §2.1).references/<broker>.md — auth model, paper availability, order types, TIF matrix, rate limits,
market-data terms, and the specific ways that broker lets you trade by accident.
The optional fin-libraries plugin carries a dedicated skill for each library below. Load one
only after this skill has told you which library you want:
lib-alpaca-py — alpaca-pylib-ccxt — ccxtSettlement is T+1 since 2024-05-28 and the Pattern Day Trader rule was eliminated on
2026-06-04 (SEC 34-105226) — a model answering from its training prior will get both wrong.
Reg T initial margin and the broker's own maintenance number decide the leverage this account
can actually reach. See ../us-market-rules/SKILL.md.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
18 skills in this plugin
/backtesting-enginesChoose a backtesting engine and know what it silently models wrong. TRIGGER - "backtest this", backtest a crossover or a moving-average strategy, simulate a strategy, walk-forward, parameter sweep, "test this trading idea"; comparing or choosing backtest frameworks; vectorbt, backtesting.py, backtrader, zipline, PyBroker, bt, nautilus_trader, LEAN, freqtrade, jesse; how an engine models fills, slippage, commissions; what slippage to assume, partial fills, margin, shorting or delistings; taking a strategy from backtest to live; "my backtest looks too good"; "works in backtest but loses money live". Several popular engines fill at the signal's own bar close by default. SKIP for judging whether a finished result is real (backtest-validation) for A-share rules (china-trading-stack), for crypto funding and perpetuals (crypto-data-and-execution), for options, which need assignment and settlement no engine here models (options-backtesting), and for measuring fills you already have (execution-cost-analysis)./backtest-overfittingDecide whether an edge that passed every mechanical check is still just the best of N tries. TRIGGER - PBO, probability of backtest overfitting, CSCV, combinatorially symmetric cross validation, logit of the out-of-sample rank; minimum backtest length, MinBTL, "how much history do I need", "how many parameter sets can I try on N years of data"; a grid search, Optuna or AutoML picked a winner and it decayed; "in-sample Sharpe 2, live Sharpe 0", "the best parameter set stopped working", "is this peak on my parameter surface real"; pypbo, RiskLabAI CSCV. SKIP for the deflated and probabilistic Sharpe ratios, the trial ledger and SPA/StepM/MCS against a benchmark (backtest-validation); for family-wise error and false-discovery control over a whole research programme (multiple-testing-ledger); for the purged and combinatorial CV splitters themselves (lib-purgedcv); for the mechanical leakage gates that come first (research-integrity-guards); and for regime coverage of the test window (regime-detection)./backtest-validationDecide whether a result survives the number of things you tried. TRIGGER - "I tried N strategies or parameters and the best one..."; overfitting, p-hacking, data snooping, "is this result real", "is this statistically significant"; deflated Sharpe, DSR, PSR, the trial ledger; White's Reality Check, Hansen SPA, StepM, model confidence set, arch.bootstrap; purged or combinatorial cross-validation, embargo, walk-forward, "cross validation on time series without leaking"; a grid search, hyperopt or AutoML picked a winner; triple-barrier labeling, meta-labeling, fractional differentiation, mlfinlab. Load whenever a Sharpe ratio is about to be offered as evidence for trading. SKIP for plain performance metrics - Sharpe, Sortino, CAGR, drawdown (portfolio-and-risk); for PBO, CSCV and the minimum backtest length (backtest-overfitting); and for Bonferroni, Holm, Benjamini-Hochberg or Benjamini-Yekutieli over a ledger of trials (multiple-testing-ledger). The deflated and probabilistic Sharpe ratios are computed HERE./combining-data-sourcesCombine information of DIFFERENT kinds into one research view whose every number can be traced back to what was knowable when. TRIGGER - joining prices to fundamentals, earnings or a macro series; building a signal from a filing plus a price; merging two vendors into one series; "which vendor do I trust"; combine_first / fillna / bfill across sources; assembling a company dossier, profile or research view from several places; a field that must carry its provenance; "when did this number become knowable"; period_end vs filed vs available; a ticker that changed company mid-sample; filling a ResultCard's data block. SKIP for the mechanics of ONE as-of join (safe_asof, in market-data-engineering); for reconciling two price series from two vendors (reconcile_sources, in market-data-sourcing); for auditing a finished backtest (research-integrity-guards); and for resolving a ticker to a permanent id (security-master-and-symbology)./derivatives-pricingChoose a derivatives pricing library and get its Greek units and conventions right. TRIGGER - option pricing, implied volatility, IV, Greeks, delta, gamma, vega, theta, rho; which pricing library, exotics coverage; QuantLib, vollib, py_vollib, financepy, rateslib, optionlab; option chains. Greek scaling differs by 100x and 365x between the three common libraries, and one popular fixed-income package is not open source. SKIP for option lifecycle events - assignment, pin risk, expiry - live or backtested, and for historical option chains and vendors (options-backtesting). SKIP for the models themselves - implementing one (option-pricing-models), fitting a smile (implied-vol-surface), building a curve (term-structure-models), bond accrued and the 30/360 family (bond-conventions-and-accrued), duration and DV01 (duration-convexity-and-dv01), and projection-versus-discount choice on a swap (ois-discounting-and-multi-curve)./etf-mechanicsWhy an ETF's price series does not behave like the index it tracks - daily-reset leverage, NAV vs price, distributions, holdings files and fees. TRIGGER - "why is my 3x ETF down when the index is flat", TQQQ decay, SQQQ, leveraged ETF long term, inverse ETF, volatility drag, daily reset; premium to NAV, discount to NAV, iNAV, creation/redemption, "bond ETF trading below NAV"; ETF distribution, capital gains distribution, return of capital, "ETF dropped on the ex-date", phantom drop; ETF holdings file, constituents CSV, index reconstitution, Russell rebalance, "I used today's holdings for the backtest"; expense ratio drag, tracking difference vs tracking error, "ETF returned less than the index". SKIP for downloading price series and vendor adjustment defaults (market-data-sourcing) - holdings files stay here, for UNG, USO or VIXY roll yield and contango (futures-continuous-contracts), for auditing a finished backtest (research-integrity-guards), and for weights, Sharpe or drawdown (portfolio-and-risk)./fin-core:broker-execution-apisfrom fin-core
npx claudepluginhub howard-lynn-ye/fin-rsi --plugin fin-core