/algo-trading-skills:etrade-oauth1-signature-flowfrom algo-trading-skills
Handles E*TRADE's OAuth 1.0a HMAC-SHA1 request signing for trading bots. Covers three-legged flow with oob callback, RFC 5849 signature base strings, and token expiry rules.
Ships in algo-trading-skills. 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.
Invoke this skill when building a trading bot for E*TRADE. Unlike most modern broker APIs
that use OAuth 2.0 bearer tokens, E*TRADE uses OAuth 1.0a with HMAC-SHA1 request
signing. Every API request must carry an Authorization: OAuth ... header with a nonce,
timestamp, and signature computed over a canonical signature base string. This skill
covers the full three-legged flow, per-request signing, and E*TRADE's two distinct token
lifetime rules.
schwab-api-oauth-pkce-flow), Upstox
uses refresh-token rotation (upstox-oauth-refresh-token-rotation).RSA-SHA1 and PLAINTEXT are not implemented — E*TRADE documents HMAC-SHA1 as the
only supported oauth_signature_method.scripts/etrade_auth.py deliberately issues no requests and adds
no dependencies. It returns URLs and header values; you supply the transport, timeouts,
and retry policy.headless-broker-auth-patterns and token-lifecycle-live-probing.centralized-secrets-management-vault-integration and
secrets-rotation-without-bot-downtime.oauth_timestamp
tolerance). See clock-drift-monitoring-alerting-thresholds.Request Token — GET {base_url}/oauth/request_token.
oauth_callback is mandatory and must be "oob", whether or not the app has a
callback URL registered. It has no server-side default; omitting it fails the call.
build_request_token_header() sets it.&.parse_token_response(). An E*TRADE error body
also parses cleanly as form data, so decision point: reject any response without
both oauth_token and oauth_token_secret rather than storing empty strings — an
empty-credential client fails opaquely at the first API call, not here.User Authorization — GET https://us.etrade.com/e/t/etws/authorize?key=…&token=….
us.etrade.com for both sandbox and production. Deriving it from api.etrade.com
or apisb.etrade.com yields a dead URL.+, /, and =;
an unencoded + arrives at the server as a space and authorizes nothing.oauth_verifier on the Authorization Complete page
(or appended to a registered callback URL).Access Token — GET {base_url}/oauth/access_token.
oauth_token (the request token) and oauth_verifier.Sign Requests — build the RFC 5849 base string, then HMAC-SHA1 it.
oauth_* header parameters plus the URL's query
parameters plus any form-encoded body parameters. oauth_signature and realm are
excluded.percent_encode(consumer_secret) + "&" + percent_encode(token_secret).?detailFlag=ALL produces a signature E*TRADE rejects, because the query
parameters were never in the base string.Token Lifecycle — two independent rules, with different remedies.
GET {base_url}/oauth/renew_access_token
(sign_renew_access_token()).GET {base_url}/oauth/revoke_access_token
(sign_revoke_access_token()).Full procedure: see
references/workflows.md. Standards and endpoint table: seereferences/standards.md. Printable pre-flight checklist: seeassets/checklist.md.
/v1/accounts/{id}/orders signs fine, then
?status=OPEN&count=50 is appended and every call is rejected. Query parameters are a
mandatory signature input (RFC 5849 §3.4.1.3.1), and the base string URI must carry no
query at all."a b" < "a+" (0x20 < 0x2B), but
encoded "a%20b" < "a%2B" orders them the other way. The difference only surfaces on
values containing spaces, +, or non-ASCII — so it passes every simple test and fails on
the first symbol list or free-text order field.oauth_callback on leg one. E*TRADE requires it on the request-token call
and documents that it must always be "oob". There is no default.us.etrade.com, not api.etrade.com/apisb.etrade.com, in both environments.+, /, and =; an unencoded + is decoded server-side as a space.+, /,
and =, all of which must be escaped inside the quoted header value.oauth_timestamp must be within 5 minutes of E*TRADE's clock. A drifting
container clock produces signature rejections that look like credential failures.repr prints secrets in plain text
into logs and tracebacks. OAuth1Credentials and OAuth1Token mark secret fields
repr=False; keep it that way.build_base_string("POST", "http://example.com/request?b5=%3D%253D&a3=a&c%40=&a2=r%20b", …)
including the body parameters c2= and a3=2 q and a realm that must be dropped. This
vector exercises query-parameter inclusion, a repeated name, realm exclusion, and
encode-then-sort ordering at once.Ls93hJiZbQ3akF3HF3x1Bz8/zU4=
from its published base string and signing key, which pins HMAC-SHA1 and base64 end to end.build_request_token_header() emits oauth_callback="oob" and no oauth_token.get_authorize_url() starts with https://us.etrade.com/e/t/etws/authorize? for
both use_sandbox=True and False, and that a token a+b/c= encodes to a%2Bb%2Fc%3D.parse_token_response() must raise on an empty body, on
oauth_problem=signature_invalid, and on a response missing either token field;
sign_request() and sign_renew_access_token() must raise before an access token is set;
blank consumer credentials must raise at construction.repr(OAuth1Credentials(...)) contains neither secret.python -m unittest discover -s skills/etrade-oauth1-signature-flow/scripts and confirm 100% pass rate.headless-broker-auth-patternsschwab-api-oauth-pkce-flowbroker-agnostic-adapter-interfacetoken-lifecycle-live-probingclock-drift-monitoring-alerting-thresholdsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub himanshuj16/algo-trading-skills --plugin algo-trading-broker-integration36 skills in this plugin
/alpaca-paper-live-key-separationUse when a bot connects to the Alpaca Trading API and must never cross paper keys with the live endpoint; pins the base URL per environment, checks the key prefix, probes /v2/account and requires an explicit ALLOW_LIVE_TRADING flag./api-key-least-privilege-audit-toolUse before deploying a live bot, to audit existing broker API keys for scopes they do not need. Flags withdrawal, transfer and admin rights that turn a leaked execution key into theft./broker-account-margin-call-handlingUse when a bot trades a Reg T, portfolio or futures margin account and must act before the broker liquidates: tiered maintenance-margin warnings cross-checked against broker excess liquidity, initial-margin order gating and liquidity-aware de-leveraging.Other plugins' skills for the same job