Hi all,
This is probably a dumb question related to my inexperience with Pandas dataframes, but I'm trying to access fundamental information in the handle_data function. I am initially setting up a screen in before_trading_start and including this line as I've seen in the examples,
query(
fundamentals.valuation.market_cap
)
.filter(fundamentals.valuation.market_cap > 2.5e9)
.filter(fundamentals.valuation.market_cap < 3e9)
# order by market cap
.order_by(fundamentals.valuation.market_cap.desc())
.limit(10)
context.fundamental_df = fundamental_df
context.stocks = context.fundamental_df
then, in handle_data, I'm trying to access the market cap for these stocks. If I do the following,
log.info(context.stocks)
then I get the following output:
handle_data:88 INFO security Security(41280 [AL]) Security(24489 [GLNG]) Security(18582 [LHO]) Security(7364 [TDW]) Security(11086 [AEO]) Security(1315 [CBT]) Security(8188 [JW_B]) Security(39204 [PDM]) Security(2404 [EAT]) Security(7844 [USG])
market_cap 2991576478 2990319502 2988820773 2985963474 2985360174 2981665098 2978814819 2977367611 2977252454 2968431801
So I know the market_cap information is in here. I can get a bit closer if I do this,
log.info(context.stocks.loc['market_cap'])
then I get the following output,
2014-01-07 handle_data:88 INFO security
Security(41280 [AL]) 2991576478
Security(24489 [GLNG]) 2990319502
Security(18582 [LHO]) 2988820773
Security(7364 [TDW]) 2985963474
Security(11086 [AEO]) 2985360174
Security(1315 [CBT]) 2981665098
Security(8188 [JW_B]) 2978814819
Security(39204 [PDM]) 2977367611
Security(2404 [EAT]) 2977252454
Security(7844 [USG]) 2968431801
Name: market_cap, dtype: int64
SO: I'm wondering how I can access the market cap info for each stock and then use it? I think this is probably a simple indexing question, but I'm having trouble sorting it out. any thoughts?? Thanks!!
Jason