Back to Community
The returns are somewhat unexpected

This algo needs to be optimised so as to eliminate the excessive draw down, I don't believe it would survive live trading otherwise. I am curious to see the results on other commodities. What sort of results are others getting with this template?

Clone Algorithm
19
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 55ad36c05214020c67050631
There was a runtime error.
3 responses

The first transaction buys $300,000,000 in securities. Something tells me 300,000x leverage isn't allowed (anywhere I know of at least).

Hi Spencer. firstly, I don't see this transaction, or what you speak of in the data set...the first purchase is for 100k, I don't think that this equates to the amount of leverage you mention...1lot on average is is 100,000units, and the requirement for the CFD component (difference) in pips requires around [email protected]$200.34. I did a lot calculation on the largest holdings, an it worked out to be around 70 lots, when the account was at $868,122,178.28

SPY
$200.70 qty 6,980,000 Note: /100,000 = 69.8 lots

Position $1,400,886,000.00 Gains $483,965,280.00
Cash ($868,122,178.28)
- -
total positions :$532,763,821.72 total gains: $483,965,280.00

From past experience I have maintained >1m of positions using only <$500 capital

This would appear to be the effect of compounded loading and interest combined with leverage...though I could be wrong
Anyone here able to validate/clarify..or offer some useful constructive criticism?

Michael,

Spencer is right -- if you run a full backtest and click Transactions, you will see it purchases 10,000 shares of SPY almost every minute (over $1million per minute). You are purchasing real shares for the full amount (as far as I'm aware, there are no CFDs on Quantopian)

        if data[context.spy].price < avg_price*.95:  
            if momentum:  
                order(context.spy, -10000)  
                log.debug("Selling spy -10000 momentum")  
            elif reverting:  
                order(context.spy, 10000)  
                log.debug("Ordering spy +10000 reverting")  
            else:  
                return  
        elif data[context.spy].price > avg_price*1.05:  
            if momentum:  
                order(context.spy, 10000)  
                log.debug("Ordering spy +10000 momentum")  
            elif reverting:  
                order(context.spy, -10000)  
                log.debug("Selling spy -10000 reverting")  
            else:  
                return  

You could try order_target_percent instead, but be aware that your order takes time to fill (quite possibly >1minute) so you should probably wait for the current order to fill before issuing another.

if not get_open_orders(context.spy):  
       order_target_percent(context.spy, 1.0)