您好,在最后给出的策略中,有以下几段代码,有几点不明白
1、python为什么能在def中再包含def。能否告知以下语句实现的机理?
2、一般filter函数中第一个参数是功能(如not_st_filter),但是在以下语句中not_st_filter在头一条语句又赋值了,不明白什么道理(python编程菜鸟,见笑):
def not_st_stock(data):
def make_filter(stock):
return not list(data[stock])[-1]
return make_filter
调用以上语句如下:
st_data = get_extras('is_st',holds, start_date='2005-01-01', end_date=context.current_dt.strftime("%Y-%m-%d"))
not_st_filter = not_st_stock(st_data)
holds = list(filter(not_st_filter, holds))
2016-07-14