Saxo Bank
How the fund talks to Saxo, what it refuses to do, and how to set it up. The decision record is
decisions/0019-saxo.md. Saxo is the second live venue. It sits behind the same approval
ladder, the same signature and the same HARD rules as Interactive Brokers. Only one broker is configured
at a time (BROKER=ibkr or BROKER=saxo).
The fund reaches Saxo through Saxo's OpenAPI, with an app you register yourself. You log in on Saxo's own page, and the fund never sees, asks for or stores your Saxo password. The settings store refuses any field named like one. You sign every order and you sign the go-live. Nothing in this document changes that.
The honest limit. This venue has been built from Saxo's published reference and tested only against a scripted
fake (test/helpers/fake-saxo.ts). It has never run against a real Saxo account, simulation or live. The shapes
it is least sure of are listed under Uncertain shapes. Run it in Saxo's simulation environment
first, and do not sign a live go-live on Saxo until a simulation round trip (connect, check instruments, a signed
order, a fill, a reconciliation) has worked end to end on your own account.
Setting it up
Register an app. Log in at developer.saxo with your Saxo login and create an application for the simulation environment. Choose the authorization code grant with PKCE. As its redirect address, register the fund's address followed by
/oauth/saxo/callback, for examplehttps://my-fund.tailnet-name.ts.net/oauth/saxo/callback. Saxo sends your browser back only to an address registered exactly.Enter the settings. In Connections, open the broker card, choose Saxo Bank and fill in:
Setting What it is BROKERsaxoSAXO_APP_KEYThe app key Saxo shows for your app (the OAuth client id) SAXO_APP_SECRETOnly if your app has a secret. A PKCE app does not. Sealed like every secret SAXO_REDIRECT_URLThe redirect address registered in step 1, exactly SAXO_ENVsim(the default) orliveSAXO_ACCOUNTOptional: the AccountId to trade. Unset, the client's default account is used Or set them in the environment, which always wins over the dashboard:
# .env BROKER=saxo SAXO_APP_KEY=<your app key> SAXO_REDIRECT_URL=https://my-fund.tailnet-name.ts.net/oauth/saxo/callback SAXO_ENV=simSettings saved in the dashboard take effect at once; settings in the environment are read at start.
Connect. Press Connect Saxo on the broker card. Your browser goes to Saxo's login page, you log in there, and Saxo sends you back to
/oauth/saxo/callbackwith a one-time code. The fund exchanges it for tokens and returns you to the dashboard. The Connect is single use and expires after ten minutes.Check the instruments. Press Check instruments. Every name in the universe is mapped to exactly one Saxo instrument: ISIN first, on the home market, with the currency checked. A name that maps to none, or to more than one, is listed and will not be traded.
Rehearse. On the Connections page, the dry run asks Saxo's precheck for one share of the benchmark. Nothing is placed. Then go live in the broker panel, in the simulation environment first. The go-live is the same signed terms, rung check and account check as for IBKR.
SAXO_ENV=live points the same app at Saxo's live gateway. A token issued for the simulation environment is never
used against the live one: changing the environment means connecting again. You also need to register a live app at
developer.saxo, which Saxo approves separately.
The connection
The tokens are sealed with the integrations key and kept in <data>/saxo-token.json with mode 0600, bound to the
environment and app key they were issued for. They never reach the browser, the Record or a log. Without a data
directory (--memory) they live in memory and a restart means connecting again.
The access token is renewed a minute before it expires, one renewal at a time, and again once if Saxo answers 401.
When Saxo refuses the renewal, or the refresh token has expired, the connection is forgotten and the broker card and
topbar ask you to connect again. A network failure during a renewal keeps the connection for the next try.
Disconnect forgets the tokens on this server. It is refused while the fund is live on Saxo; go back to paper first.
Orders: what the fund guarantees
The same guards as IBKR, in the same order, before anything is sent. Each refusal names its reason, and nothing is sent.
- Saved before sent. Every order is written as
sendingbefore the request leaves. - ExternalReference is the client order id. Every order is a DAY limit order with
ManualOrder: true(you decided it) and the fund's client order id asExternalReference. A lost answer is looked up by it in Saxo's open orders and order activities, and an order found there is adopted. - A lost answer is never resent. Unlike IBKR, Saxo does not refuse a second order with the same reference. So an
order whose answer was lost (a timeout, a dropped connection, a server error after the write) stays
unknownuntil Saxo shows it or you resolve it. An order the process was sending when it stopped becomesunknownon restart, with that reason. Recovery and the poll look such an order up and never send it again. PastORDER_STUCK_MINit is flagged like any other: see operating.md. - No order on a stale price. Only a
Tradablebid and ask on an open market price an order. An indicative price or a closed market refuses it. A delayed price is allowed and noted on the order. - The collar. The limit must be within 2% of Saxo's price (the mid of bid and ask).
- No margin. A buy must be covered by the account's cash balance and by what Saxo reports as available for trading. Either figure missing refuses the order.
- No shorts. A sell must be covered by the shares the account holds at Saxo.
- EUR only, for now. The account must be in EUR, the order in EUR, and Saxo's instrument in EUR. There is no signed conversion leg to Saxo yet.
- The precheck is signed. When the fund is live on Saxo, each order you are asked to sign carries Saxo's precheck with its time and hash: the commission and its currency, the cash required, the fund's euro rate and warnings. The digest you sign covers it. A precheck Saxo refuses, or one that raises a pre-trade disclaimer (a PRIIPs/KID notice), cannot be signed: the fund never accepts a disclaimer on your behalf.
- The precheck is checked when you sign and again before sending, with the same tolerance as IBKR's preview: the commission may move by the larger of EUR 1 and 20%; a commission that appears, vanishes or changes currency, a new warning, an error or a block refuses the signature (or rejects the order unsent), and the approval is issued again for a new signature.
- Pacing. At most 2 requests a second, and a second between order requests (placement, precheck, cancel). On a
429a read waits for Saxo'sX-RateLimit-*-Reset(a second when it gives none) and is tried once more; an order is never retried. A second429in a row pauses every call for a minute or Saxo's reset, whichever is longer. Nothing is sent during the pause.
Fills and reconciliation
The fund polls Saxo's order activities for its orders. Each Fill or FinalFill activity is booked once, by Saxo's
execution id. Reconciliation compares the fund's positions and euro cash with Saxo's positions and balance, as for
IBKR. The cash compared is the account's cash in its own currency (EUR, since live trading on Saxo is EUR-only).
There is no Flex statement at Saxo; the daily statement check is IBKR-only.
Uncertain shapes
Every Saxo field name the fund relies on is in src/broker/saxo/api.ts and nowhere else. These are the ones the
published reference did not settle. Where a name is uncertain the reader takes the documented one first and a known
alternative second, and returns nothing rather than a guess, which refuses the order.
| Where | What the fund reads | Why it is uncertain |
|---|---|---|
| Precheck costs | Cost.Long / Cost.Short .Commission, else Costs.*, Commissions[0].Value, EstimatedCommission | The cost breakdown's layout for FieldGroups: ['Costs'] differs between reference pages |
| Precheck currency | Cost.Currency, else CostCurrency, else the order's currency | Not shown on every example |
| Pre-trade disclaimers | PreTradeDisclaimers.DisclaimerTokens, else its DisclaimerContext | Any disclaimer blocks, whatever its shape |
| Cash available | CashAvailableForTrading, else MarginAvailableForTrading | The second includes margin on some account types; the cash balance is checked too |
| Positions | PositionBase or NetPositionBase, Uic and Amount | Net and per-position views both exist |
| Instrument market | The part of Symbol after the colon (ASML:xams), read as the MIC | Observed in examples, not specified |
| Instrument id | Identifier, else Uic | The search answer names it Identifier |
| Fill quantity and price | FillAmount / FilledAmount, ExecutionPrice / AveragePrice | Activity fields vary by activity type |
| Fill id | ExecutionId, else order id, time and sequence | An activity without an execution id is identified by its position |
| Rate limits | The smallest X-RateLimit-*-Reset header, in seconds | Saxo sends several dimensions |
| Order status | FinalFill, Fill, Cancelled, Expired, Rejected, Error | Other statuses are treated as working |
Not done yet
- Running against a real Saxo account. See the honest limit at the top.
- Streaming prices and order events. The fund polls.
- Sending a currency conversion to Saxo, and with it live trading in currencies other than EUR.
- Accepting a pre-trade disclaimer. An order that raises one is refused; place it at Saxo yourself if you accept it.
- Keeping the instrument map across restarts. It is cached in memory and signed into the go-live terms.