Trading Bitcoin

An Algorithmatic Way

Created by James Cai

Motivation 1

Traders recognize technical patterns to predict the market.

Motivation 2

Traders also look at the order book.


  1. Recognize current pattern
  2. Capture current order book feature
  3. Predict future price based on pattern and order book


  • I don't know what the patterns are.
  • So I use k-means to cluster the patterns.
  • Every price time series is a 57min long vector.
  • Throw them into k-means.

Patterns (K-Means Centers)

x unit: timestamp/30s y: CNY

A Single Pattern and Its Surrounding Instances

x unit: timestamp/30s y: CNY

Prediction Based on Pattern

  • In Training Data, For every cluster ci, there are ai instances, with average future price move pi
  • The probability that a given x belongs to a cluster is modeled as Gaussian.

Modeling the Order Book

  • vbid is the total volume of the highest 50 bids
  • vask is the total volume of the lowest 50 asks

Final Prediction