PyThalesians – Open Source Financial Library

PyThalesians is a Python financial library developed by the Thalesians ( I have used the library to develop my own trading strategies and I’ve included simple samples which show some of the functionality including an FX trend following model and other bits of financial analysis.

There are many open source Python libraries for making trading strategies around! However, I’ve developed this one to be as flexible as possible in terms of what types of strategies you can develop with it. In addition, a lot of the library can be used to analyse and plot financial data for broader based analysis, of the type that I’ve had to face being in markets over the years. Hence, it can be used by a wider array of users.

At present the PyThalesians offers:

  • Backtesting of systematic trading strategies for cash markets (including cross sectional style trading strategies)
  • Sensitivity analysis for systematic trading strategies parameters
  • Seamless historic data downloading from Bloomberg (requires licence), Yahoo, Quandl, Dukascopy and other market data sources
  • Produces beautiful line plots with PyThalesians wrapper (via Matplotlib), Plotly (via cufflinks) and a simple wrapper for Bokeh
  • Analyse seasonality analysis of markets
  • Calculates some technical indicators and gives trading signals based on these
  • Helper functions built on top of Pandas
  • Automatic tweeting of charts
  • And much more!
  • Please bear in mind at present PyThalesians is currently a highly experimental alpha project and isn’t yet fully documented
  • Uses Apache 2.0 licence


pytrader is a cryptocurrency trading robot that uses machine learning to predict price movements at confidence intervals, and sometimes execute trades. It is programmed to work on the cryptocurrency platform.

Prettymuch, this:

I (@owocki) built this as a side project in January / February 2016, as a practical means of getting some experience with machine learning, quantitative finance, and of course hopefully making some profit ;).

3/26/2016 – My test portfolio was initialized with a 1 BTC deposit, and after 2 months and 23,413 trades, exited with 0.955 BTC. The system paid 2.486 BTC in fees to poloniex. CALL TO ACTION — Get this trader to profitability. A strategy is being fleshed out here.

Stock Price Prediction With Big Data and Machine Learning

“This post is based on Modeling high-frequency limit order book dynamics with support vector machines paper. Roughly speaking I’m implementing ideas introduced in this paper in scala with Spark and Spark MLLib. Authors are using sampling, I’m going to use full order log from NYSE (sample data is available from NYSE FTP), just because I can easily do it with Spark. Instead of using SVM, I’m going to use Decision Tree algorithm for classification, because in Spark MLLib it supports multiclass classification out of the box…”

Intro to Technical Analysis

“Looking back over this “Intro to Technical Analysis” series I have tried to cover a wide range of topics related to technical analysis without getting to deep into its complexities. Here is a list of the things we have covered…”

Probability Tutorials

These tutorials are designed as a set of simple exercises, leading gradually to the establishment of deeper results. Proved Theorems, as well as clear Definitions are spelt out for future reference. (An alphabetical index A|B|C|D … should also be helpful.) Contrary to standard university lectures or textbooks, these tutorials do not contain any formal proof: instead,they will offer you the means of proving everything yourself. However, for those who need more help, Solutions to exercises are provided, and can be downloaded in A4 paper format from the Printing  page…”


How I made $500k with machine learning and HFT (high frequency trading)

“This post will detail what I did to make approx. 500k from high frequency trading from 2009 to 2010. Since I was trading completely independently and am no longer running my program I’m happy to tell all. My trading was mostly in Russel 2000 and DAX futures contracts.

The key to my success, I believe, was not in a sophisticated financial equation but rather in the overall algorithm design which tied together many simple components and used machine learning to optimize for maximum profitability. You won’t need to know any sophisticated terminology here because when I setup my program it was all based on intuition. (Andrew Ng’s amazing machine learning course was not yet available – btw if you click that link you’ll be taken to my current project: CourseTalk, a review site for MOOCs)

First, I just want to demonstrate that my success was not simply the result of luck. My program made 1000-4000 trades per day (half long, half short) and never got into positions of more than a few contracts at a time. This meant the random luck from any one particular trade averaged out pretty fast. The result was I never lost more than $2000 in one day and never had a losing month…”

Learning Q KDB+

“This page lists the sites that I use to learn Q. I will be updating it as I explore more.

1) Q for Mortals by Jeffry A. Borror is the primer for learning Q. A tutorial page is provide in kx systems website. This book contains all the basic syntax and knowledge that is needed for a rampup.

2) A reference page containing all the functions is quite useful and handy while coding.

3) KDB+ for mortals which I consider the second level after having read Q for Mortals describes the database aspects. It helps you understand how the data is stored in partitions and how kdb uses map reduce to speed up your queries internally. In short, it helps you visualize the HDB. Some specific links handy in this regard are dotQ Utilities, pardottxt , tplog file and chained tickerplants.

4) Q Idioms contains code snippets and is useful for getting accustomed to style of coding in Q.

5) The cookbook contains lots of applications of Q/KDB+

6) Callbacks in Q…”

High Frequency Trading – What’s broken and how to fix it

“In previous posts, I discussed the basic mechanics and social utility of high frequency trading. Of particular import is that I characterized the latency arms race as socially wasteful. Now I’ll discuss a policy proposal which might mitigate the harmful effects of the race for latency, while giving better prices to speculators…”

A High Frequency Trader’s Apology

“I’m a former high frequency trader. And following the tradition of G.H. Hardy, I feel the need to make an apology for my former profession. Not an apology in the sense of a request for forgiveness of wrongs performed, but merely an intellectual justification of a field which is often misunderstood.

In this blog post, I’ll attempt to explain the basics of how high frequency trading works and why traders attempt to improve their latency. In future blog posts, I’ll attempt to justify the social value of HFT (under some circumstances), and describe other circumstances under which it is not very useful. Eventually I’ll even put forward a policy prescription which I believe could cause HFT to focus primarily on socially valuable activities…”

“In the previous post, I explained that HFT’s usually make their money by running market making strategies. Consider a market with two market makers, Leela and Bender, as well as two speculators, Fry and Zoidberg. Fry bought shares of MomCorp one year ago when the price was $5.00 and wants to cash out. Zoidberg thinks MomCorp is a good buy and wants to get into the market…”