Skip to content

Instantly share code, notes, and snippets.

@halfelf
halfelf / how_to_build_a_fast_limit_order_book.md
Created February 11, 2019 02:18
How to Build a Fast Limit Order Book

https://web.archive.org/web/20110219163448/http://howtohft.wordpress.com/2011/02/15/how-to-build-a-fast-limit-order-book/

The response to my first few posts has been much larger than I’d imagined and I’d like to thank everyone for the encouragement.

If you’re interested in building a trading system I recommend first reading my previous post on general ideas to keep in mind.

My first really technical post will be on how to build a limit order book, probably the single most important component of a trading system. Because the data structure chosen to represent the limit order book will be the primary source of market information for trading models, it is important to make it both absolutely correct and extremely fast.

To give some idea of the data volumes, the Nasdaq TotalView ITCH feed, which is every event in every instrument traded on the Nasdaq, can have data rates of 20+ gigabytes/day with spikes of 3 megabytes/second or more. The individual messages average about 20 bytes each so this means handling

@yannvanhalewyn
yannvanhalewyn / build.boot
Last active December 13, 2017 17:37
Boot node cljs repl
(set-env!
:target-path "target"
:source-paths #{"src"}
:dependencies '[[org.clojure/clojure "1.9.0-RC1"]
[org.clojure/clojurescript "1.9.946"]
[figwheel-sidecar "0.5.14"]])
(require '[figwheel-sidecar.repl-api :as ra])
(deftask cljs-repl []
@purcell
purcell / code-font-user-styles.css
Last active October 22, 2020 22:55
User styles for coding fonts on sites with lots of code
@-moz-document domain("github.com"), domain("gist.github.com") {
tt, code, pre, .file-data pre, textarea, .blob-line-code, .blob-code, .blob-code-inner, .diff-line-code {
font-family: "Iosevka Fixed SS08", "Iosevka Fixed", "Iosevka Term", "Iosevka", "Input Mono Condensed", "PragmataPro", "Ubuntu Mono", "Menlo";
font-weight: 400;
}
}
@-moz-document domain("gitlab.com") {
tt, code, pre, textarea, .code, .file-content.code pre code {
font-family: "Iosevka Fixed SS08", "Iosevka Fixed", "Iosevka Term", "Iosevka", "Input Mono Condensed", "PragmataPro", "Ubuntu Mono", "Menlo";
@stuarthalloway
stuarthalloway / clojure_spec_missing_piece.clj
Created March 17, 2017 01:11
Clojure spec's missing piece
;; clojure.spec's missing piece, work in progress
;; this is only halfway done, somebody else will need to do the other 95%
(require
'[clojure.spec :as s]
'[clojure.spec.test :as test])
(defn naive-english-explain
"Copy and paste this into your app. Figure out what it does by
trying it in production."
@reborg
reborg / rich-already-answered-that.md
Last active July 11, 2024 09:54
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

@favila
favila / entity-changes.clj
Last active October 16, 2019 13:14
enity-changes Return transaction history for a datomic entity and its components.
(require '[datomic.api :as d])
(defn entity-changes
"Return transaction history for an entity and its components.
Returns a sequence of maps, each is the transaction map (tx metadata) plus a
key `:entity-changes`, which is a nested map of keys: entity id, attribute
ident, `:db/add` or `:db/retract`, and the value added or retracted, e.g.:
{12345678910 {:long-card-1-attr {:db/retract 1
:db/add 0}
:long-card-many-attr {:db/add #{0}}
@alandipert
alandipert / ec2query.boot
Last active July 31, 2018 16:33
Example of querying AWS infrastructure with Amazonica and Datomic, in Clojure with Boot-clj
#!/usr/bin/env boot
;; or `BOOT_FILE=ec2query.boot boot repl' for interactive use
(set-env! :dependencies '[[amazonica "0.3.23"]
[com.datomic/datomic-free "0.9.5344"]])
(require '[amazonica.aws.ec2 :as ec2]
'[amazonica.core :refer [defcredential]]
'[boot.cli :refer [defclifn]]
'[boot.util :refer [info]]
@nijikokun
nijikokun / about.md
Last active January 24, 2024 08:48
Cool ways to Diff two HTTP Requests in your terminal!

Basic diffing

  • Line by line
  • No colors
  • Able to be piped into vim (shown later on)
diff <(curl -vs https://reddit.com 2>&1) <(curl -vs https://reddit.com 2>&1)
@ohpauleez
ohpauleez / debugrepl.clj
Last active August 29, 2015 14:17
Another debug repl
;; Simpler debug-repl based on https://github.com/stuarthalloway/circumspec/blob/master/src/clojure/contrib/debug.clj
;; This `debug-repl` also tries to capture line metadata from forms/files, as well as exceptions
;; Some people may want to rename `debug-repl` to `break`, and `quit-dr` to `continue`
(defmacro local-bindings
"Produces a map of the names of local bindings to their values."
[]
(let [symbols (map key @clojure.lang.Compiler/LOCAL_ENV)]
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols)))
@tonsky
tonsky / .profile.boot
Created March 2, 2015 20:14
boot-clj plugin to report build status to AnyBar
(defn- send-udp [s port]
(with-open [socket (java.net.DatagramSocket.)]
(let [group (java.net.InetAddress/getByName "localhost")
bytes (.getBytes s)
packet (java.net.DatagramPacket. bytes (count bytes) group port)]
(.send socket packet)
(.close socket))))
(deftask anybar [p port VAL int "AnyBar port"]
(let [port (or port 1738)]