quantopian / zipline

Zipline, a Pythonic Algorithmic Trading Library
https://www.zipline.io
Apache License 2.0
17.73k stars 4.74k forks source link

Liquidity for ETFs, CEFs. I would suggest relaxing at least 5-20x liquidity requirements for them. #1925

Open dmicsa opened 7 years ago

dmicsa commented 7 years ago

Dear Zipline Maintainers,

Before I tell you about my issue, let me describe my environment:

Environment

Now that you know a little about me, let me tell you about the issue I am having:

Description of Issue

ETFs have a very different way of generating liquidity in case of demand. I arrive on a simulation to try to buy $5M on over $1B traded per day ETF (XLF) and it didn't fill the order. In my opinion, this is not acceptable. This a trade that will fill w/o problem w/o significant slippage in less than 10 seconds in reality.

As an example, I bought many times 3x the average dollar amount of an ETF or CEF instant w/o any slippage. The provider of the product just created extra shares on demand. Of course, if I would never be able to do something similar for a stock not even for a 50 times smaller order.

I would suggest relaxing at least 5-20x liquidity requirements for ETFs/CEFs. I know they have various and complex ways of creating liquidity but relaxing in bulk would make more good than harm.

What steps have you taken to resolve this already?

I try to replace the ETF with its major components but that's 10x the code size and 20x time slower using the pipeline, filters, etc.

Sincerely, Dan

dmicsa commented 7 years ago

Regarding slippage

This is a formula that tries to replicate pretty realist the slippage for a trade done automatic. StockSlippage = 0.05 + 0.2 / (AvgDailyLiquidityForLast10Bars / 1,000,000 ^ .7) + 1. / Price

Some example:

Price\MegaVol 0.125 0.25 0.5 1 2 4 0.125 8.08% 8.06% 8.06% 8.05% 8.05% 8.05% 0.25 4.08% 4.06% 4.06% 4.05% 4.05% 4.05% 0.5 2.08% 2.06% 2.06% 2.05% 2.05% 2.05% 1 1.08% 1.06% 1.06% 1.05% 1.05% 1.05% 2 0.58% 0.56% 0.56% 0.55% 0.55% 0.55% 4 0.33% 0.31% 0.31% 0.30% 0.30% 0.30% 8 0.20% 0.19% 0.18% 0.18% 0.18% 0.18% 16 0.14% 0.13% 0.12% 0.12% 0.11% 0.11% 32 0.11% 0.09% 0.09% 0.08% 0.08% 0.08% 64 0.09% 0.08% 0.07% 0.07% 0.07% 0.07% 128 0.08% 0.07% 0.06% 0.06% 0.06% 0.06% 256 0.08% 0.07% 0.06% 0.06% 0.06% 0.05% 512 0.08% 0.06% 0.06% 0.06% 0.05% 0.05% 1024 0.08% 0.06% 0.06% 0.05% 0.05% 0.05%

Slippage for ETFs should not be computed like the one for stocks. ETFs have special ways of being created by demand by the provider and should be around 0.05%-0.15% according to with price and volume.

The main formula for stock can be used dividing at least with 10(!) and eventually bounded in [0.05%. 0.15%]

ETFSlippage = Bound(StockSlippage / 10, 0.0005, 0.0015)

After applying the slippage the trade should execute 100% of the time.