def _main(): basics = ts.get_stock_basics() frame = DataFrame() frame['name'] = np.nan # frame['pe'] = basics['pe'] frame[COL_P_CHANGE_01] = np.nan frame[COL_PASTAVERAGETURNOVER] = np.nan frame[COL_STOPMARK] = '' for i, code in enumerate(leading_shares): frame.loc[code, 'name'] = basics.loc[code, 'name'] hist_data = ts.get_hist_data(code) try: frame.loc[code, COL_P_CHANGE_01] = hpc(hist_data, begin=DAY_0, end=DAY_1) frame.loc[code, COL_PASTAVERAGETURNOVER] = pat( hist_data, PAST_AVERAGE_TURNOVER_PERIOD) if hist_data.index[0] != LAST_MARKET_DATE: frame.loc[code, COL_STOPMARK] = 'stop' except Exception: continue print('#####', i, '#####') filtered_frame = frame[(frame[COL_STOPMARK] != 'stop')] sorted_frame = filtered_frame.sort_values(by=COL_P_CHANGE_01) print(sorted_frame) file_name = '../logs/{date}@HeroSea.csv'.format(date=LAST_MARKET_DATE) # print(fileName) with open(file_name, 'w', encoding='utf8') as file: sorted_frame.to_csv(file)
def _main(): basics = ts.get_stock_basics() frame = DataFrame() frame['name'] = basics['name'] frame[COL_PASTCHANGE] = np.nan frame[COL_PASTPOSITIVE] = np.nan frame['pe'] = basics['pe'] i = 0 for code in basics.index: hist_data = ts.get_hist_data(code) try: frame.loc[code, COL_PASTCHANGE] = phpc(hist_data, PAST_DAY_PERIOD) if phpc(hist_data, PAST_POSITIVE_PERIOD) > 0: frame.loc[code, COL_PASTPOSITIVE] = '★' frame.loc[code, COL_PASTAVERAGETURNOVER] = pat( hist_data, PAST_AVERAGE_TURNOVER_PERIOD) except Exception: continue i += 1 print('#####', i, '#####') sorted_frame = frame.sort_values(by=COL_PASTCHANGE) print(sorted_frame) t = time.strftime('%Y-%m-%d', time.localtime()) file_name = '../logs/%s@rocket%s' % (t, '.csv') # print(fileName) with open(file_name, 'w', encoding='utf8') as file: sorted_frame.to_csv(file)
def _main(): basics = ts.get_stock_basics() frame = DataFrame() frame['name'] = basics['name'] frame['pe'] = basics['pe'] frame[COL_P_CHANGE_01] = np.nan frame[COL_P_CHANGE_12] = np.nan frame[COL_PASTAVERAGETURNOVER] = np.nan frame[COL_STOPMARK] = np.nan frame[COL_SORT_KEY] = np.nan for i, code in enumerate(basics.index): hist_data = ts.get_hist_data(code) try: frame.loc[code, COL_P_CHANGE_01] = hpc(hist_data, begin=DAY_0, end=DAY_1) frame.loc[code, COL_P_CHANGE_12] = hpc(hist_data, begin=DAY_1, end=DAY_2) frame.loc[code, COL_SORT_KEY] = round( frame.loc[code, COL_P_CHANGE_01] * frame.loc[code, COL_P_CHANGE_12], 3) frame.loc[code, COL_PASTAVERAGETURNOVER] = pat( hist_data, PAST_AVERAGE_TURNOVER_PERIOD) if hist_data.index[0] != LAST_MARKET_DATE: frame.loc[code, COL_STOPMARK] = 'stop' except Exception: continue print('#####', i, '#####') filtered_frame = frame[(frame[COL_P_CHANGE_01] > 0) & (frame[COL_P_CHANGE_12] < 0) & (abs(frame[COL_P_CHANGE_12]) > abs( frame[COL_P_CHANGE_01])) & (frame[COL_PASTAVERAGETURNOVER] < 20) & (frame[COL_PASTAVERAGETURNOVER] > 0.5) & (frame['pe'] > 0) & (frame[COL_STOPMARK] != 'stop')] sorted_frame = filtered_frame.sort_values(by=COL_SORT_KEY) print(sorted_frame) file_name = '../logs/{date}@EnemyChaser.csv'.format(date=LAST_MARKET_DATE) # print(fileName) with open(file_name, 'w', encoding='utf8') as file: sorted_frame.to_csv(file)
def _main(): basics = ts.get_stock_basics() frame = DataFrame() frame['name'] = basics['name'] frame['pe'] = basics['pe'] frame[COL_PASTFAR] = np.nan frame[COL_PASTNEAR] = np.nan frame[COL_PASTAVERAGETURNOVER] = np.nan frame[COL_STOPMARK] = np.nan i = 0 for code in basics.index: hist_data = ts.get_hist_data(code) try: frame.loc[code, COL_PASTFAR] = hpc(hist_data, begin=DAY_NEAR, end=DAY_FAR) frame.loc[code, COL_PASTNEAR] = hpc(hist_data, begin=0, end=DAY_NEAR) frame.loc[code, COL_PASTAVERAGETURNOVER] = pat(hist_data, PAST_AVERAGE_TURNOVER_PERIOD) if hist_data.index[0] != LAST_MARKET_DATE: frame.loc[code, COL_STOPMARK] = 'stop' except Exception: continue i += 1 print('#####', i, '#####') filtered_frame = frame[(frame[COL_PASTFAR] < 0) & (frame[COL_PASTNEAR] > 0) & (frame[COL_PASTAVERAGETURNOVER] < 20) & (frame[COL_PASTAVERAGETURNOVER] > 0.5) & (frame['pe'] < 100) & (frame['pe'] > 0) & (frame[COL_STOPMARK] != 'stop')] sorted_frame = filtered_frame.sort_values(by=COL_PASTFAR) print(sorted_frame) file_name = '../logs/%s@flash%s' % (LAST_MARKET_DATE, '.csv') # print(fileName) with open(file_name, 'w', encoding='utf8') as file: sorted_frame.to_csv(file)