Skip to content

Instantly share code, notes, and snippets.

cmake_minimum_required(VERSION 3.16)
project(odr_test)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_executable(odr_test main.cpp)
add_library(odrl SHARED lib.cpp)
@halfelf
halfelf / garch11.cpp
Created May 5, 2020 07:23
GARCH(1, 1) MLE in C++
// Parameter estimation for GARCH(1,1) model
// Fitted to S&P500 index levels
// By Fabrice Douglas Rouah, 2009
// For Visual C++.Net Version 7.1
//#include "stdafx.h"
//using <mscorlib.dll>
#include <iostream>
#include <fstream>
#include <iomanip>
@halfelf
halfelf / completion.sh
Created July 2, 2019 02:21
case insensitive bash completion
# If ~/.inputrc doesn't exist yet: First include the original /etc/inputrc
# so it won't get overriden
if [ ! -a ~/.inputrc ]; then echo '$include /etc/inputrc' > ~/.inputrc; fi
# Add shell-option to ~/.inputrc to enable case-insensitive tab completion
echo 'set completion-ignore-case On' >> ~/.inputrc
# add option to /etc/inputrc to enable case-insensitive tab completion for all users
# echo 'set completion-ignore-case On' >> /etc/inputrc
@halfelf
halfelf / type_name.cpp
Created May 14, 2019 05:02
Get C++ type name
template <class T>
constexpr std::string_view type_name() {
#ifdef __clang__
std::string_view p = __PRETTY_FUNCTION__;
return std::string_view(p.data() + 34, p.size() - 34 - 1);
#elif defined(__GNUC__)
std::string_view p = __PRETTY_FUNCTION__;
# if __cplusplus < 201402
return std::string_view(p.data() + 36, p.size() - 36 - 1);
# else
@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

@halfelf
halfelf / ripgreprc
Created August 7, 2018 06:29
export $RIPGREP_CONFIG_PATH="$HOME/.ripgreprc"
--colors=line:fg:yellow
--colors=line:style:bold
--colors=path:fg:green
--colors=path:style:bold
--colors=match:fg:black
--colors=match:bg:yellow
--colors=match:style:nobold
--smart-case
@halfelf
halfelf / show_cron.sh
Created September 13, 2017 10:41
List crontab jobs.
#!/bin/bash
# System-wide crontab file and cron job directory. Change these for your system.
CRONTAB='/etc/crontab'
CRONDIR='/etc/cron.d'
# Single tab character. Annoyingly necessary.
tab=$(echo -en "\t")
# Given a stream of crontab lines, exclude non-cron job lines, replace
@halfelf
halfelf / my_configs.vim
Last active March 6, 2019 02:55
custom vim config for amix/vimrc
set pastetoggle=<F3>
set nu
"""""""""""""""""c/cpp/cu settings""""""""""""""""""""""""""""""""""
" check cpp code applying c++11 standard
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = '-std=c++14 -stdlib=libc++'
" on some system:
" let g:syntastic_cpp_compiler = 'g++'
# Find and then delete all files under current directory (.) that:
# 1. contains cmake (case-&insensitive) in it's path (wholename)
# 2. name is not CMakeLists.txt
find . -iwholename '*cmake*' -not -name CMakeLists.txt -delete
@halfelf
halfelf / reliable_word_count.clj
Created March 31, 2014 08:02
Reliable word count example for storm in Clojure. Note the `ack` and `fail` parts in spout.
(ns storm.starter.clj.word-count2
(:import [backtype.storm StormSubmitter LocalCluster])
(:use [backtype.storm clojure config log])
(:gen-class))
(def id-count (atom 0)) ;; tuple counter for debugging -- something to make ids out of
(defspout sentence-spout ["sentence"]
[conf context collector]
(let [sentences ["a little brown dog"