Skip to content

This is my personal repository for past coding experience. For employers, please see showcase files in readme. For crypto/algotraders, please let me know if my code helped you. :)

Notifications You must be signed in to change notification settings

tobby2002/portfolio-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Portfolio

Hello, I am Thor Kiessling and this is my showcase for real-world python implementations of machine learning and algorithmic trading. To get these scripts running rename api_keys_example.py to api_keys.py and input bitmex.com api keys, and download DB.sqlite and place it in the production folder. If you wish to recompile the Cython portions:

    python setup.py build_ext --inplace 

Employers

Bitmex sniper is a multi-threaded high performance python algorithmic trading script. It features switching between long term and short term business logic, C++ comparable execution time on latency-sensitive tasks, and integration with compiled Cython modules.

My primary example of network optimization is the websocket thread module that handles real-time concurrent state synchronization, serving data under load of bitmex's Level 2 orderbook (10-100 diffs/second) on the resources of an AWS t2.micro instance. It manages the exchange, orderbook, user balance, and user position state for the BitMEX class.

My fork of nicholasg3's motif matching extends the original by adding options for K-nearest neighbor matching and vastly speeds up execution time with Cython cdefs and compiling. Runtime improved from 41 seconds to .26 seconds when matching a 100 length sample to a 568k length timeseries. The optimization report shows how this was achieved, with the white sections of code inside loops converting to C without python protection/interaction.

Data visualization is essential to understanding what my code is doing. Scatter plots and histograms helped me to pinpoint trends, bugs, and other problems. Straightforward price and performance stats helped me decide which strategies to pursue or abandon. These images were generated by ucr classifier, a script to train the hyperparameters of a knn motif matching trading strategy.

alt text alt text

Machine Learning

Wavenet is a Google Deepmind project to iteratively generate realistic voice with a deep convolutional neural network. I adapted the technique to arbitrary time series and attempted to use the wave generator to predict price movements. Generator, trainer, and evaluator as a trade strategy. I was unsuccessful in producing a viable trading strategy but learned a lot about tensorflow internals.

Feature production and selection is essential in any data analysis. Feeding raw (or normalized) time series into almost every machine learning technique will result in failure, the time series must be transformed into actionable features. My module for doing this is based on ta-lib and is called build_ta_data It was able to grab random sections of the time series, run a full TA suite on that subsequence, and store the results. Later experiments included using an autoencoder to determine feature importances.

Algotrading

DB.sqlite contains all 1m OHLC data for XBTUSD in bmxswap, all funding history for XBTUSD in bmxfund, and an incomplete 1m OHLC for okcoin quarterlies.

Bitmex sniper incorporates all I have learned about the mechanics of algotrading, it reliably executes long term and short term positions with variable leverage options. I hope someone out there finds it useful to copy and modify or simply learn from. It was forked from bitmex's sample market maker. any files with _run.py are meant to be executed in production instead of the main file, providing restart on looping and Cython performance improvements.

The runlive script is designed to work with OKEX and does one of the best jobs I've seen of implementing their API. I advise against trading there as there are better futures options elsewhere and they frequently change their API without any documentation.

About

This is my personal repository for past coding experience. For employers, please see showcase files in readme. For crypto/algotraders, please let me know if my code helped you. :)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 83.0%
  • Python 16.1%
  • Other 0.9%