Discover your dream Career
For Recruiters

How to write Python trading algorithms, the secrets

Just because you want to break into the algorithmic trading space doesn't mean you have to use C++. Jane Street uses Ocaml, crypto firms use either Python or Java.

Python gets some disrespect from C++ purists in the space but definitely has its uses.

If you're a python afficionado looking to dip your toes into high frequency trading (HFT), be it solo or at a large firm, there are a number of ways you can make yourself either attractive to employers or effective in the space yourself.

In a recent webinar on algorithmic trading with python from crypto trading and analytics firm ProfitView, co-founder and former BofA quant Jahan Zahid went through the process of writing a trading algorithm and gave some tips and tricks along the way.

You should be using cubic spline

Oftentimes, market data can be quite scattered and hard to collate into meaningful patterns.  Zahid says you therefore need to take "little bits of data here and there, and you need to come up with a smooth surface".

A tool that can help with this is the cubic spline.

Cubic spline is a tool available in the python library SciPy (scientific python). Wolfram Mathworld defines it as "constructed of piecewise third-order polynomials which pass through a set of m control points."

When comparing the spline's results to his histogram data, Zahid said they fit together well and that "the nice thing about it is  we can take derivatives of that function."

Avoid the mistake of not looking at log-normal returns

If you're a total newcomer, this information might slide under the radar, but Zahid says "typically in-industry you look at log-normal returns."

Non-normal returns distribution is "a distribution of market performance data that doesn’t fit into the bell curve." according to Asymmetry Observations.

Zahid says, for example "if an asset goes up by 1% then down 1%, it does not return to the same value."

Ensuring you are using the correct data distribution can be the key to effectively implementing your trading strategies. If you're an entry level algo writer, this can also serve to indicate a knowledge of industry practices.

Using that information, Zahid says we should be able to "plot out 5, 10 or 30 minutes from now, what the distribution of returns will look like."

Get coding, simple as that.

Small tips and tricks are all well and good but getting in the right frame of mind can be a bit more difficult. In the case of coding trade algorithms, the best way to improve is simply by doing.

Zahid says "sometimes, the best way to learn is just to get to work and start coding."

Broadening your coding knowledge with tools like Jupyter Notebook can of course be helpful, but Zahid says that "if you’re an aspiring trader you’re gonna learn so much more by getting off Jupyter and getting on with writing code that actually trades.

Click here to create a profile on eFinancialCareers. Comment ANONYMOUSLY on articles and make yourself visible to recruiters hiring for top jobs in technology and finance. 

Have a confidential story, tip, or comment you’d like to share? Contact: in the first instance. 

Bear with us if you leave a comment at the bottom of this article: all our comments are moderated by human beings. Sometimes these humans might be asleep, or away from their desks, so it may take a while for your comment to appear. Eventually it will – unless it’s offensive or libelous (in which case it won’t.)

AUTHORAlex McMurray Reporter

Sign up to Morning Coffee!

Coffee mug

The essential daily roundup of news and analysis read by everyone from senior bankers and traders to new recruits.

Boost your career

Find thousands of job opportunities by signing up to eFinancialCareers today.
Recommended Articles
Recommended Jobs

Sign up to Morning Coffee!

Coffee mug

The essential daily roundup of news and analysis read by everyone from senior bankers and traders to new recruits.