Back to Community
A naive attempt using Kinetic Component Analysis

A naive implementation of trading rules on Kinetic Component Analysis. Anyone care to improve trading rules (entry/exit)?

Clone Algorithm
48
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: 599233268439c64fa36dcf82
There was a runtime error.
6 responses

Hi Pravin -

What is Kinetic Component Analysis? And why might it work?

Also, since you are using daily data, could your code be written as a pipeline custom factor (so that it could be combined with other factors, in a single algo)?

Thanks,

Grant

Hi Grant,

Here is the paper. It could be written as a pipeline factor but first I want to get it working with a single asset. Mostly predicting futures.

Best regards,
Pravin

In the source code, he initialises the state transition matrix A to be equal to

A=np.array([[1,h,.5*h**2, 1./6.*h**3],  
                 [0,1,h,h**2],  
                 [0,0,1,h],  
                 [0,0,0,1]])  

Can someone give an explanation as to how is this derived?

In the paper, A is taken to be

A = np.array([[1,h,h**2],  
                 [0,1,h],  
                 [0,0,1]])  

Thanks!

Oh dear, I misread 0.5 to be 5. This is straightforward.

I tried to put this in pipeline. pipeline loads for a long time and then errors out on schedule function with
TimeoutException: Too much time spent in handle_data and/or scheduled functions. 50 second limit exceeded.

Clone Algorithm
12
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: 5b19676a906b6544e080a655
There was a runtime error.

In general, you should call pipeline_output in before_trading_start, as opposed to a scheduled function or handle_data. The before_trading_start function has a 5 minute limit as opposed to scheduled functions and handle_data which have a 50 second limit. There has been some discussion on another thread about ways that might change at some point in the future, but for now the best solution is to call pipeline_output in before_trading_start, save the result in a context variable, and then reference the context variable in other parts of the algorithm.

Let me know if this helps.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.