Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
A question about building customer fundamental factor

Hi,

I am learning creating/building customer fundamental factor since soe the fundamental parameter I want are't be found in the Fundamental Reference.

In order to make sure doing correct, I try to build a fundamental factor for pe_ratio and compare the result with that from the get_fundamental. I attach my algo. Here are the result:

Bei using get_fundamental():
2016-05-23 before_trading_start:82 INFO pe_ratio Equity(13984 [TGTX]) 0.0273
2016-05-23 before_trading_start:82 INFO pe_ratio Equity(19177 [LEU]) 0.0294
2016-05-23 before_trading_start:82 INFO pe_ratio Equity(29616 [GSI]) 0.0376
2016-05-23 before_trading_start:82 INFO pe_ratio Equity(29884 [ISR]) 0.0380
2016-05-23 before_trading_start:82 INFO pe_ratio Equity(25582 [FMD]) 0.1195
2016-05-23 before_trading_start:82 INFO pe_ratio Equity(11512 [LJPC]) 0.1206
2016-05-23 before_trading_start:82 INFO pe_ratio Equity(13331 [ADMP]) 0.1389
2016-05-23 before_trading_start:82 INFO pe_ratio Equity(48090 [NDRM]) 0.1618
2016-05-23 before_trading_start:82 INFO pe_ratio Equity(42461 [CZR]) 0.1672
2016-05-23 before_trading_start:82 INFO pe_ratio Equity(15988 [EMIT_F]) 0.1728
2016-05-24 before_trading_start:64 INFO ranks Equity(19661 [XLV]) 1.0

These must be correct.

By using my customer factor I get:
2016-05-23 before_trading_start:64 INFO ranks
Equity(41968 [SVXY]) 3
Equity(13197 [FCX]) 5
Equity(19657 [XLI]) 10
Equity(26703 [FXI]) 12
Equity(2174 [DIA]) 13
Equity(3212 [GILD]) 14
Equity(8089 [WBA]) 15
Equity(42471 [UWTI]) 15
Equity(8151 [WFC]) 16
Equity(5938 [PG]) 16

These might be correct(?). But my question is: why they are so different? There must be error in my code.

Cheers

3 responses

Thomas, the problem is the rank:

ranks = context.output.rank().mean(axis=1).order()  

Try printing this instead:

log.info("ranks %s" % context.output.order().head(10))  

Hi,

I've tried your code but I got error:

AttributeError: 'DataFrame' object has no attribute 'order'.