Upgrade to Pro — share decks privately, control downloads, hide ads and more …

trading systems for fun and profit

trading systems for fun and profit

Slides from my talk at EmpireJS

Roman Shtylman

October 22, 2012
Tweet

More Decks by Roman Shtylman

Other Decks in Business

Transcript

  1. agenda • exchange architecture • modules of interest • ???

    • profit! disclaimer: the opinions expressed in this presentation are mine and do not reflect the opinions of my employer
  2. SELL SELL SELL • high frequency and automated trading •

    node.js 0.2/0.3 days ◦ random web projects • why make a new exchange? • "internet nerd tokens"!
  3. bitfloor corporate seal • started Aug 2011 • moving over

    700,000 USD July/Aug • various forms of deposit over lifetime ◦ USD is not easy • bitcoins are alpha from a user perspective
  4. may I take your order? • matching engine contains the

    order book ◦ bid/ask (buy/sell) • order book is the ledger indicating who wants to buy (size) at what price (level) • first come first serve ◦ there are others • module: bintrees
  5. spread 'em BUY 5 @ 1 SELL 2 @ 3

    BUY 2 @ 2 BUY 2 @ 1 SELL 3 @ 4 SELL 1 @ 2 • The "gap" between lowest bid and highest ask is the spread. • If you want to get "filled" you must cross the spread. • This "fill" is called an execution and creates a "tick" • This is printed on the ticker as the price. • If you cross the book and are not filled, you're gonna have a bad time!
  6. diagrams! Two fundamentals • order entry • market data •

    order gateways • matching engine • clearing ◦ realtime vs delayed • market data ◦ realtime vs historic postgres matching engine mongo www REST FIX Websocket clearing orders multicast historic
  7. matching engine • maintains the state of the order book

    ◦ no db communication • tcp input ◦ WAL ◦ request state • multicast output ◦ sequence numbered • JSON messages • testing ◦ state and output
  8. place your bets! • user facing • order entry ◦

    website ◦ REST ◦ FIX • market data ◦ REST ◦ websocket • system design makes it easy to add more
  9. connectivity • multicast allows for many consumers • you don't

    need another pub/sub system, the network can do it for you ◦ dropping better than latency • "I know this great UDP joke, but you might not get it"
  10. • every dependency is a new burden ◦ dependency issues

    are now your issues • deploying different version is a debugging disaster ◦ death to ~, >=, #.#.x, * • devs who mostly use their own modules do NOT appreciate this pinhead
  11. int/num INT sometimes I want to express your mom's weight

    in my web app NUM because 0.2 + 0.1 should never equal 0.3? How would you feel if your bank showed you rounding errors?
  12. notp users will pick "password" as their password * and

    users will format their phone and then lock themselves out
  13. raven (getsentry.com) • What happens when shit breaks? • Do

    you have 24/7 ops? • Debugging production problems with no info is awesome! • Use something!! ◦ tail, syslog, email, etc
  14. logging • Unstructured logging is so 1990's ◦ console.log is

    for n00bs • book, winston, bunyan, debug, etc ◦ easy to add new destinations/features • don't make it harder to debug things!
  15. spaceport • ip/port configurations are annoying • leverage multicast for

    service announcements and discovery • no single registration server ◦ avahi/zeroconf inspired