Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Help using get_fundamentals (beginner)

Hi, I'm trying to use "get_fundamentals" to filter out some specific conditions and then add the stocks to my "context.stocks".
In handle_data I'm trying to print the "context.stocks", because I want to see which stock are being flagged by my query.
It does't seem to be working (see the code I have below). If someone could help me out, that would be fantastic!

import numpy as np  
import math  
import talib as ta  
import pandas as pd  
from brokers.ib import IBExchange

def initialize(context):  
    context.stocks= {}  
    context.positions = []

def before_trading_starts(context, data):  
    basket_size = 2  
    fundamental_df = get_fundamentals(  
        query(  
        fundamentals.valuation.market_cap,  
        fundamentals.income_statement.net_income,  
        fundamentals.valuation_ratios.book_value_per_share,  
        fundamentals.operation_ratios.total_debt_equity_ratio,  
         )  
        .filter(fundamentals.valuation.market_cap > 1)  
        .filter(fundamentals.income_statement.net_income > 1)  
        .filter(fundamentals.valuation_ratios.book_value_per_share > 10)  
        .filter(fundamentals.operation_ratios.total_debt_equity_ratio < 1)  
        .order_by(fundamentals.valuation.market_cap  
        .desc())  
        .limit(basket_size)  
        )  
    fundamental_df=fundamental_df.dropna()  
    update_universe(fundamental_df.columns.values)  
def handle_data(context, data):  
    print context.stocks  
1 response

Bump. I took a couple days break and now just took another look at it with a fresh mind, however I still cannot solve my problem.
Could anyone assist me, much appreciated! Thanks!