def _count_lighting_rod(self):
        '''

        피뢰침이 만들어진 일자는?
        피뢰침이 만들어진후 지난일자
        피뢰침 평균 거래량


        :return:
        '''


        rt = ic.fillindex(self.df_ohlc_min)

        df_volume_head_10 = rt.sort_values('VOLUME', ascending=False).head(20)
        df_volume_head_10['FLUCT'] = df_volume_head_10['HIGH']-df_volume_head_10['OPEN']


        # print(df_volume_head_10)
        # print('HEAD 20 ROWS, VOLUME MEAN : ', df_volume_head_10['VOLUME'].mean())
        # print('HEAD 20 ROWS, FLUCT MEAN : ', (df_volume_head_10['FLUCT']/df_volume_head_10['OPEN']).mean())
        # print('HEAD 20 ROWS, CLOSE MEAN : ', df_volume_head_10['CLOSE'].mean())
        # print('UPPER 10%, VOLUME : ', rt['VOLUME'].quantile(0.85))
        # print('HEAD 10 ROWS, HIGH ABS: ', df_volume_head_10['HIGH'].max())
        # print('HEAD 10 ROWS, HIGH WHOLE: ', rt['HIGH'].max())

        # RETURN 으로 빼서 set_prev_index() 에서 설정하도록...
        self.dict_prev['20D_TOP20_MEAN_VOL'] = df_volume_head_10['VOLUME'].mean()
        self.dict_prev['20D_TOP20_MEAN_FLUCT']=(df_volume_head_10['FLUCT']/df_volume_head_10['OPEN']).mean()
        self.dict_prev['20D_TOP20_MEAN_CLOSE']=df_volume_head_10['CLOSE'].mean()
        self.dict_prev['20D_85QTILE_VOL'] = rt['VOLUME'].quantile(0.85)
Beispiel #2
0
 def fill_index(self):
     st = datetime.now()
     self.df_ohlc_realtime_filled = ic.fillindex(
         self.df_ohlc_realtime).tail(5)
     elapsed_time = (datetime.now() - st)
     return {
         'elapsed_time':
         '%s.%06d' % (elapsed_time.seconds, elapsed_time.microseconds)
     }
Beispiel #3
0
    def __init__(self,
                 stockcode,
                 condition_buy,
                 the_date,
                 the_date_index,
                 purchased=0,
                 amount=0,
                 hist_purchased=0,
                 hist_selled=0):
        '''

        :param stockcode:
        :param stockname:
        :param to:
        :param condition:
        '''

        self.obj = JazzstockObject_Account(stockcode, the_date, the_date_index,
                                           purchased, amount)
        self.obj.set_ohlc_day_from_db_include_index(
            cntto=the_date_index + 1,
            window=60)  # to + 1, 즉 시뮬레이션 전 거래일 까지의 일봉정보를 가져옴
        self.obj.set_ohlc_min_from_db(cntto=the_date_index,
                                      window=1)  # to 거래일 까지의 5분봉을 가져옴
        self.obj.set_prev_day_index()

        self.obj.df_ohlc_realtime_filled = ic.fillindex(
            self.obj.df_ohlc_min)  # 5분봉에 지표들을 붙여줌

        # # 의문의 DATE타임 전처리.... 왜인지 어떤건 되고 어떤건 안됨
        # self.obj.df_ohlc_realtime_filled.DATE = self.obj.df_ohlc_realtime_filled.DATE.astype(str)

        self.obj.df_ohlc_realtime_filled = self.obj.df_ohlc_realtime_filled[
            self.obj.df_ohlc_realtime_filled.DATE == the_date]
        self.COLUMNS_DAY = [
            'DATE', 'TIME', 'CLOSE', 'VSMAR20', 'BBP', 'BBW', 'K', 'D', 'J'
        ]
        self.COLUMNS_MIN = [
            'DATE', 'TIME', 'CLOSE', 'VSMAR20', 'BBP', 'BBW', 'K', 'D', 'J'
        ]

        self.condition_buy = condition_buy

        self.hist_purchased = hist_purchased
        self.hist_selled = hist_selled
Beispiel #4
0
import common.connector_db as db
import util.index_calculator as ic
import pandas as pd
from crawl.jazzstock_object_crawling import JazzstockCrawlingObject

pd.options.display.max_rows = 1000
pd.options.display.max_columns= 500

obj = JazzstockCrawlingObject('131370','알서포트')
obj.get_daily_index(cntto=1)                    # -1 거래일 까지의 일봉정보를 가져옴
obj.set_ohlc_min_from_db(cntto=0)               # -0 거래일 까지의 5분봉을 가져옴
obj.df_ohlc_min = ic.fillindex(obj.df_ohlc_min) # 5분봉에 지표들을 붙여줌

print(obj.df_ohlc_min.columns)

SHOW_COLUMNS=['DATE', 'TIME', 'CLOSE', 'VSMAR20', 'BBP', 'BBW', 'K', 'D', 'J']

print(obj.df_ohlc_min[obj.df_ohlc_min['VSMAR20']>1])


# AUTOML에서 쓰던 함수들 다 가져와서 util을 만들자
# _equal()
# _bigger()
# _smaller()