Skip to content

Instantly share code, notes, and snippets.

@wheng3
wheng3 / gist:67b2dff732816744d8e69e5e754b673a
Created February 26, 2020 09:22
Market basket analysis
high support: should apply to a large amount of cases
high confidence: should be correct often
high lift: indicates it is not just a coincidence
@wheng3
wheng3 / gist:14b554ac1c8851639b7d2f4b2accfdab
Created January 7, 2020 03:09
VSCode multiple cursors trick
Press CTRL + A to select all of the text
Press SHIFT + ALT + I to insert multiple cursors at the end of each line
Press Home twice to jump to the start of every line
@wheng3
wheng3 / gist:d47b505e86920e0bc3c2b779c4bf5fa6
Created November 29, 2019 06:34
Typical workflow for building a trading algorithm
Data collection
-> Data preprocessing and cleaning
-> Feature construction
-> Model training
-> Backtesting
-> Live trading
@wheng3
wheng3 / gist:0113138b649b711d842adf2e804afc2a
Created November 27, 2019 03:47
The Dollar Milkshake Theory
Dollar Milkshake
The algos and carbon fx traders are probably gauging right now whether the Dollar Milkshake trade is over, in view of the Fed’s patience to pull the reins of its normalization policy
So, firstly let’s zero in on the Dollar Milkshake trade theory, no doubt a current hot topic in the forex market with an average daily turnover of approximately 5.35 trillion USD a day.
The crux of the Dollar Milkshake theory put forward by Brent Johnson CEO of Santiago Capital is based on the dollar strengthening and the fallout that could have on global markets
Dollar Milkshake theory sounds yummy and jolly but do not be fooled, “this is a story that ends very, very badly,” said Brent Johnson in his interview.
So Dollar Milkshake theory predicts a bull market in USD, which has been underway for some time, but it comes with a caveat.
@wheng3
wheng3 / gist:f25c40711a039a2687487ba4b2a76cd3
Last active October 31, 2019 09:34
General backtracking solution
Pick a starting point.
while(Problem is not solved)
For each path from the starting point.
check if selected path is safe, if yes select it
and make recursive call to rest of the problem
before which undo the current move.
End For
If none of the move works out, return false, NO SOLUTON.
More comprehensive and common backtracking formulas:
@wheng3
wheng3 / gist:4c16a22f2a2dab1dfb201915867b7133
Created October 23, 2019 03:16
TRADING SYSTEMS: The Seven Deadly Sins of Automated Trading
TRADING SYSTEMS: The Seven Deadly Sins of Automated Trading
by Sam Berry, CEO, Littlefish FX
In my last article published in FX Trader Magazine “Revolutionize the way you trade”, I covered some thoughts on the FX industry as a good investment and what we look for. As part of that I mentioned the seven deadly sins of strategy development and so I thought it would be a good subject to expand on and provide you with the laws we abide by.
Don’t rely on back tests – what you need are out of sample forward tests
My team and I can easily generate a system that uses 1:1 leverage and returns 100% per month in a back test with almost no draw down. I can also guarantee that if we ever turned that system on it would at best remain flat in its performance.

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@wheng3
wheng3 / gist:1530fa3b2c68c625b736e6854939886c
Last active October 21, 2019 04:57
Leetcode thinking directions
A search in a sorted collection, think binary search.
Minimum # of steps, think BFS.
Min/max K elements, think heap.
Optimization, think DP.
Combinations, think backtracking and DFS.
@wheng3
wheng3 / gist:700c92bf77bcbef9e50d96378bb7edd8
Last active October 15, 2019 06:05
Priority Queue and Heap
A priority queue is different from a "normal" queue, because instead of being a "first-in-first-out" data structure, values come out in order by priority.
A heap is a binary tree (in which each node contains a Comparable key value), with two special properties:
The ORDER property:
For every node n, the value in n is greater than or equal to the values in its children (and thus is also greater than or equal to all of the values in its subtrees).
The SHAPE property:
All leaves are either at depth d or d-1 (for some value d).
All of the leaves at depth d-1 are to the right of the leaves at depth d.
@wheng3
wheng3 / gist:1d9c2492dbad991ae580513784391cfd
Created October 9, 2019 07:09
Linear Programming: Simplex Algorithm
We convert the system of inequalities into system of equalities and then use Gaussian elimination with clever pivot selections.