Ejemplo n.º 1
0
def get_shorting_volume_by_ticker(date, market="코스피"):
    """종목별 공매도 거래 현황 조회
    :param date: 조회 일자 (YYYYMMDD)
    :param market  : 코스피/코스닥
    :return        : 거래 현황 DataFrame
                       종목명   수량  거래량   비중
        000020       동화약품    454  196429   0.23
        000030       우리은행      0       0   0.00
        000040       KR모터스     69  175740   0.04
        000042   KR모터스 1WR      0    2795   0.00
        000050           경방    264   39956   0.66
    """
    market = {"KOSPI": 1, "KOSDAQ": 3, "KONEX": 6}.get(market, 1)
    df = SRT02020100().fetch(date, date, market, "")

    df = df[['종목코드', '공매도거래량', '총거래량', '비중', '공매도거래대금']]
    df = df.replace('/', '', regex=True)
    df = df.replace(',', '', regex=True)
    df = df.set_index('종목코드')
    df.index = df.index.str[3:9]
    df = df.astype({
        "공매도거래량": np.int64,
        "총거래량": np.int64,
        "공매도거래대금": np.int64,
        "비중": np.float64
    })
    return df
Ejemplo n.º 2
0
def get_shorting_volume_by_ticker(date, market="코스피"):
    """종목별 공매도 거래 현황 조회
    :param date: 조회 일자 (YYYYMMDD)
    :param market  : 코스피/코스닥
    :return        : 거래 현황 DataFrame
                       종목명   수량  거래량   비중
        000020       동화약품    454  196429   0.23
        000030       우리은행      0       0   0.00
        000040       KR모터스     69  175740   0.04
        000042   KR모터스 1WR      0    2795   0.00
        000050           경방    264   39956   0.66
    """
    market = {"코스피": 1, "코스닥": 3, "코넥스": 4}.get(market, 1)
    df = SRT02020100().read(date, date, market)
    df = df[[
        'isu_cd', 'isu_abbrv', 'cvsrtsell_trdvol', 'acc_trdvol', 'trdvol_wt'
    ]]
    df.columns = ['티커', '종목명', '수량', '거래량', '비중']

    df = df.replace('/', '', regex=True)
    df = df.replace(',', '', regex=True)
    df = df.set_index('티커')
    df.index = df.index.str[3:9]
    df = df.astype({"수량": np.int32, "거래량": np.int32, "비중": np.float64})
    return df.sort_index()