Example #1
0
def retrieve_buysell_data_from_hnet(window_hnet=None):

    if window_hnet is None:
        logger.info('no handle of hnet...')
        return

    if not window_hnet.Exists():
        logger.error('no handle of hnet...')
        return

    window_hnet.SetFocus()

    # 30137
    sub_window_title = u'30137 \uc124\uc815\ud574\uc9c0\ud604\ud669'
    sub_window = window_hnet[sub_window_title]

    if not sub_window.Exists():
        window_hnet.ClickInput(coords=(70, 70)) # Editor (# of sub_window)
        clipboard.copy('30137')
        helper.paste()
        # helper.press('enter')

    sub_window.Maximize()
    sub_window.Restore()
    sub_window.SetFocus()

    sub_window.ClickInput(coords=(40,15)) # 자동조회
    sub_window.ClickInput(coords=(120,15)) # 클래스통합
    sub_window.ClickInput(coords=(120,125)) # 펀드유형3
    helper.press('2')

    helper.press('enter')

    logger.info('waiting data retreive...')
    time.sleep(30) # FIXME: check retreive done
    logger.info('stop waiting 30 sec')
    # Copy Data

    sub_window.RightclickInpu(coords=(70, 200))
    helper.press('up_arrow')
    time.sleep(0.3)
    helper.press('up_arrow')
    time.sleep(0.3)
    helper.press('enter')
    time.sleep(0.3)

    text = clipboard.paste()
    return textpre
    pass
Example #2
0
def query_fund_buysell_able_data_from_hnet(window_hnet=None, fund_code_lst=[]):
    if window_hnet is None:
        logger.info('no handle of hnet...')
        return

    if not window_hnet.Exists():
        logger.error('no handle of hnet...')
        return

    window_hnet.SetFocus()

    # 30116 펀드정보등록
    sub_window_title = u'30116 펀드정보등록'
    sub_window = window_hnet[sub_window_title]

    # if sub_window.Exists():
    #     sub_window.Close()

    if not sub_window.Exists():
        window_hnet.ClickInput(coords=(70, 70))  # Editor (# of sub_window)
        clipboard.copy('30116')
        helper.paste()
        # helper.press('enter')

    sub_window.Maximize()
    sub_window.Restore()
    sub_window.SetFocus()

    # msg = '=== START of retreive_fund_day_buysell_data_from_hnet %s %s ===' % (strdate1, buysell)
    # logger.info(msg)

    # line_data_lst = list()

    for fund_code in fund_code_lst:

        sub_window.ClickInput(coords=(90, 150))  # 펀드코드
        # clipboard.copy('1356016')
        clipboard.copy(fund_code)
        helper.paste()

        helper.press('enter')
        print(fund_code)
        time.sleep(0.2)

    # msg = '=== END of retreive_fund_day_buysell_data_from_hnet %s %s ===' % (strdate1, buysell)
    # logger.info(msg)
    # logger.info('data count: %d' % len(line_data_lst))
    pass
def download_statement_from_front(window_front=None, trade_id_list=[]):
    if window_front is None:
        logger.info("no handle of front...")
        return

    if not window_front.Exists():
        logger.error('no handler of front...')
        return

    window_front.SetFocus()

    window_front.ClickInput(coords=(80, 340))  # URL Editor
    clipboard.copy(
        'http://front.samsungsecurities.local/instrument/document/index/F190621-00001'
    )
    helper.paste()
    helper.press('enter')
    time.sleep(0.5)
def chk_isin_in_schedul_list(window_hnet, target_df, df_data):
    # 32802 파생결합증권상품정보
    sub_window_title = u'32802 파생결합증권상품정보'
    sub_window = window_hnet[sub_window_title]

    if not sub_window.Exists():
        window_hnet.ClickInput(coords=(70, 70))  # Editor (# of sub_window)
        clipboard.copy('32802')
        helper.paste()
        helper.press('enter')
        time.sleep(0.5)

    sub_window.Maximize()
    sub_window.Restore()
    sub_window.SetFocus()

    msg = '== START of chk_isin_in_schedule_list ==='
    logger.info(msg)

window_front = handle_front()
time.sleep(3)
trade_id_list = [
    'F190626-00006',
    'F190626-00005',
    'F190626-00004',
]

trade_id_list = ["F200618-%05d" % i for i in xrange(5, 16 + 1)]
trade_id_list = trade_id_list + ["F200618-%05d" % i for i in xrange(2, 3 + 1)]

for trade_id in trade_id_list:
    window_front.SetFocus()
    logger.info("downloading %s" % trade_id)
    window_front.ClickInput(coords=(340, 50))  # URL Editor
    # clipboard.copy('http://45.249.2.37/instrument/document/index/%s' % trade_id)
    # clipboard.copy('http://45.249.2.37/Document/Trade/%s' % trade_id)
    clipboard.copy(
        'http://front.samsungsecurities.local/Document/Trade/Detail/%s' %
        trade_id)
    helper.press('backspace')
    helper.paste()
    helper.press('enter')
    time.sleep(5)
    window_front.ClickInput(coords=(890, 500))  # download button final
    time.sleep(2)

logger.info("======== END download %d ==========" % len(trade_id_list))
def get_confirm_isin_list_from_hnet(window_hnet=None):
    if window_hnet is None:
        logger.info('no handle of hnet')
        return

    if not window_hnet.Exists():
        logger.info('no handle of hnet')
        return

    window_hnet.SetFocus()

    # 30192 파생결합증권위험고지
    sub_window_title = u'32802 파생결합증권상품정보'
    sub_window = window_hnet[sub_window_title]

    if not sub_window.Exists():
        window_hnet.ClickInput(coords=(70, 70))  # Editor (# of sub_window)
        clipboard.copy('30192')
        helper.paste()
        helper.press('enter')
        time.sleep(0.5)

    sub_window.Maximize()
    sub_window.Restore()
    sub_window.SetFocus()

    msg = '== START of get_confirm_isin_code_list_from_hnet ==='
    logger.info(msg)

    sub_window.ClickInput(coords=(90, 15))  # 업무구분
    for i in xrange(6):
        helper.press('up_arrow')
    for i in xrange(3):
        helper.press('down_arrow')
    helper.press('enter')

    time.sleep(0.5)
    helper.press('enter')

    sub_window.RightClickInput(coords=(90, 140))
    helper.press('up_arrow')
    time.sleep(0.5)
    helper.press('up_arrow')
    time.sleep(0.5)
    helper.press('enter')
    time.sleep(0.5)

    data_table = clipboard.paste()
    data_table_rows = data_table.split("\n")

    isin_code_list = list()

    for row in data_table_rows:
        column_list = row.split("\t")
        if column_list[0] != u"상품코드" and len(column_list[0]) >= 10:
            isin_code_list.append(column_list[0])
            # print(column_list[0])

    logger.info("data load->isin_code cnt: %d" % len(isin_code_list))
    sub_window.Close()

    msg = "== END of get_confirm_isin_code_list_from_hnet ==="
    logger.info(msg)
    return isin_code_list
def chk_isin_in_salesteam(window_hnet, isin_code_list, df_data):

    # 32802 파생결합증권상품정보
    sub_windwow_title = u'32802 파생결합증권상품정보'
    sub_windwow = window_hnet[sub_windwow_title]

    if not sub_windwow.Exists():
        window_hnet.ClickInput(coords=(70, 70)) # Editor (# of sub_window)
        clipboard.copy('32802')
        helper.paste()
        helper.press('enter')
        time.sleep(0.5)

    sub_windwow.Maximize()
    sub_windwow.Restore()
    sub_windwow.SetFocus()

    msg = '== START of chk_isin_in_saleteam ==='
    logger.info(msg)

    df_data_sub = df_data[(df_data[u'Sales부서'] == u'PB') & (df_data[u'결제상태'] == u'최종확정')]
    df_data_early = df_data_sub[(df_data_sub[u'일자구분'] == 'OBS') & (df_data_sub[u'Sched.Type'] == u'의무중도')]
    df_data_mat = df_data_sub[(df_data_sub[u'일자구분'] == 'MAT')]

    df_data_sub = df_data[(df_data[u'Sales부서'] == u'PB') & (df_data[u'결제상태'] == u'미입력')]
    df_data_delay = df_data_sub[(df_data_sub[u'일자구분'] == 'OBS') & (df_data_sub[u'Sched.Type'] == u'의무중도')]

    logger.info('Sched Early Term-> %d' % len(df_data_early))
    logger.info('Sched Delay Term-> %d' % len(df_data_delay))
    logger.info('Sched MAT Term-> %d' % len(df_data_mat))

    for isin_code in isin_code_list:
        sub_windwow.ClickInput(coords=(90, 35))  # 종목코드
        clipboard.copy(isin_code[2:])
        helper.paste()

        # helper.press('enter')
        sub_windwow.ClickInput(coords=(775, 35))  # 조회
        time.sleep(0.5)

        sub_windwow.RightClickInput(coords=(110, 80))  # 딜코드
        helper.press('up_arrow')
        helper.press('up_arrow')
        helper.press('enter')

        deal_code = clipboard.paste()
        if deal_code in list(df_data.index):
            if len(df_data.loc[deal_code][u'Sales부서']) > 0:
                sales_team = df_data.loc[deal_code][u'Sales부서'][0]
                settle_state = df_date.loc[deal_code][u'결재상태'][0]
                sched_type = df_data.loc[deal_code][u'Sched.Type'][0]
            else:
                sales_team = df_data.loc[deal_code][u'Sales부서']
                settle_state = df_data.loc[deal_code][u'결재상태']
                sched_type = df_data.loc[deal_code][u'Sched.Type']
            msg = u"%s %s %s %s" % (isin_code, sales_team, settle_state, sched_type)
            logger.info(msg)
        else:
            logger.info("%s not in list" % deal_code)

        msg = '=== END of chk_isin_in_saleteam ==='
        logger.info(msg)
def get_total_settle_list_from_hnet(window_hent=None, strdate=None):
    if window_hent is None:
        logger.info('no handle of hent...')
        return

    if not window_hent.Exists():
        logger.info('no handle of hent...')
        return

    window_hent.SetFocus()

    # 66305 통합스케쥴내역1
    sub_window_title = u'66305 통합스케쥴내역1'
    sub_window = window_hent[sub_window_title]

    if sub_window.Exists():
        sub_window.Close()

    window_hent.ClickInput(coords=(70, 70))     # Editor (# of sub_window)
    clipboard.copy('66305')
    helper.paste()
    helper.press('enter')
    time.sleep(0.5)

    sub_window.Maximize()
    sub_window.Restore()
    sub_window.SetFocus()

    msg = '== START of get_total_settle_list_from_hnet ==='
    logger.info(msg)

    sub_window.DoubleClickInput(coords=(90, 15))    # 조회기간
    for i in xrange(2):
        for date_digit in strdate:
            helper.press(date_digit)

    sub_window.DoubleClickInput(coords=(90, 55))  # 종목종류
    for i in xrange(5):
        helper.press('down_arrow')
    for i in xrange(3):
        helper.press('up_arrow')
    helper.press('enter')

    sub_window.DoubleClickInput(coords=(700, 55))  # 일괄조회
    helper.press('enter')

    time.sleep(15)

    sub_window.ClickInput(coords=(90, 120))     # 자료 복사
    helper.press('up_arrow')
    time.sleep(1)
    helper.press('up_arrow')
    time.sleep(1)
    helper.press('enter')
    time.sleep(1)

    data = clipboard.paste()
    data = data.split("\r\n")
    new_data_lst = []
    for row in data:
        row_lst = row.split('\t')
        new_data_lst.append(row_lst)

    df_data = pd.DataFrame(new_data_lst)
    headers = df_data.iloc[0]
    df_data = pd.DataFrame(df_data.values[1:], columns=headers)
    # df_data.index = df_data[u'딜코드']
    df_data.index = df_data[df_data.columns[5]]

    sub_window.Close()

    msg = '=== END of get_total_settle_list_from_hnet ==='
    logger.info(msg)

    return df_data
Example #9
0
def retreive_stdprice_data_from_hnet(window_hnet=None):
    # now_dt = dt.datetime.now()

    if window_hnet is None:
        logger.error('no handle of hnet ...')
        return

    if not window_hnet.Exists():
        logger.error('no handle of hent ...')
        return

    window_hnet.SetFocus()

    # 30126 기준가정보
    sub_window_title = u'30126 \ud380\ub4dc\uae30\uc900\uac00\uaca9\uc815\ubcf4'
    sub_window = window_hent[sub_window_title]

    if not sub_window.Exists():
        window_hnet.ClickInput(coords=(70, 70))     # Editor (# of sub_window)
        clipboard.copy('30126')
        helper.paste()
        # helper.press('enter')

    sub_window.Maximize()
    sub_window.Restore()
    sub_window.SetFocus()
    sub_window.ClickInput(coords=(70, 15))
    helper.press('2')

    for fundcode in fundcode_lst:
        sub_window.ClickInput(coords=(70, 55))      # 펀드코드 Edit
        # clipboard.copy('1356004')
        clipboard.copy(fundcode)
        helper.paste()

        # sub_window.ClickInput(coords=(725, 95))   # Click 조회
        helper.press('enter')

        # Copy Data

        sub_window.RightClickInput(coords=(70, 205))
        helper.press('up_arrow')
        time.sleep(0.3)
        helper.press('up_arrow')
        time.sleep(0.3)
        helper.press('enter')
        time.sleep(0.3)

        text = clipboard.paste()
        text_line_lst = text.split('\n')
        text_line_encode = text_line_lst[2].encode('utf-8')
        text_line_encode = text_line_encode.replace('/', '-')
        text_line_encode_lst = text_line_encode.split('\t')
        fund_code_info = "%s %s %s %s %s" % (fundcode,
                                             text_line_encode_lst[0],
                                             text_line_encode_lst[1],
                                             text_line_encode_lst[5],
                                             text_line_encode_lst[8],
                                             )
        logger.info(fund_code_info)

        data = text_line_lst[2]
        data = data.replace('\r', '')
        data = data.replace('/', '-')
        data_lst = data.split('\t')

        fund_data_dict[fundcode] = data_lst

    pass
Example #10
0
def retrieve_fund_day_buysell_data_from_hnet(window_hnet=None,
                                             fund_code_lst=[],
                                             buysell='B',
                                             pw='',
                                             strdate1=''):
    """
    :param window_hnet:
    :param fund_code_lst:
    :param buysell:
    :param pw:
    :param strdate1: '%Y%m%d'
    :return:
    """

    if window_hnet is None:
        logger.info('no handle of hnet...')
        return

    if not window_hnet.Exists():
        logger.error('no handle of hnet...')
        return

    window_hnet.SetFocus()

    # 30301 TR
    sub_window_title = u'30301 매매신청/결제현황'
    sub_window = window_hnet[sub_window_title]

    # if sub_window.Exists()
    #   sub_window.Close()

    if not sub_window.Exists():
        window_hnet.ClickInput(coords=(70, 70))  # Editor (# of sub_window)
        clipboard.copy('30301')
        helper.paste()
        # helper.press('enter')

    sub_window.Maximize()
    sub_window.Restore()
    sub_window.SetFocus()

    if strdate1 == '':
        now_dt = dt.datetime.now()
        strdate1 = now_dt.strftime('%Y%m%d')
        strdate = now_dt.strftime('%Y-%m-%d')
    else:
        strdate = strdate1[:4] + '-' + strdate1[4:6] + '-' + strdate1[-2:]

    msg = '=== START of retreive_fund_day_buysell_data_from_hnet %s %s ===' % (
        strdate1, buysell)
    logger.info(msg)

    sub_window.DoubleClickInput(coords=(90, 125))  # 처리일자
    helper.typer(strdate1)

    sub_window.ClickInput(coords=(620, 150))  # 비*밀&번$호
    clipboard.copy(pw)
    helper.paste()

    sub_window.ClickInput(coords=(90, 55))  # 매매구분
    if buysell == 'B':
        helper.press('1')  # 1. 매수 2. 매도
    elif buysell == 'S':
        helper.press('2')  # 1. 매수 2. 매도
    else:
        helper.press('1')  # 1. 매수 2. 매도

    line_data_lst = list()

    for fund_code in fund_code_lst:
        sub_window.ClickInput(coords=(90, 150))  # 펀드코드
        # clipboard.copy('1356016')
        clipboard.copy(fund_code)
        helper.paste()

        helper.press('enter')

        time.sleep(0.5)

        sub_window.RightClickInput(coords=(90, 250))  # Data
        helper.press('up_arrow')
        helper.press('up_arrow')
        helper.press('enter')

        text = clipboard.paste()
        text_line_lst = text.split('\n')
        line_count = len(text_line_lst)
        data_line_count = (line_count - 3) / 2

        for i in xrange(data_line_count):
            # text_line_encode = text_line_lst[i + 2].encode('utf-8')
            text_line_encode = text_line_lst[2 * i + 2]
            text_line_encode = text_line_encode.replace('/', '-')
            text_line_encode_lst1 = text_line_encode.split('\t')

            # text_line_encode = text_line_lst[i + 3].encode('utf-8')
            text_line_encode = text_line_lst[2 * i + 3]
            text_line_encode = text_line_encode.replace('/', '-')
            text_line_encode_lst2 = text_line_encode.split('\t')

            data_lst = list()
            data_count = len(text_line_encode_lst1)

            if text_line_encode_lst1[0] == '':
                logger.info('no buysell fund: %s' % fund_code)
                continue
            else:
                data_lst.append(strdate)
                fund_name = text_line_encode_lst2[4]
                order_amount = text_line_encode_lst2[7]
                # print(fund_code, fund_name, str(order_amount))
                msg = str(fund_code) + ' '
                msg = msg + fund_name + ' '
                msg = msg + order_amount
                text_line_encode_lst1[2] = ''  # 계&좌*번$호
                logger.info(msg)

            for j in xrange(data_count):
                data_lst.append(text_line_encode_lst1[j])
                data_lst.append(text_line_encode_lst2[j])

            line_data_lst.append(data_lst)

    msg = '=== END of retreive_fund_day_buysell_data_from_hnet %s %s ===' % (
        strdate1, buysell)
    logger.info(msg)
    logger.info('data count: %d' % len(line_data_lst))

    return line_data_lst
    pass
def query_otc_termination_data_from_hnet(window_hnet=None, isin_code_lst=[]):
    if window_hnet is None:
        logger.info('no handle of hent...')
        return

    if not window_hnet.Exists():
        logger.error('no handle of hnet...')
        return

    window_hnet.SetFocus()

    # 32802 파생결합증권상품정보
    sub_window_title = u'32802 파생결합증권상품정보'
    sub_window = window_hnet[sub_window_title]

    if not sub_window.Exists():
        window_hnet.ClickInput(coords=(70, 70))  # Editor (# of sub_window)
        clipboard.copy('32802')
        helper.paste()
        helper.press('enter')
        time.sleep(0.5)

    sub_window.Maximize()
    sub_window.Restore()
    sub_window.SetFocus()

    msg = '== START of query_otc_termination_data_from_hnet ==='
    logger.info(msg)

    termination_data_dict = dict()

    for isin_code in isin_code_lst:

        sub_window.ClickInput(coords=(90, 35))  # 종목코드
        clipboard.copy(isin_code[2:])
        helper.paste()

        # helper.press('enter')
        sub_window.ClickInput(coords=(775, 35))  # 조회
        time.sleep(0.1)

        sub_window.ClickInput(coords=(90, 15))  # 업무구분
        helper.press('down_arrow')
        helper.press('up_arrow')
        helper.press('up_arrow')
        helper.press('enter')

        sub_window.ClickInput(coords=(250, 275))  # 만기일
        manual_copy(sub_window, 250, 275)
        expire_date = clipboard.paste()
        if expire_date[:4] != "    ":
            expire_date = dt.datetime.strptime(expire_date, "%Y/%m/%d")
            str_expire_date = expire_date.strftime("%Y-%m-%d")
        else:
            str_expire_date = ""

        sub_window.ClickInput(coords=(700, 250))  # 상환예정일
        manual_copy(sub_window, 700, 250)
        termination_date = clipboard.paste()
        if termination_date[:4] != "    ":
            termination_date = dt.datetime.strptime(termination_date,
                                                    "%Y/%m/%d")
            str_termination_date = termination_date.strftime("%Y-%m-%d")
        else:
            str_termination_date = "    -  -  "

        sub_window.ClickInput(coords=(700, 275))  # 상환예상단가
        helper.copy()
        termination_price = clipboard.paste()

        # ctrl = window_hnet['AfxWnd100u58']
        # ctrl.ClickInput()
        sub_window.ClickInput(coords=(100, 110))
        helper.copy()
        prdt_name = clipboard.paste()
        termination_type = u'미상환'
        if str_termination_date[:4] != "    ":
            if expire_date > termination_date:
                termination_type = u'조기상환'
            elif expire_date < termination_date:
                termination_type = u'만기상환'
            elif expire_date == termination_date:
                termination_type = u'카피에러'
            data_lst = [
                termination_type, str_termination_date, termination_price
            ]
        else:
            data_lst = [termination_type, "", ""]

        msg = "%s %s %s %s %s %s" % (isin_code, prdt_name, str_expire_date,
                                     str_termination_date, termination_price,
                                     termination_type)
        logger.info(msg)

        termination_data_dict[isin_code] = data_lst
        sub_window.ClickInput(coords=(775, 35))  # 조회
        time.sleep(0.1)

    msg = "== END of query_otc_termination_data_from_hnet ==="
    logger.info(msg)
    logger.info('data count: %d' % len(termination_data_dict))
    return termination_data_dict
    pass