【备忘】datetime使用与series的元素迭代:样例-rqdatac的A股市值查验

实在自己觉得都不好意思,本想养成写看法或随想的习惯,一度成了这种备忘习惯啊啊啊啊啊!
然而还能说什么,有个备忘习惯也算有个习惯吧。好习惯使人终生受益~~(对,我就是这么会哄自己)

from datetime import datetime
import numpy

stock_list=list(all_instruments('CS').order_book_id)
x='2017-12-05'
date_check = datetime.strptime(x, '%Y-%m-%d')  # string convert to date
final_list=[]

for key in stock_list:
    starTing = datetime.strptime(instruments(key).listed_date,'%Y-%m-%d')
    if starTing > date_check:
        continue
    elif (instruments(key).de_listed_date != '0000-00-00'):
        deLing = datetime.strptime(instruments(key).de_listed_date,'%Y-%m-%d')
        if deLing < date_check:
            continue
        else:
            final_list.append(key) #cannot use extend
    else:
        final_list.append(key)


series_factor = get_factor(id_or_symbols = final_list, factor = 'a_share_market_val', start_date = '2017-12-05', end_date ='2017-12-05')
key_list = []

for keke, value in series_factor.iteritems():  #series的元素迭代
  if numpy.isnan(value):
    key_list.append(keke)

print(len(key_list))

你可能感兴趣的:(Python,rqdatac,datetime,pandas,series)