Live data from Hacker News

Introduction to Zipline: A Trading Library for Python

quantinsti.com

61–70 of 155 posts

Re: Introduction to Zipline: A Trading Library for Python

#61

Everybody's trading nowadays. How about just investing :-) I.e. focus on periods longer than a year, which so few people/professional market participants do. And on actual businesses instead of the crazy antics of a line. I wonder if you could use something like Zipline/Quantopian to screen huge amounts of consolidated balance sheets for markers of undervaluation. You could reject 1000s of companies and focus your “m…

> Everybody's trading nowadays.

Primarily the artifact of sustained positive returns recently and short-term memory. There used to be a saying: When your cab driver start giving you stock tips, it is time to bail out of market. When every Tom, Dick and Harry think they can beat the market, time to take a break.

> How about just investing :-)

This is the right way to go for majority of your portfolio. Follow simple, tried and test strategies - buy Index funds/ETFs for majority of your portfolio. Bogleheads Wiki https://www.bogleheads.org/wiki/Main_Page is a good starting point.

If you really interested in individual stock/investment picking, have a very small portion of your portfolio as play money for such endeavors.

> I wonder if you could use something like Zipline/Quantopian to screen huge amounts of consolidated balance sheets for markers of undervaluation. You could reject 1000s of companies and focus your “manual” vetting on the few that remain.

I primarily use similar methodology. Automated filtering of stocks to find a few that I want to review further. It is not scalable. Majority of time is spent on developing strategy for filtering and selecting the stocks for review. I most probably manually review 15-20 stocks a year (Reading SEC filings for the company and competitors, industry news, trade articles, analyzing financial statements, etc) and invest in 3-6 stocks a year at most.

Re: Introduction to Zipline: A Trading Library for Python

#62

For the past year I have been trying to learn more about trading, risk management, etc. There are so many stories about how the markets work and how to make money in them. You could spend your lifetime throwing money down a hole trying each one and probably do worse than random. I can't say enough good things about the perspective I have gained from just listening to good interviews of people that trade and manage fu…

Never trust stories about how to make money in the stock markets, unless said stories are told entirely in the past tense.

If someone really does have a successful trading strategy, the only way it makes economic sense to publish it is if they believe they can make more money by publishing it now (i.e. selling books, pageviews, whatever) than by using it to trade. Either that, or the algorithm is being described in sufficiently general terms that you're not actually given enough information to use it effectively.

Re: Introduction to Zipline: A Trading Library for Python

#63
post #20

Earlier quoted context omitted.

Agreed, HFT has become a catch-all term for anyone trying to make a marketing/political statement about trading. Like the term "big data" - it's been used to describe so many things that it no longer describes anything. Another thing that gets ignored is the the difference between a trading strategy and an execution algorithm.

I wish I could get some rest API and websockets into the debt and credit default swaps market, really inefficient markets that reveal a lot about sentiment don't need high frequency at all, just pretty average latency actually (for now anyway) IB probably has this, not sure though. But those data costs are a huge deterrent for me!

CDS and debt are not really inefficient markets. Some bonds are less liquid than others but there is currently a rapid conversion to electronic trading going on. CDS is also a very mature market. Not saying that those markets don't contain signal but they are not very inefficient.

Re: Introduction to Zipline: A Trading Library for Python

#64
post #52

I've typed and deleted this post a few times trying to find a way that it doesn't sound kind of pompous but if it helps save one person alot of money then screw it, I'll sound pompous.... I get asked quite a bit on how to start doing algorithmic trading and the first thing I always tell people is don't. I think I've said this many times now but the number of people who come at it with the thinking "I'm a computer sci…

Random idea, but what if you could combine market data with news articles, and (obviously only for the past few years) data from blogs/reddit/hn/twitter/etc.? Sometimes there is fascinating insight to be learned in obscure places on the Internet (hn itself being a great example); I imagine a system that would collect and analyze that kind of information would be quite interesting, despite the huge amount of noise. Su…

Been done tons of times. Some of them make quite a bit of money, others not. The real game-changer is if you're effective at separating out the real signal from the noise (and the noise floor is high in these sorts of feeds).

Re: Introduction to Zipline: A Trading Library for Python

#65

For the past year I have been trying to learn more about trading, risk management, etc. There are so many stories about how the markets work and how to make money in them. You could spend your lifetime throwing money down a hole trying each one and probably do worse than random. I can't say enough good things about the perspective I have gained from just listening to good interviews of people that trade and manage fu…

Never trust stories about how to make money in the stock markets, unless said stories are told entirely in the past tense. If someone really does have a successful trading strategy, the only way it makes economic sense to publish it is if they believe they can make more money by publishing it now (i.e. selling books, pageviews, whatever) than by using it to trade. Either that, or the algorithm is being described in s…

Couldn't agree more.

Re: Introduction to Zipline: A Trading Library for Python

#66

I've typed and deleted this post a few times trying to find a way that it doesn't sound kind of pompous but if it helps save one person alot of money then screw it, I'll sound pompous.... I get asked quite a bit on how to start doing algorithmic trading and the first thing I always tell people is don't. I think I've said this many times now but the number of people who come at it with the thinking "I'm a computer sci…

Disclaimer(s): QuantStart.com founder here, background as a quant dev at a small fund.

I should probably nuance my statement that it is easy to find trading strategies by saying that it is easy to find new trading /ideas/. There are a huge number of freely available trading ideas on forums, pre-print servers (arXiv, SSRN), blogs etc. The trick is knowing how to implement them properly, accounting for any transaction costs and adjusting the parameters of the model. This is often where the stated performance falls down. It takes a lot of time to carry out this sort of research.

Long-term profitable strategies are tricky to find, due to the ever-present spectre of "alpha decay". This is where your strategy's edge is "arb'd out" - everyone else knows what you're doing and so there's no tradeable edge anymore. Hence it is necessary to have a portfolio of strategies and gradually phase out the ones that aren't doing well, and bring in new ones over time.

That being said there are a large number of trend following funds (known as Commodity Trading Advisors, or CTAs, in the industry) that all broadly do the same thing (follow "trends" in the commodity futures markets) and have great years every now and then. There are some well-known "retail" quant traders who do well by trend following, but it does require quite a bit of capital to trade in futures.

The philosophy that I do try to emphasise is to always be learning and researching new ideas. Also, as you mention, I'm pretty keen on discussing the math(s)/statistics aspect because once you have a solid math capability, it is easier to see where potential edges might exist and how to really assess whether it is a true "edge" or just a statistical anomaly.

I believe someone else in a grandchild comment below said that there are many areas that bigger quant funds won't touch because of institutional incentives. If you have $10bn assets under management (AUM), then you're not going to care about investing $100-200k, even if the returns are good, because it won't move the needle on your monthly reports.

The trick is to niche down into markets that you can spend a lot of time researching to find a distinct edge, that won't likely be touched by bigger funds. One area that is becoming interesting recently, due to the prevalence of satellite data/AI/deep learning-esque VC-backed startups, is building commodity supply/demand models. A good example is forecasting oil supply/demand by analysing large quantities of storage tank heights in global refineries [1].

Also, a small related-to-Zipline plug: I've recently started a free Python-based MIT-licensed open-source backtester [2], predominantly as a learning tool for programming and quant trading. There's about 4-5 of us working on it at the moment and it's in an early alpha stage, but we're always looking for people willing to help.

[1] - https://orbitalinsight.com/solutions/ [2] - https://github.com/mhallsmoore/qstrader/

Re: Introduction to Zipline: A Trading Library for Python

#67
i just want to check my understanding of the algorithmic trading "world", so please do jump in.

Once upon a time (1986ish) the equities and bond trading world was run by humans talking to humans and agreeing deals, the prices then fed into computer systems and the exchanges passed the prices around to make things mostly fair.

Fair of course is relative, the Eco-system was very hierarchical, with major institutions at the top, trading between each other at low fees, with brokers feeding up into them and retail shops feeding into major brokers. The customer got a raw deal, being charged heavy fees per transaction, and getting a poor "spread".

Spread was where the major institutions made their money. Human traders effectively bought very low and sold very high - both because they were human and could not easily handle algorithms in their heads and because who was going to stop them? At the top of the hierarchy traders got to see both sides of every trade - they could net trades off one against the other to make deals with little risk. And if it was not visible in a fair exchange they had even more leverage.

Spreadsheets took off around now, making it possible for one trader to plan and monitor his trades and look really good to his boss.

And then it became obvious that having a human in the spreadsheet-to-trade loop was sub optimal. A human with a spreadsheet still needed to dial a phone, make a decision, go to the toilet. A perl script could out perform him.

And at the time the algorithms were simple. If Exxon's share price dropped then pretty obviously other oil companies would drop too, but so would say car company stocks, but maybe coal miner shares would go up. And that's just in LSE - the same goes for Hong Kong and Chicago. Those correlations I could work out in a perl script. (OK, 1980, maybe some Basic :-)

And so algo trading was feasible with really tiny hardware - because the correlations in the world markets were simple, and large. And so low latency trading started. Because if I can use my ZX spectrum of my Commodore 64 to beat major traders to the punch, then all you need is a faster computer than the commodore and you beat me to the punch. And so it goes.

Fast forward twenty years and

- the hierarchy of the past is mostly still in place. Retail shops pull in the customers money, pass it upwards to brokers and they deal with traders at large banks. However the traders are much reduced, the volumes they do are orders of magnitude larger now.

- the spread has gone. Major institutions make money on tiny margins and tiny fees and just do vast vast volumes. Major FX desks will make maybe 10 USD on a billion dollars of Eurodollar trades (I think).

- the spread has gone for the algo traders. The reason PhD's are needed is because the correlations and arbitrage is all eaten up. The wins are few and far between and mostly need real world events (Brexit)

- this is generally good, there is more trade on open exchanges (good for everyone) there is smaller spreads (good for customers). The break neck automation to a good for contractors like me :-)

I'm not sure where I am going with this to be honest - but mostly it's that I am sure zip line is a good library, that the core part is written in the way a proprietary engine would look if someone took a year to rewrite it, but the core tech will not give you any edge - that edge has gone. The correlations have gone except in esoteric areas.

If you want the edge, you need to be at the top of the tree again.

Re: Introduction to Zipline: A Trading Library for Python

#68

I've typed and deleted this post a few times trying to find a way that it doesn't sound kind of pompous but if it helps save one person alot of money then screw it, I'll sound pompous.... I get asked quite a bit on how to start doing algorithmic trading and the first thing I always tell people is don't. I think I've said this many times now but the number of people who come at it with the thinking "I'm a computer sci…

Can't find the original comment but somebody wrote here time ago that some HFs let you run on their infrastructure (keeping 85/90% of any profits) if you can prove to have a valid strategy. Just out of curiosity, I could not find any other information about this, is it a thing that actually happens?

There are places (like Quantopian, but also more professionally-oriented) that will not only provide infrastructure but also capital if you come to them with a trading algorithm that does well on back tests.

The next step down are firms that'll give you a platform including hardware and software for the "infrastructure" bits: often called an "algo container", but lots of brokers have an API you can use to avoid needing to write feed handlers, etc. eg. Pico.

Then there are heaps of providers who'll rent you servers, connectivity, rackspace, etc. You do all the software. Lucera is a trading-oriented "cloud" provider. OptionsIT or Fixnetics are infrastructure providers. Or you just go straight to the data centers -- any decent finance-oriented datacenter will have a POP for most of the venues, and you can just cross-connect.

No relationship with any of the firms named -- just examples off the top of my head.

Re: Introduction to Zipline: A Trading Library for Python

#69

Earlier quoted context omitted.

I wish I could get some rest API and websockets into the debt and credit default swaps market, really inefficient markets that reveal a lot about sentiment don't need high frequency at all, just pretty average latency actually (for now anyway) IB probably has this, not sure though. But those data costs are a huge deterrent for me!

CDS and debt are not really inefficient markets. Some bonds are less liquid than others but there is currently a rapid conversion to electronic trading going on. CDS is also a very mature market. Not saying that those markets don't contain signal but they are not very inefficient.

You're right, I would primarily like to see them more liquid so that there were more data points to extrapolate moves across different asset classes

Re: Introduction to Zipline: A Trading Library for Python

#70

I've typed and deleted this post a few times trying to find a way that it doesn't sound kind of pompous but if it helps save one person alot of money then screw it, I'll sound pompous.... I get asked quite a bit on how to start doing algorithmic trading and the first thing I always tell people is don't. I think I've said this many times now but the number of people who come at it with the thinking "I'm a computer sci…

I agree with you. I have spent my nights and weekends into trying to find an edge and am still looking. As a retail trader, it is very difficult to find anything but random data all over. I hope I will prove myself wrong someday, but as of now, I think a retail trader finding an edge is nearly impossible.
Post reply on HN