Tips On Getting Started In Python

Hi,
Ive been a professional trader for about a decade but feel in order to keep with the times I really need to make the effort and start exploring the world of algo trading. Its benefits are clear.
Ive built "systems" on CQG and Tradestation in the past but want to use a more universal language. Knowing a few guys in the algo/fund world Python seems to be the way forward.
...
Thanks
Has anyone used Python with real-time data, such as 5 second bars, NOT with Interactive Brokers, Bloomberg or Quantopian?

Have most people here used end-of-day data with Python?
 
I have written some programs to screen stocks. Nothing that would actually place a trade but rather just to sort data in a manner that any other service could not provide. I have written in Java, Python, Qt.

Java:
It's been a years since I have used Java. I found it to be slow and require too many try/catch statements. The pre-made packages are always limited so I decided to move on. Also at the time I looked at bench make times for program languages and Java turned out to be the slowest. Also it seams to change with every release which is pretty much annually and you end up updating your code.

Python:
Going back to when I last looked at bench mark times, Python was in the middle of the list. You can build code pretty fast. Again I found it to be to slow. Also the pre-made library Matplotlib, in my opinion makes ugly unlegible charts.

Qt (c++ pre-made library)
The best so far and by far. I find it fast, lighten fast in comparison to other languages hence it is c++ based which means you will have to get familiar with pointers and header files and other characteristics of the c++ language. According the the bench mark times it was the fastest and so far for me it is! I did have to do some thinking in some situations but it wasn't the bad. Great charts, lots of GUI objects and listeners are very easy to work with once you get the hang of connecting signal and slots. Qt creator allows you to build your program visually. Qt Creator is a light, fast, simple, ergonomic programming environment. End of the day, Qt is the best I have found as far as stand alone apps go.

At the end of the day as someone else had posted it all comes down to experience. I have been programming for 16 years now off and on pretty much for my own purposes. As you gain experience you'll learn what works best for which situation. Experience is the key no so much the language.
Are Python compilers generally optimizing worser to assembly and running worse than C/C++ (mingw , gcc , visual studio x64 etc) or it depend also on ways of coding?

I have 2-3 years of programming experience and have gotten best multithreaded C++ performance on linux, gcc compiler.
On windows compilers all appear to perform almost equal to eachother with single thread.
 
Last edited:
The lecturer forgot to mention another reason why the CIS dept at Stanford has more honor code and plagiarism violations than all other departments combined is to a large degree Asian students. Of course he cannot say that as political correctness is still the forte at US colleges. But truth be told students who come from HK or China and even Japan or Korea in majority have never heard the term honor code or thought of copying as cheating. Most can be blamed because they are intelligent enough to know, a few maybe can't be faulted. But fact is in China and other Asian countries as long as you get your A it does not matter how you came to it.

Sorry, unrelated to Python but as the posted lecture did not focus on Python but honor code I thought I wanted to inject this point. It equally pertains to trading and finance in general. There is so much blatant cheating going on in stock markets around the world and nobody really is competent enough out there to properly police it.

The only way to really learn how to be a good software engineer is through experience. Fortunately, there's not much that you really need to know to start writing software. So you could buy a book, but personally, I'd start here:


I recommend doing the homework assignments. There's probably some other lecture series that's Python specific.
 
Python:
Going back to when I last looked at bench mark times, Python was in the middle of the list. You can build code pretty fast. Again I found it to be to slow. Also the pre-made library Matplotlib, in my opinion makes ugly unlegible charts.

There are several Python graphics packages. Have you tried PyQtGraph? It is mentioned in "20 Python Libraries You Aren't Using (But Should)." It is also mentioned this podcast "Episode #77: 20 Python Libraries You Aren't Using (But Should)." It can be added in the Anaconda Python install.
 
I use it for both barred and true tick data, using transformed exchange data. Why do you ask?

I was wondering how many people are using real-time data outside of the standard broker client programs. I am under the impression most people access end-of-day data from free sources such as Yahoo or Google.

What is transformed exchange data? How much does it cost? If you don't mind me asking.
 
packages like this sound nice and are pleasing to the eye but when you actually get to the gist of it they are not applicable to a financial or trading application, at least not one that requires dynamic charting. If you want to know what I mean then take a look at this and how any Java, any C++, any Python charting library measures up to it: https://www.scichart.com/wpf-chart-examples/

Maybe not all applications require dynamic graphs or charting but when you do then I have never seen a library that comes even close to the C#/WPF library I linked to above. There is a reason more and more front-end applications in banks and hedge funds are coded in C# and use WPF/xaml for visuals.


There are several Python graphics packages. Have you tried PyQtGraph? It is mentioned in "20 Python Libraries You Aren't Using (But Should)." It is also mentioned this podcast "Episode #77: 20 Python Libraries You Aren't Using (But Should)." It can be added in the Anaconda Python install.
 
  • Like
Reactions: H2O
What is transformed exchange data? How much does it cost? If you don't mind me asking.
Raw ticks. I can tell you more via PM.

packages like this sound nice and are pleasing to the eye but when you actually get to the gist of it they are not applicable to a financial or trading application, at least not one that requires dynamic charting.
Python is very good for it. So, petty much any serious quant shop runs their R&D on python these days. There is really nothing like pandas out there. Matlab and R are close second, but the sheer horsepower that pandas+numpy deliver are unmatched. Plenty of people run live execution straight from Python too if they are using broker algos and they don't care for latency much.

At banks traders rarely program much, use BBG charts and have excel-based tools that they use for their analytics. It's ghetto, but it gives you flexibility and fast deployment time. C++ tools are usually risk viewers and all sort of execution engines.

This brings me to my main point. Traders job is to extract alpha, not write pretty widgets or charts. Unless you are sensitive to latency or have other performance issues, Python is more then enough.
 
I was not trying to suggest traders would be writing applications. IT departments at banks do, however. And I would claim every bank in the top 10 league tables provides traders with some applications that were written in-house either in Java or C#, or both. I am talking about front-end applications. And I only mention it because Python's charting libraries were brought up. Python lags badly behind in terms of visualization. Pending need and requirements this might be a non-issue or a deal breaker.

Raw ticks. I can tell you more via PM.


Python is very good for it. So, petty much any serious quant shop runs their R&D on python these days. There is really nothing like pandas out there. Matlab and R are close second, but the sheer horsepower that pandas+numpy deliver are unmatched. Plenty of people run live execution straight from Python too if they are using broker algos and they don't care for latency much.

At banks traders rarely program much, use BBG charts and have excel-based tools that they use for their analytics. It's ghetto, but it gives you flexibility and fast deployment time. C++ tools are usually risk viewers and all sort of execution engines.

This brings me to my main point. Traders job is to extract alpha, not write pretty widgets or charts. Unless you are sensitive to latency or have other performance issues, Python is more then enough.
 
And I would claim every bank in the top 10 league tables provides traders with some applications that were written in-house either in Java or C#, or both.
Yup, they do. In most cases it would be better if they did not :)
 
Back
Top