DpExchange.Schwab.Orders (DpExchangeSchwab v0.1.2)

Copy Markdown View Source

Building Schwab order payloads, and refusing the ones the venue publishes as invalid — internal.

An order here is a strategy with legs

Every worked example in the venue's documentation has the same skeleton: an outer strategy carrying orderType, session, duration and orderStrategyType, and an orderLegCollection of instruments and instructions. Core.Venue.place_order/3 takes a flat request — one symbol, one side, one quantity — so this module builds the single-leg SINGLE strategy that shape corresponds to, and nothing else.

Multi-leg spreads, TRIGGER and OCO nest whole orders inside childOrderStrategies and are unreachable through the contract. That is a Core gap, recorded rather than worked around: inventing a request shape here would put venue vocabulary into a consumer's code, which is exactly what the facade exists to prevent (D12).

session has no slot in the contract, and it is required

Every documented example carries it, including the simplest market order. Nothing in Core expresses "which trading session", because every crypto venue trades continuously. NORMAL is used unless the caller overrides it, and that default is stated here rather than hidden: it is the session a person placing an order by hand would get, and the alternative is refusing every order until Core grows the field.

The instruction matrix is published, so a mismatch is refused locally

Schwab documents which instructions each asset type accepts, and the table is exhaustive. That is worth using rather than discovering: on this venue order writes are the throttled operation and reads are free, so an order rejected for a knowable reason has spent a scarce slot to learn something the documentation already said.

Summary

Functions

Build a single-leg order payload from a contract request.

Instructions the venue accepts for equities.

Instructions the venue accepts for options.

Functions

build(request, opts \\ [])

@spec build(
  map(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Build a single-leg order payload from a contract request.

The request is Core's vocabulary: :symbol, :side, :quantity, and optionally :order_type, :price, :stop_price, :time_in_force, :session.

Refuses, by name and before any request, when:

  • the order type or time-in-force is outside what this venue serves
  • a limit order carries no price, or a stop order no stop price — the venue would reject it, and a locally-refused order has not spent a throttled write
  • the instruction does not match the asset type, per the venue's published matrix

equity_instructions()

@spec equity_instructions() :: [String.t()]

Instructions the venue accepts for equities.

option_instructions()

@spec option_instructions() :: [String.t()]

Instructions the venue accepts for options.