Implementing SPAN Margining for a US Broker
Case study

Implementing SPAN Margining for a US Broker

About the Client

The client is a US-based broker that offers services to individual and institutional traders in the US and worldwide. They offer one-click access to all major US exchanges and market centers through their analysis platform. This allows their customers to monitor, automate, and backtest custom equities, options, and futures trading strategies.

Business Challenge

The client was set to add options and futures instruments to their product offerings but encountered issues with implementing SPAN margining into their existing trading platform.

The client did not want to introduce SPAN as a major update to their trading platform. Instead, they wanted to introduce it as a seamlessly integrated service. The client also required complex portfolio calculation rules that would combine SPAN margin with different algorithms for outright futures.

In addition, the client was concerned about the amount of time the calculations would take: it needed to be limited. SPAN margining creates a combinatorial explosion: the more orders and positions, the longer the algorithm takes to analyze the portfolio. Meanwhile, the portfolio also requires continuous reassessment with special heuristics according to order execution.

The client decided to seek guidance from an experienced software vendor for advice on margin calculations and development.

The client ultimately wanted an outline of the margin calculation logic for:

  1. The current margin requirement of a portfolio (with householding master/sub-accounts support)
  2. Pre-trade order validation
  3. What-if analysis

They also required support for futures and futures options instruments from the following exchanges: CBOT, CFE, CME, COMEX, EUREX, ICEBS, ICEEU, ICEUS, and NYMEX.

Solution

The client hired Devexperts because of its reputation for having high-end professionals with relevant expertise and experience in implementing similar services for top US companies in the industry.

Devexperts proposed developing three standalone services to fulfill all requirements and for the sake of simple integration with the client’s existing system:

  1. A Margin Service responsible for all the logic of margin requirement calculations in the scope of the Futures Options project:
    • SPAN margin for SPAN-eligible products
    • Outright future margin for SPAN-ineligible products
    • Day trade margin relief configured for an account/product
    • Margin scale-ups configured for an account
  2. A Position Grouping service responsible for algorithmic and custom manual grouping of positions in the client GUI terminals.
  3. An Options Pricing service providing theoretical prices for Futures & Options markets.

The Margin Service needed to support both SPAN and outright futures margin. The SPAN algorithm implementation was to be based on CME’s methodology. The service needed to be able to calculate margin requirements for a mixed portfolio of SPAN-eligible and -ineligible instruments. 

Devexperts designed the Margin Service as an internal component that could communicate with the client’s system backend to receive configurations, positions,  orders, margin settings, conversion rates, master/sub-account relationships, and theoretical options prices. Devexperts outlined all technical details of these integrations along with supported APIs, data formats, and use cases.

Devexperts designed the Margin Service
Devexperts designed the Margin Service as an internal component

The Position Grouping Service was to be responsible for the algorithmic and custom grouping of positions in client portfolios. It was designed to communicate with the client’s system backend to receive position portfolios by re-using the same integration endpoints and protocols designed for the Margin service.

The Position Grouping Service required persistent storage for the client’s custom groupings.
The Position Grouping Service required persistent storage for the client’s custom groupings

Due to illiquidity in the Future Options markets, the Margin service needed to use theoretical Options prices to calculate Net/Short/Long Options Values for illiquid options contracts.

For this purpose, the Options pricing service was implemented as a separate endpoint to make theoretical prices and Greeks available to client’s other in-house risk tools and end-user trading UI applications.

For the options pricing, Devexperts proposed the cloud service dxPrice from its subsidiary dxFeed. The service consumes options market data and provides arbitrage-free theoretical prices and Greeks as a streaming output. dxFeed has market data available for all the exchanges that have to be supported according to the project’s scope.

By implementing these three services, the client would be able to introduce options and futures instruments with SPAN margin for SPAN-eligible products and outright future margin for SPAN-ineligible products. They also guarantee support for the whole range of required exchanges.

Results

Devexperts provided a comprehensive system architecture design for the client to add options and futures instruments to their offering, supporting SPAN margin for SPAN-eligible products and outright future margin for SPAN-ineligible products. It included high- and low-level design, blueprints, and data flow diagrams.

The project design comprised three separate services that would cover all the client’s requirements for the current margin of a portfolio, pre-trade order validation, and what-if analysis. These could be seamlessly implemented into the client’s existing trading platform and provide support for the entire range of required exchanges.