Book simulations now allow for leverage and shorting

Hello,

You can now run Book Simulations with leverage and short exposure to assets.

We will be adding the same options to Live Books shortly, and additional documentation.

Let us know if you have any questions.

Thanks

10 Likes

PS. You might need to logout/login to get the latest version

2 Likes

Thanks a lot. That makes things much easier

Wow, thanks Marco! This is an incredibly useful feature.

Hit a couple snags:

  1. In the Rebalance tab, the relative weight gets re-assigned to 1 if I set it to 0. I would occassionally leave assets in the book with weight 0 as I was testing allocations, so it should be allowable.
  2. In the one book I tried, this on a (100/100 long short book), I get the following error when I try gross exposure of 2. Oddly enough, 1.9 and 2.1 and every other value I’ve tried so far works fine.
    The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is > incorrect. Parameter 7 (""): The supplied value is not a valid instance of data type float. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision.
  3. It’s a cosmetic issue, but it should report a Net Exposure of 0 (instead of 2) when running a Gross Exposure of 2 of a 100% long leg and a 100% short leg.

Thanks!

These levered long short curves really show the potential of a long short if there was some sort of a (conservative estimate of a) borrowing cost available.

Below a long short system where the short side shorts 50 stocks, excludes the top 50% of stocks with the highest short interest to float, the bottom 50% of institutional ownership and the stocks with a median dollar volume below 500k. 10% margin carry cost. 140% exposure of which 40% short.

@feldy

  1. good suggestion.
  2. we are investigating.
  3. not seeing this behavior

Since a book sim does not look at individual holdings of an asset (it only uses the equity curve of the assets), what do you suggest?

In the general tab we have a fixed slippage % but that only applies to the transaction amount.

Perhaps just add another setting for margin cost in %?

1 Like

I would suggest for all margin (books and sims) that there be an option to mimic IB’s margin cost which is (Bennchmark + 1%) or something like that. Should be easy to pull in Fed Funds and adjust from there.

2 Likes

Create a book with a long strategy and a short strategy, both with weights of +1. The book will report having net exposure of 2. This is hard to get right in the general case where the book could be directly holding inverse or levered ETFs, but right now now it’s just computing net exposure based on book asset weights. It could be smarter than just assuming p123 strategies as 100% long exposure strategies since the system knows their leverage and direction.

Nice!! Thank you Marco!!

Super excited. Now I don’t have to code this by hand into excel and load it into a 3rd party platform for reporting! This is fantastic and will save me huge amounts of time.

1 Like

Right. The new implementation only looks at the time series of the asset. Does not look deeper if the asset is leveraged , in cash, or short. In other words with the new Book Sim you should only use long assets that are 100% invested. You "short asset" should therefore have a negative weight but the underlying simulation should just be a plain vanilla long simulation.

We simplified because the old code had to be discarded. It kind of worked, but was thrown off in certain cases, and was just generally poorly written. Consider this v1.0 of the new Book Sim that only supports using long simulations that are 100% invested. Weights should then be used for leverage and shorting.

Sorry about this. I think we need to add restrictions so only long, 100% invested strategies are allowed, otherwise it will be too confusing.

Please don’t restrict it. I set long 100% and short 50% and gross at 1.5x. And it works as expected. Could it be refined? Yes. But this saves me so much time for now so pretty please not restrict it to long only.

For item #2 try 2.0 as it looks from the message that it is expecting a decimal (floating point) instead of an integer (2).

Cheers,

Rich

Totally agree, please do not remove the short functionality. It works and is way more functional than before. What I was reporting was purely cosmetic, nothing functional.

Now we still need to be able to vary the weights according to a formula.

Just a warning: the way it works right now, if you short an asset, the book inverts the equity curve. So if an asset incurs transaction costs or margin interest, as most simulations will, in the book those will become earnings rather than costs. Obviously, this isn't what you want. Portfolio123 will be correcting this in due course, but I wanted to give people a head's up about it now. If your short asset is a stock or an ETF it'll work fine as is. If you want to short a simulation (i.e. give it a negative allocation), then you should run the simulation with negative fixed slippage first.

1 Like

Errors should be fixed.

Regarding using long sims with negative weights, @yuvaltaylor is correct: the transaction costs would inflate the results. The proper way when using a long simulation with negative weight is to re-run it using a negative slippage. You can use even larger negative slippage to account for borrow costs.

We'll add some extra logic so that long simulations used with negative weights be required to have a negative slippage. This way there's no way to mess this up.

PS: currently there's no way to specify a negative variable slippage. You need to switch to fixed slippage and enter a negative number

What would a reasonable negative slippage value be to account for borrowing costs?

That depends entirely on your broker. Borrowing costs vary hugely from broker to broker. Some brokers will actually pay you when you borrow some stocks (often the short credit interest rate will be higher than the borrowing costs--for example, see the note at the bottom of this article: https://www.interactivebrokers.com/campus/traders-insight/securities/short-selling/the-risks-of-shorting-series-part-ii-borrow-fees/). Others will charge you an arm and a leg. Yet others will let you borrow most stocks free. Years ago I compared the borrowing costs of various stocks between IBKR and Fidelity and couldn't find any commonality at all; now I'm using Pershing for my hedge fund, and the rates are completely different.

Yuval thank you for your advice.

Using the same sim with 50% positive and negative allocations gives a net exposure=0. Slippage for negative exposure set at -1% and for positive exposure at 0.1%. The book then shows an annualized return of -1.83%. Most of this would be due to the cost of borrowing the ETFs for the shorts. Is that realistic?

If the short credit interest rate was 1.83% you would be borrowing stocks at no cost for the particular slippage settings of the sims.