purchasableItemsAll.py
Code snippet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# # Search Stock code from 1000 to 9999 # all_company_code_range = [] all_open_days = [] for n in range(9): # Search Stock code from X000 to X999 startStockCode = (n + 1) * 1000 stopStockCode = startStockCode + stock_code_step sql_str = 'select * from tbl_company_new where company_code >= %d and company_code < %d' % (startStockCode, stopStockCode) cursor.execute(sql_str) exec('company_code_range_%d = cursor.fetchall()') % (startStockCode) #all_company_code_range = [company_code_range_1000, company_code_range_2000, company_code_range_3000] exec('all_company_code_range.append(company_code_range_%d)') % (startStockCode) # Search close price of target day sql_str = 'select * from tbl_close_price_%d_%d;' % (startStockCode, start_year) cursor.execute(sql_str) exec('open_days_%d = cursor.fetchall()') % (startStockCode) #all_open_days = [open_days_1000, open_days_2000, open_days_3000] exec('all_open_days.append(open_days_%d)') % (startStockCode) |
all_company_code_range[9]
各社の株式コードと会社名が1000番単位でcompany_code_range_xxxx に格納され、それぞれのcompany_code_range_1xxx〜9xxxが格納されるリスト。
all_open_day[9]
市場の稼働日と各社の終値が1000番単位でopen_days_xxxxに格納され、それぞれのopen_days_xxxxが格納されるリスト。
1 2 3 4 5 6 7 8 9 10 |
# Get Recent date using_open_days = all_open_days[0] recentDateTime = datetime.datetime.strptime('1900-01-01 00:00:00', "%Y-%m-%d %H:%M:%S") for (m, oneDay) in enumerate(using_open_days): if recentDateTime < oneDay['open_date_time']: recentDateTime = oneDay['open_date_time'] recentDateTimeIndex = m print recentDateTime print recentDateTimeIndex |
リストに格納されている最大日のリスト上の位置を求める
→→リスト操作でうまい事出来るかも知れない??