Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
New to quantopian-quick question

Hey I'm new to quantopian and trying to build a model around VVIX(volatility of volatility). Im having some trouble figuring out fletcher and would love a quick example/explanation how I should present the quandl data in the code. Currently, Im having a error around line 8.

Thanks,
Henry

Heres the code:

def preview(df):  
    log.info(df.head())  
    return df

def initialize(context):  
    context.investment_size = (context.portfolio.cash / 10.0)  
    fetch_csv('https://www.quandl.com/api/v1/datasets/CBOE/VVIX.csv', vvix = 'VVIX', pre_func = preview)  
    context.stocks = symbols('xiv')  
def handle_data(context, data):  
    cash = context.portfolio.cash  
    try:  
        for s in data:  
           if 'VVIX' in data[s]:  
            vvix = data[s]['VVIX']  
            current_posistion = context.portfolio.positions[s].amount  
            current_price = vvix  
            if (vvix >= 120):  
                if cash > context.investment_size:  
                    order_value(XIV, context.investment_size)  
                    cash -= context.investment_size  
            elif (vvix <= 90) and (current_position > 0):  
                order_target(XIV,0)  
    except Exception as e:  
        print(str(e))  
2 responses

Have you tried the fetcher sample algo from the docs. It uses quandl as well? https://www.quantopian.com/help#sample-csv-1

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.

For folks interested in VVIX, we now have VVIX daily values from Quandl integrated into Quantopian and available for use in algorithms, research and your live trading algos (like your contest algos): https://www.quantopian.com/data/quandl/cboe_vvix

Lot's of other new CBOE data sets available on Quantopian now, delivered via Quandl: https://www.quantopian.com/data?searchq=CBOE