Imandra Formal Verification of Financial Algorithms, Progress and - - PowerPoint PPT Presentation

imandra
SMART_READER_LITE
LIVE PREVIEW

Imandra Formal Verification of Financial Algorithms, Progress and - - PowerPoint PPT Presentation

Imandra Formal Verification of Financial Algorithms, Progress and Prospects Grant Olney Passmore ACL2-2017, Austin Joint work with Denis Ignatovich and our incredible team at AI AESTHETIC DESIGNED INTEGRATION WITH CARE BY Video (see


slide-1
SLIDE 1

Imandra

Grant Olney Passmore
 ACL2-2017, Austin

AESTHETIC INTEGRATION DESIGNED WITH CARE BY

Formal Verification of Financial Algorithms, Progress and Prospects

Joint work with Denis Ignatovich and our incredible team at AI

slide-2
SLIDE 2 The Logic of Financial Risk™/ 2

Video
 (see it on http:/ /imandra.ai)

slide-3
SLIDE 3 3 The Logic of Financial Risk™/

Problem

Financial markets have become notoriously unstable.

slide-4
SLIDE 4 Flash Crashes: systemic events characterised by non-trivial co- dependence of trading algorithms (e.g., May 2010, drop of $1tr) 4 The Logic of Financial Risk™/

Problem

Financial markets have become notoriously unstable.

slide-5
SLIDE 5 Flash Crashes: systemic events characterised by non-trivial co- dependence of trading algorithms (e.g., May 2010, drop of $1tr) 5 The Logic of Financial Risk™/

Problem

Financial markets have become notoriously unstable.

Lack of Transparency: issues of misrepresentation (e.g., misleading marketing materials or regulatory filings) of trading algorithm behaviour (e.g., BATS/Direct Edge $14M settlement with the SEC)
slide-6
SLIDE 6 Flash Crashes: systemic events characterised by non-trivial co- dependence of trading algorithms (e.g., May 2010, drop of $1tr) 6 The Logic of Financial Risk™/

Problem

Financial markets have become notoriously unstable.

Lack of Transparency: issues of misrepresentation (e.g. misleading marketing materials or regulatory filings) of trading algorithm behaviour (e.g., BATS/Direct Edge $14M settlement with the SEC) Glitches: trading system errors in design or implementation,
  • fuen causing significant losses (e.g., Knight Capital’s loss of
$400M)
slide-7
SLIDE 7

Goals for this talk

7
  • Concepts: venue, exchange, dark pool, order

book, order type (market, limit, pegged), matching logic, market microstructure, smart

  • rder router
slide-8
SLIDE 8
  • Regulations: Transparency, safety and

fairness (Reg ATS-N), best execution (Reg NMS)

Goals for this talk

  • Concepts: venue, exchange, dark pool, order

book, order type (market, limit, pegged), matching logic, market microstructure, smart

  • rder router
slide-9
SLIDE 9
  • Practice: Be able to write a spec and

analyse basic regulatory properties of a trading venue’s matching logic

Goals for this talk

  • Concepts: venue, exchange, dark pool, order

book, order type (market, limit, pegged), matching logic, market microstructure, smart

  • rder router
  • Regulations: Transparency, safety and

fairness (Reg ATS-N), best execution (Reg NMS)

slide-10
SLIDE 10
  • Intuitions:
  • “Venue matching logics” = “ISA of the market”
  • Pressing need for:
  • venues to be bullet-proof w.r.t. safety and fairness
regulations
  • matching logics to be formally described to regulators and
market participants
  • matching logics to be formally analysed w.r.t. precise
encodings of regulatory directives
  • financial mathematics (stochastic calculus) that takes
precise discrete behaviour of matching logics into account

Goals for this talk

slide-11
SLIDE 11 The Logic of Financial Risk™ / 11

The Stack of Financial Algorithms

slide-12
SLIDE 12 The Logic of Financial Risk™ /12

Venues

The Stack of Financial Algorithms

slide-13
SLIDE 13 The Logic of Financial Risk™ /13

Venues Smart Order Routers

The Stack of Financial Algorithms

slide-14
SLIDE 14 The Logic of Financial Risk™ /14

Venues Smart Order Routers Trading Algos

The Stack of Financial Algorithms

slide-15
SLIDE 15 The Logic of Financial Risk™ /15

Venues Smart Order Routers Trading Algos Algo Containers

The Stack of Financial Algorithms

slide-16
SLIDE 16 The Logic of Financial Risk™ /16

Venues Smart Order Routers Trading Algos Algo Containers Inventory Management

The Stack of Financial Algorithms

slide-17
SLIDE 17 The Logic of Financial Risk™ /17

Venues Smart Order Routers Trading Algos Algo Containers Collateral Trading Inventory Management

The Stack of Financial Algorithms

slide-18
SLIDE 18 The Logic of Financial Risk™ /18

Venues Smart Order Routers Trading Algos Algo Containers Collateral Trading Inventory Management

The Stack of Financial Algorithms

slide-19
SLIDE 19 The Logic of Financial Risk™ /19

Venues Smart Order Routers Trading Algos Algo Containers Collateral Trading Inventory Management high freq low freq

The Stack of Financial Algorithms

slide-20
SLIDE 20 The Logic of Financial Risk™ /20

Venues Smart Order Routers Trading Algos Algo Containers Collateral Trading Inventory Management high freq low freq

The Stack of Financial Algorithms

discrete, nonlinear

slide-21
SLIDE 21 The Logic of Financial Risk™ /21

Venues Smart Order Routers Trading Algos Algo Containers Collateral Trading Inventory Management high freq low freq

The Stack of Financial Algorithms

discrete, nonlinear continuous, nonlinear

slide-22
SLIDE 22 The Logic of Financial Risk™ /22

What is a venue?

slide-23
SLIDE 23 The Logic of Financial Risk™ /23

What is a venue?

slide-24
SLIDE 24 The Logic of Financial Risk™ /24

What is a venue?

slide-25
SLIDE 25 The Logic of Financial Risk™ /25

LIT LIQUIDITY

DARK LIQUIDITY

What is a venue?

slide-26
SLIDE 26

620 companies 52 countries First place winner!

The Logic of Financial RiskT M

Running Example: UBS ATS

slide-27
SLIDE 27 The Logic of Financial RiskT M Jan, 2015: UBS fined $14M by the SEC for issues of unfairness in their dark pool design

First place winner! 620 companies 52 countries We analysed it, found more issues

Running Example: UBS ATS

slide-28
SLIDE 28 The Logic of Financial RiskT M

Running Example: UBS ATS

slide-29
SLIDE 29 The Logic of Financial RiskT M

Running Example: UBS ATS

Let’s examine an actual regulatory disclosure
 (esp. Sec 4.1)
slide-30
SLIDE 30
  • Programming language
  • Mathematical logic
  • Reasoning engine

The Logic of Financial RiskT M

What is Imandra?

slide-31
SLIDE 31
  • Programming language
  • Mathematical logic
  • Reasoning engine

The Logic of Financial RiskT M
  • First-class counterexamples
  • Nonlinear + SE decomposition
  • Proof automation for various
financial regulations
  • Test suite generation
  • Documentation generation


Automated Reasoning

+

What is Imandra?

slide-32
SLIDE 32 The Logic of Financial Risk™ /32
  • maintain an order book
  • process incoming orders
  • match orders (‘trade’!)
  • send `fills’
  • route orders away (`best-ex’)
  • report on market activity

…all according to a (precisely?) defined ‘spec’
 …while obeying many complex regulations

What does a venue do?

slide-33
SLIDE 33 The Logic of Financial Risk™ /33

What is an order book?

slide-34
SLIDE 34 The Logic of Financial Risk™ /34

What is an order book?

slide-35
SLIDE 35 The Logic of Financial Risk™ /35

at each discrete time-step,
 the book is sorted.

What is an order book?

slide-36
SLIDE 36 The Logic of Financial Risk™ /36

how is it sorted?

What is an order book?

slide-37
SLIDE 37 The Logic of Financial Risk™ /37

how is it sorted?

VERY COMPLEX ANSWER!

What is an order book?

slide-38
SLIDE 38 The Logic of Financial Risk™ /38

how is it sorted?

INTUITION: 
 Price/Time Priority

What is an order book?

slide-39
SLIDE 39 The Logic of Financial Risk™ /39

how is it sorted?

INTUITION: 
 Price/Time Priority

What is an order book?

REALITY:
 Let’s see!
slide-40
SLIDE 40 The Logic of Financial Risk™ /40
  • buy or sell a given security
  • in a specified manner,
  • subject to market constraints, and
  • order parameters.

an instruction to

What is an order?

slide-41
SLIDE 41 The Logic of Financial Risk™ /41 “buy 100 shares of MSFT, with price at most $50”
  • buy or sell a given security
  • in a specified manner,
  • subject to market constraints, and
  • order parameters.

an instruction to

What is an order?

slide-42
SLIDE 42 The Logic of Financial Risk™ /42
  • buy or sell a given security
  • in a specified manner,
  • subject to market constraints, and
  • order parameters.

an instruction to

“buy 100 shares of MSFT”

What is an order?

“buy 100 shares of MSFT, with price at most $50”
slide-43
SLIDE 43 The Logic of Financial Risk™ /43

What is an order?

slide-44
SLIDE 44 The Logic of Financial Risk™ /44

What is an order type?

MARKET ORDER
slide-45
SLIDE 45 The Logic of Financial Risk™ /45

What is an order type?

MARKET ORDER LIMIT ORDER
slide-46
SLIDE 46 The Logic of Financial Risk™ /46

What is an order type?

MARKET ORDER LIMIT ORDER ICEBERG ORDER
slide-47
SLIDE 47 The Logic of Financial Risk™ /47

What is an order type?

MARKET ORDER LIMIT ORDER STOP LOSS ORDER ICEBERG ORDER
slide-48
SLIDE 48 The Logic of Financial Risk™ /48

What is an order type?

slide-49
SLIDE 49 The Logic of Financial Risk™ /49

What is an order type?

slide-50
SLIDE 50 The Logic of Financial Risk™ /50

What is an order type?

slide-51
SLIDE 51 The Logic of Financial Risk™ /51
  • Is your venue fair?
  • Can you prove it?
  • If it’s not fair, how can you fix it?
  • Can your collection of order-types ever
violate regulatory directives?
  • Does your high-performance
implementation conform to your high- level design specification?
  • Does your documentation of your order-
types truly match your implementation?
  • How can you automate both testing and
compliance?
  • What is the strongest possible evidence
you can give to regulators?

Difficult questions:

Is your venue fair?

slide-52
SLIDE 52 The Logic of Financial Risk™ /52

Formal analysis of trading venues

  • Analysis of safety and fairness

properties of trading venues (dark pools, exchanges, etc.)

  • In use at top global investment

banks

  • Principled way to manage

growing order-type proliferation

  • Exciting developments in

regulatory space (more soon…!)

slide-53
SLIDE 53 The Logic of Financial Risk™ /53

Running Example: UBS ATS

Demo: Transitivity of

  • rder ranking
slide-54
SLIDE 54 The Logic of Financial Risk™ /54

Example: SIX Swiss Exchange

slide-55
SLIDE 55 The Logic of Financial Risk™ /55

Pricing Logic: Informal

slide-56
SLIDE 56 The Logic of Financial Risk™ /56

Pricing Logic: Formal

slide-57
SLIDE 57 The Logic of Financial Risk™ /57

Pricing Fairness Example

  • Consider specification of the SIX Swiss matching logic - we

will prove that client ID, although used by the system, does not factor into pricing and matching decisions

  • We will use IML to encode both the matching logic and the

fairness principle, and then use Imandra to reason about the model

  • Our example highlights iterative nature of the specification

process: We discover, through a non-trivial counter- example, that our original hypothesis is incorrect. We then update our specification or model accordingly and iterate.

slide-58
SLIDE 58 The Logic of Financial Risk™ /58

Pricing Fairness Example

  • The following is an overview of the SIX Swiss Matching Engine
  • Three market models: CLOB, MMB, and MMB-FoK
  • Six business periods, 5 order types with numerous attributes
  • 22 product types across equities, bonds, funds, and structured

products with specific trading parameters

  • Randomised auction times, volatility circuit breakers, order

validities, and regulatory reporting requirements

  • Complexity stems from the need to meet diverse client needs

while operating a heavily regulated business

slide-59
SLIDE 59 The Logic of Financial Risk™ /59 ? MatchPrice(S) = MatchPrice(S’)

Pricing Fairness Example

  • B_1 == B_2 except Client ID
  • S_1 == S_2 except Client ID
slide-60
SLIDE 60 The Logic of Financial Risk™ /60 NO MatchPrice(S) = MatchPrice(S’)

Pricing Fairness Example

  • B_1 == B_2 except Client ID
  • S_1 == S_2 except Client ID
slide-61
SLIDE 61 The Logic of Financial Risk™ /61 MatchPrice(S) = MatchPrice(S’) YES

Pricing Fairness Example

  • B_1 == B_2 except Client ID
  • S_1 == S_2 except Client ID
slide-62
SLIDE 62 The Logic of Financial Risk™ /62
  • symbolic execution modulo nonlinear sign-invariance
  • intuitively, a generalisation of cylindrical algebraic decomposition to
programs
  • the basis of IMANDRA’s test-suite and documentation generation

Principal Region Decomposition

slide-63
SLIDE 63 The Logic of Financial Risk™ /63

Venues Smart Order Routers Trading Algos Algo Containers Collateral Trading Inventory Management high freq low freq

The Stack of Financial Algorithms

slide-64
SLIDE 64 The Logic of Financial Risk™ /64

Venues Smart Order Routers Trading Algos Algo Containers Collateral Trading Inventory Management high freq low freq

The Stack of Financial Algorithms

we’re here

slide-65
SLIDE 65 The Logic of Financial Risk™ /65

Venues Smart Order Routers Trading Algos Algo Containers Collateral Trading Inventory Management high freq low freq

The Stack of Financial Algorithms

we’re here how do we get here?

slide-66
SLIDE 66 The Logic of Financial Risk™ /66

Formalized Financial Mathematics

Assuming every order is a MARKET ORDER is ridiculous. We need new financial mathematics that takes the precise
 discrete market microstructure into account.

slide-67
SLIDE 67 The Logic of Financial Risk™ /67

Formalized Financial Mathematics

Assuming every order is a MARKET ORDER is ridiculous. We need new financial mathematics that takes the precise
 discrete market microstructure into account.

Stochastic Calculus Brownian Motion Wiener Processes Martingales Stochastic Control
slide-68
SLIDE 68 The Logic of Financial Risk™ /68

Conclusion

  • Pressing need for:
  • venues to be bullet-proof w.r.t. safety and fairness

regulations

  • matching logics to be formally described to regulators and

market participants

  • matching logics to be formally analysed w.r.t. precise

encodings of regulatory directives

  • financial mathematics (stochastic calculus) that takes

precise discrete behaviour of matching logics into account

  • this is a killer app for formal methods!