Exemplo n.º 1
0
def sell_just_kospi():
    writeLog(dt, '[관망]매도')
    # 테스트인 경우
    if isTest:
        return

    # 현재 보유종목 가져오기
    stock_code, stocks = daishinTrade.getJango()

    # 1:매도, 2: 매수
    for sellCode in stock_code:
        # 보유수량 확인
        amount = 0
        for s in stocks:
            if s['code'] == sellCode:
                amount = s['amount']
                break

        daishinTrade.goTrade(code=sellCode, bs='1', cnt=amount)

    if len(stock_code) == 0:
        writeLog('관망을 위해 매도할 종목이 없습니다.')
    else:
        # 임시
        s = time.strftime('[%H:%M:%S]')
        s += '[관망]매도'
        telegram_bot.sendMsg(s)

    # 초기화
    init_tran_val()
Exemplo n.º 2
0
def sell_leverage_only(status):
    leverageOff()
    writeLog(dt, '[매도]레버리지 Only매도 : ',status)
    # 테스트인 경우
    if isTest:
        return

    # 현재 보유종목 가져오기
    stock_code, stocks = daishinTrade.getJango()

    # 레버리지 매도
    for etf in etfLeverage:  # 레버리지
        if etf in stock_code:
            # 보유수량 확인
            amount = 0
            for s in stocks:
                if s['code'] == etf:
                    amount = s['amount']
                    buyPrice = s['buyPrice']
                    break

            writeLog(" - 레버리지Only(", etf, ") 매도 : ", amount, '주, 매입가격 : ', buyPrice)

            # 임시
            s = time.strftime('[%H:%M:%S]')
            s += '[매도]레버리지 Only매도 : '
            s += status
            telegram_bot.sendMsg(s)

            daishinTrade.goTrade(code=etf, bs='1', cnt=amount)
        else:
            writeLog(" - 레버리지Only(", etf, ")는 잔고에 존재하지않습니다.")
Exemplo n.º 3
0
def sell_inverse_only(status):
    inverseOff()
    writeLog(dt, '[매도]인버스 Only매도 : ',status)
    if isTest:
        return

    # 현재 보유종목 가져오기
    stock_code, stocks = daishinTrade.getJango()

    # 인버스 매도
    for etf in etfInverse:  # 인버스 대상매도
        if etf in stock_code:

            # 보유수량 확인
            amount = 0
            buyPrice = 0
            for s in stocks:
                if s['code'] == etf:
                    amount = s['amount']
                    buyPrice = s['buyPrice']
                    break

            writeLog(" - 인버스Only(", etf, ") 매도 : ", amount, '주, 매입가격 : ', buyPrice)

            # 임시
            s = time.strftime('[%H:%M:%S]')
            s += '[매도]인버스 Only매도 : '
            s += status
            telegram_bot.sendMsg(s)

            # 메도주문
            daishinTrade.goTrade(code=etf, bs='1', cnt=amount)

        else:
            writeLog(" - 인버스Only 매도(", etf, ")는 잔고에 존재하지 않습니다.")
Exemplo n.º 4
0
def chkInverse():
    before_p = 1.0

    for code in etfInverse:
        # 레버리지 현재가
        now_p = daishinTrade.getNowPrice(code)
        time.sleep(1)

        # 현재 보유종목 가져오기
        stock_code, stocks = daishinTrade.getJango()

        for s in stocks:
            if s['code'] == code:
                before_p = s['buyPrice']
                break

        # 보정값 생성
        # alpha = math.floor(before_p * 0.0025)
        # alpha = 5

        # 소수점 버림
        # before_p = math.floor(before_p)

        # 시장가로 매수하므로 한단계 5를 보정해줌
        writeLog(now_p, " <-I-> ", before_p)
        if (before_p / now_p) > SELL_MINUS:
            sell_inverse_only('MINUS')
        elif (now_p / before_p) > SELL_PLUS:
            sell_inverse_only('PLUS')
Exemplo n.º 5
0
def sell_kospi():  # 1:매도, 2: 매수

    writeLog(dt, '[매도]인버스매수 & 레버리지매도')
    # 테스트인 경우
    if isTest:
        return

    goto_sell = []
    # 현재 보유종목 가져오기
    stock_code, stocks = daishinTrade.getJango()

    # 미체결 있으면 해당 종목취소
    # 좀 나중에 개발..

    # 레버리지 매도
    for etf in etfLeverage:  # 레버리지 대상구매
        if etf in stock_code:
            goto_sell.append(etf)
        else:
            writeLog(" - 레버리지(", etf, ")는 잔고에 존재하지않습니다.")

    for other in etfOther:  # 레버리지 외의 다른종목 대상구매
        if other in stock_code:
            goto_sell.append(other)
        else:
            writeLog(" - ", other, "종목은 잔고에 존재하지않습니다.")

    # 매도(어떤가격으로 매도를 해야할지..)
    # goto_sell 매도
    writeLog(" - 매도대상 : ", goto_sell.__str__())

    # 1:매도, 2: 매수
    for sellCode in goto_sell:

        # 보유수량 확인
        amount = 0
        for s in stocks:
            if s['code'] == sellCode:
                amount = s['amount']
                break

        # 임시
        s = time.strftime('[%H:%M:%S]')
        s += '[매도]인버스매수 & 레버리지매도'
        telegram_bot.sendMsg(s)

        daishinTrade.goTrade(code=sellCode, bs='1', cnt=amount)

    # 인버스 매수
    for etf in etfInverse:  # 레버리지 대상구매
        if etf in stock_code:
            writeLog(" - 인버스(", etf, ")는 잔고에 존재합니다.")
        else:
            # 인버스 1000주 매수
            writeLog(" - 인버스 매수")
            daishinTrade.goTrade(code=etf, bs='2', cnt=1000)

    # 초기화
    init_tran_val()
Exemplo n.º 6
0
def sell_all_kospi():
    writeLog('[전량매도]')

    # 현재 보유종목 가져오기
    stock_code, stocks = daishinTrade.getJango()

    # 1:매도, 2: 매수
    for sellCode in stock_code:
        # 보유수량 확인
        amount = 0
        for s in stocks:
            if s['code'] == sellCode:
                amount = s['amount']
                break

        daishinTrade.goTrade(code=sellCode, bs='1', cnt=amount)

    if len(stock_code) == 0:
        writeLog('매도할 종목이 없습니다.')
    else:
        # 임시
        s = time.strftime('[%H:%M:%S]')
        s += '[전량매도]'
        telegram_bot.sendMsg(s)
Exemplo n.º 7
0
def buy_kospi():
    writeLog(dt, '[매수]레버리지 매수 & 인버스매도')
    # 테스트인 경우
    if isTest:
        return

    goto_buy = []

    # 현재 보유종목 가져오기
    stock_code, stocks = daishinTrade.getJango()

    # 미체결 있으면 해당 종목취소
    # 좀 나중에 개발..

    # 인버스 매도
    for etf in etfInverse:  # 인버스 대상매도
        if etf in stock_code:

            # 보유수량 확인
            amount = 0
            buyPrice = 0
            for s in stocks:
                if s['code'] == etf:
                    amount = s['amount']
                    buyPrice = s['buyPrice']
                    break

            writeLog(" - 인버스(", etf, ") 매도 : ", amount, '주, 매입가격 : ', buyPrice)

            # 임시
            s = time.strftime('[%H:%M:%S]')
            s += '[매수]레버리지 매수 & 인버스매도'
            telegram_bot.sendMsg(s)

            # 메도주문
            daishinTrade.goTrade(code=etf, bs='1', cnt=amount)

        else:
            writeLog(" - 인버스(", etf, ")는 잔고에 존재하지 않습니다.")

    # 레버리지 매수
    for etf in etfLeverage:  # 레버리지 대상구매
        if etf in stock_code:
            writeLog(" - 레버리지(", etf, ")는 잔고에 존재합니다.")
        else:
            goto_buy.append(etf)

    for other in etfOther:  # 레버리지 외의 다른종목 대상구매
        if other in stock_code:
            writeLog(" - ", other, "종목은 잔고에 존재합니다.")
        else:
            goto_buy.append(other)

    # 매수(어떤가격으로 매수를 해야할지..)
    # goto_buy 매수
    writeLog(" - 매수대상 : ", goto_buy.__str__())
    for stock in goto_buy:
        # 레버리지는 70주 나머지 종목은 10주
        amount = 10
        if stock == 'A122630':
            amount = 70

        daishinTrade.goTrade(code=stock, bs='2', cnt=amount)

    # 초기화
    init_tran_val()