Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
My first algo-trade

I want to go with live trading on my IB account of total: 115k dollars with my first algorithm.
20% leverage is initiated.
The algo is simply took two longs and one short based on the knowledge of today.
I know this does not make sense for backtesting.
But I want to use this algo-trade to replace my hand-trade for my start point.
Any suggestion is appreciated.

7 responses

Why did you pick those stocks and weights? That's what you need to program the algorithm to do. Otherwise it's just re-balancing those same 3 stocks, once a month forever which is OK if that's all you want but it can do so much more. Just telling the algorithm what to buy is no different than doing it by hand IMO. you need it to make the decision based on your criteria. If you don't have well defined criteria and you just picked those 3 stocks based on some news article or some such then I would rethink your strategy

I completely agree with you, Luke. Algo selection of stock and weight may be desirable, but I have to take time to get familiar with it. At this stage, I am afraid I could make big mistake if I get complicated codes into it.

@qingshuo your algo is terrible. U are wasting your 115K. Give me your $$ and I can make it $1M in one year.

@Eric K, Hmmm, I am just making myself conservative in the sense of DD less than 5%, as a startup with real money.
Your offer is attractive. How can I believe in it?

@Obviously DD alone means nothing. I thought it's not worth taking the risks running any day trading system with a sharpe ratio <=2.0. My own one has a sharpe around 4.0 and a DD of 12%. Don't trust me I am just kidding. I am not very interested in running your $$

@Eric, Did you share your code? I am interested in having a look into it. Thanks

It is my second version of the algorithm.

Purpose:
(1) Reduce the risk, which I could afford. Here the risk for myself is called “myDD”, and I want it to be no more than 15%.
(2) Maximum Drawdown shall be no more than 20%. (3) Annual return shall be no less than 3% on average.

Risk measure:
“myDD” is variation from maximum drawdown from my own experience. The main motivation is that,
(1) I will be fine if I had 50% maximum drawdown after 100% return (2) But I will be scared if I had 20% maximum drawdown after 10% return. The formula is given as follows: My current DD is the current loss relative to inflation,
given by
myCurDD(t) = 1 - X_t * exp(- rt)/X_0
and myDD is given by
myDD(t) = max{ myCurDD(s): s <= t }
where X_t is the portfolio value at time t, and r is fixed number to mimics inflation rate.

Strategy:
(1) At t = 0, the account is divided to Stock (at portion slev = 30%)
Cash (at portion clev = 20%)
Bond (at portion blev = 50%)
(2) Every week we rebalance with Stock (at portion slev) + Cash (at portion clev) + Bond (at portion blev)
with updated portions by the formula below:
slev(t) = min{max{slev(0) - myCurDD(t), SlevMin}, SlevMax}
clev(t) = min{1 - slev, clev(0)}
blev(t) = 1 - slev - clev
The main idea is to increase the portion to stock as I gains more profit, vice versa.

Conclusion.
In the code, I used SPY throughout the period March 2007 - March 2017.
Total Returns: 60.8%
Benchmark Returns: 107.5%
Alpha: 0.02
Beta: 0.27
Sharpe: 0.77
Sortino: 1.09
Volatility: 0.07
Max Drawdown: -17.9%
MyDD: 15.6% (defined earlier)

Obviously the choice of the stock may be optimized by various factors.
As expected, the return is underperformed by SPY, but satisfactory to my own.
At least, I am not holding 80% cash doing nothing as of the earlier version.

Any comment is appreciated.