HN user

twiecki

383 karma

SciPythonista interested in computational psychiatry, algorithmic trading and Bayesian modeling. @twiecki

Posts23
Comments17
View on HN
www.pymc-labs.com 1y ago

AI MMM Agent: Bayesian Marketing Mix Insights

twiecki
2pts1
www.pymc-labs.io 4y ago

Bayes is slow? Speeding up HelloFresh's Bayesian AB tests by 60x

twiecki
2pts0
www.pymc-labs.io 5y ago

Saving the World with Bayesian Modeling

twiecki
31pts4
twiecki.github.io 7y ago

Hierarchical Bayesian Neural Networks with Informative Priors

twiecki
2pts0
twiecki.github.io 8y ago

An intuitive, visual guide to copulas

twiecki
2pts0
pymc-devs.github.io 9y ago

PyMC3 – Probabilistic Programming and Bayesian Machine Learning in Python

twiecki
5pts0
twiecki.github.io 10y ago

Bayesian Deep Learning

twiecki
7pts3
blog.quantopian.com 10y ago

Show HN: Pyfolio – a Python library for financial performance and risk analysis

twiecki
2pts0
jsalvatier.wordpress.com 11y ago

PyMC3 beta released. A new probabilistic programming framework for Python

twiecki
4pts1
blog.quantopian.com 11y ago

The Problem with Data Science

twiecki
4pts0
twiecki.github.io 11y ago

Probabilistic Programming in Quant Finance using PyMC3

twiecki
1pts0
twiecki.github.io 11y ago

A modern guide to getting started with Data Science and Python

twiecki
1pts0
pando.com 11y ago

Calling all quants: crowd-sourced hedge fund

twiecki
12pts0
twiecki.github.io 12y ago

Probabilistic Programming in Python

twiecki
2pts0
pando.com 12y ago

Quantopian enters open beta, reports $100M in customer trading volume

twiecki
9pts0
twiecki.github.io 12y ago

The Best Of Both Worlds: Hierarchical Linear Regression in PyMC3

twiecki
4pts0
blog.quantopian.com 12y ago

Real money, invested with algorithms

twiecki
165pts136
twiecki.github.io 12y ago

Easily distributing a parallel IPython Notebook on a cluster

twiecki
1pts0
twiecki.github.io 12y ago

Visualizing MCMC with PyMC and Matplotlib

twiecki
1pts0
www.quantopian.com 13y ago

Using Wikipedia page view counts to predict market movements.

twiecki
6pts4
www.quantopian.com 13y ago

Google Search Terms predict market movements

twiecki
58pts15
blog.quantopian.com 13y ago

Parameter Optimization with Zipline, PiCloud, StarCluster, and IPython Parallel

twiecki
21pts1
twiecki.github.com 13y ago

Show HN: Optimized trading algorithms using IPython parallel and ec2

twiecki
102pts28

There are packages that are just Python libraries, like PyMC3: http://pymc-devs.github.io/pymc3/ It allows you to specify a Probabilistic Program with a few lines of Python code (x ~ Normal(0, 1) becomes x = pymc3.Normal('x', 0, 1)) and then run automatic inference on whatever model you dream up, it's very powerful. I always found the approach of inventing a new language to specify Probabilistic Programs like Stan does a bit odd. There, you specify the model as a string and can't interact with it or debug if something goes wrong. Disclaimer: I'm a PyMC3 developer.

I don't think it has to be either or. For example, you can implement a Deep Net in a probabilistic programming framework (http://twiecki.github.io/blog/2016/07/05/bayesian-deep-learn...) like PyMC3. The inference here is not using sampling but rather ADVI (http://pymc-devs.github.io/pymc3/api.html#advi) which is almost as general but much much faster, and can be run on sub-samples of the data (similar to stochastic gradient descent used in deep learning). Once we bridge these two domains we can get the best of both worlds, like a deep net HMM.

PyMC3 (http://pymc-devs.github.io/pymc3/) has all the powerful samplers that Stan has (i.e. NUTS) as well as support for discrete priors. It allows you to specify your models in pure Python, supports matrix algebra, and also has variational inference which allows for large-ish scale machine learning (e.g. here is a blog post where I train a Bayesian Neural Net on MNIST http://twiecki.github.io/blog/2016/07/05/bayesian-deep-learn...). Under the hood, it uses theano for JIT compilation to C or GPU.

I'm one of the core devs.

Thanks for your comment! I did split the data in two, but it's easy to miss. X_test and X_train are the two sets. ann_input.set_value(X_test) then switches in the test values. That's identical to running make_moons() again.

If you're interested: http://pymc-devs.github.io/pymc3/

PyMC3 uses Theano to create a compute graph of the model which then gets compiled to C. Moreover, it gives us the gradient for free so that HMC and NUTS can be used which work models of high complexity.

I use it in production, despite it still being beta. We're close to the first stable release but there are still some small kinks to figure out.

Disclaimer: I'm a co-developer.

Also, this is not your standard dual moving average cross-over strategy. Rather, it rebalances its portfolio (optimally) under the assumption that the stocks will revert to their moving average. The eps parameter, which I explored in this talk, influences how aggressively the algo rebalances its portfolio -- smaller values will result in a more stable, conservative strategy.

Certainly that's always a risk. Zipline does however support simulating transaction-costs and slippage so those will be accounted for (as best as possible).

As for market-paradigm shifts, I totally agree. One way to deal with that is to constantly re-optimize the parameters based on recent data. This is also known as walk-forward optimization on which there is a slide at the very end (see http://blog.quantopian.com/parameter-optimization/ for a more information).

Finally, as to running multiple strategies with different parameter settings. The OLMAR paper that describes the algorithm (http://arxiv.org/abs/1206.4626) has a variation of this where they use a range of different-length moving averages, rather than just one.

That's currently not implemented, but definitely something we would like include. What I'd really like to see is a client for a bitcoin exchange. See our contribution request page for more details: https://github.com/quantopian/zipline/wiki/Contribution-Requ...

Finally, live trading is something which we are working on to enable on Quantopian (which uses zipline for backtesting your algorithms). The syntax is very similar so you could just convert your zipline strategy to Quantopian (which is free to use).