Back to Community
My first Algorithm on Quantopian

Hi Quantopian Community,
I am a student and this is my first time on Quantopian. I was trying to build my first portfolio with 50% in a long position in FCAU and the rest cash. I wanted to have my position closed 30 minutes before the market close. What do you think? Any suggestion to improve it?

def initialize(context):  
    context.fcau = sid(47888)  
    schedule_function(open_positions, date_rules.week_start(), time_rules.market_open())  
    schedule_function(close_positions, date_rules.week_end(), time_rules.market_close(minutes=30))

def open_positions(context, data):  
    order_target_percent(context.fcau, 0.50)

def close_positions(context, data):  
    order_target_percent(context.fcau, 0)  

I have another question:
Except the standard indicators (returns, alpha, beta etc) that the backtest shows me, what should I do if I want to add MACD, IV, P/E ratio and Aroon?

Thanks for the help,

1 response

I put your code into a backtest and shared it here so people can evaluate it more easily.

To do further evaluations on your backtest, I suggest you load the data in research and start analyzing it there using the get_backtest command.

Edit: I forgot to mention, at this level of capital, your algorithm has a hard time getting in and out of such large trades.

Clone Algorithm
Backtest from to with initial capital
Total Returns
Max Drawdown
Benchmark Returns
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: 59f107ea1762bd3f88e9128a
There was a runtime error.

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.