Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Leverage Issue

Hi,

I am having a strange issue debugging leverage exceeding 1. I'm not sure why as I my only ordering_percent methods always sum to 1, meaning leverage should be very close to 1.

2 responses

Fixed. A few of the orders were order_target rather than order_target_percent.

Also probably a typo where I think you meant context.tlt = symbol('TLT')

Here you can see the orders happening. Notice cash went quite a ways into margin sometimes.

2011-06-13 06:36 _trac:82 INFO    6      Sold -330/-399 TLT (469) at 96.70  (+59)           -6729  f226  
2011-06-13 06:36 _trac:82 INFO    6      Bot 302 SPY (453) at 127.98                        -6729  12cb  
2011-07-13 06:36 _trac:82 INFO    6      Sold -1714/-3473 TLT (4950) at 96.75  (+712)       -170754  2b90  
2011-07-13 06:36 _trac:82 INFO    6      Bot 2537 SPY (-1607) at 132.26  (-82)              -170754  71ed  

On line 92 there's a small change you can make to log just beyond a negative cash threshold for less scrolling.

Try placing a breakpoint after that line by clicking a line number and then run it. Takes longer to run. Patience.
Looking around (by typing), that might help figure out what's going on. For example, SPY was short 493 on this date.

> c.portfolio.cash  
    float: -47809.652924  
> context.portfolio.positions[context.spy].amount  
    -493  
> context.portfolio.positions[context.tlt].amount  
    2426  
> c.portfolio.portfolio_value  
    float: 108123.727076  
> get_datetime()  
    Timestamp: 2011-02-23 14:36:00+00:00