def generate_ibo_sheet_4date(**kwargs): date_to = kwargs['date_to'] output_dir = ts.create_strategy_output_dir(strategy_class='ibo', report_date=date_to) #if os.path.isfile(output_dir + '/summary.pkl') and os.path.isfile(output_dir + '/cov.pkl'): # sheet_4date = pd.read_pickle(output_dir + '/summary.pkl') # cov_output = pckl.load(open(output_dir + '/cov.pkl', 'rb')) # return {'sheet_4date': sheet_4date, 'cov_output': cov_output, 'success': True} sheet_4date = get_tickers_4date(**kwargs) num_tickers = len(sheet_4date.index) sheet_4date = pd.concat([ifs.get_intraday_trend_signals(ticker=sheet_4date.iloc[x]['ticker'],date_to=date_to)['pnl_frame'] for x in range(num_tickers)]) sheet_4date.to_pickle(output_dir + '/summary.pkl') cov_output = ifs.get_intraday_outright_covariance(**kwargs) with open(output_dir + '/cov.pkl', 'wb') as handle: pckl.dump(cov_output, handle) return {'sheet_4date': sheet_4date, 'cov_output': cov_output, 'success': True}
def generate_candlestick_sheet_4date(**kwargs): date_to = kwargs['date_to'] output_dir = ts.create_strategy_output_dir(strategy_class='candlestick', report_date=date_to) if os.path.isfile(output_dir + '/summary.pkl'): sheet_4date = pd.read_pickle(output_dir + '/summary.pkl') return {'sheet_4date': sheet_4date, 'success': True} sheet_4date = get_tickers_4date(**kwargs) num_tickers = len(sheet_4date.index) signals_output = [ ifs.get_intraday_trend_signals(ticker=sheet_4date.iloc[x]['ticker'], date_to=date_to) for x in range(num_tickers) ] sheet_4date['contract_noise'] = [ x['contract_noise'] for x in signals_output ] sheet_4date['daily_noise'] = [x['daily_noise'] for x in signals_output] sheet_4date['average_volume'] = [ x['average_volume'] for x in signals_output ] sheet_4date['ewma10_50_spread'] = [ x['ewma10_50_spread'] for x in signals_output ] sheet_4date['ewma20_100_spread'] = [ x['ewma20_100_spread'] for x in signals_output ] sheet_4date['intraday_mean5'] = [ x['intraday_mean5'] for x in signals_output ] sheet_4date['intraday_std5'] = [x['intraday_std5'] for x in signals_output] sheet_4date['intraday_mean2'] = [ x['intraday_mean2'] for x in signals_output ] sheet_4date['intraday_std2'] = [x['intraday_std2'] for x in signals_output] sheet_4date['intraday_mean1'] = [ x['intraday_mean1'] for x in signals_output ] sheet_4date['intraday_std1'] = [x['intraday_std1'] for x in signals_output] sheet_4date.to_pickle(output_dir + '/summary.pkl') cov_output = ifs.get_intraday_outright_covariance(**kwargs) with open(output_dir + '/cov.pkl', 'wb') as handle: pckl.dump(cov_output, handle) return { 'sheet_4date': sheet_4date, 'cov_output': cov_output, 'success': True }
def get_intraday_breakout_chart(**kwargs): signal_out = ifs.get_intraday_trend_signals(ticker=kwargs['ticker'],date_to=kwargs['trade_date']) intraday_data = signal_out['intraday_data'] trade_datetime = cu.convert_doubledate_2datetime(kwargs['trade_date']) intraday_data = intraday_data[intraday_data['time_stamp']>=trade_datetime] plt.figure(figsize=(16, 7)) plt.plot(intraday_data['time_stamp'],intraday_data['mid_p'],color='k') plt.plot(intraday_data['time_stamp'],intraday_data['ewma25'],color='b') plt.plot(intraday_data['time_stamp'],intraday_data['ewma100'],color='g') plt.axvline(dt.datetime.combine(trade_datetime,dt.time(8,30,0,0)),color='r') plt.axvline(dt.datetime.combine(trade_datetime,dt.time(9,0,0,0)),color='r') #plt.axvline([x for x in intraday_data['time_stamp'] if 100*x.hour+x.minute == 830][0],color='r') #plt.axvline([x for x in intraday_data.index if 100*x.hour+x.minute == 900][0],color='r') plt.grid() plt.show()