Skip to content
조회 수 1355 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

파이썬 키움증권 open api 분할매매 수식구하기

장시작 또는 현재가에서 지정한 투자금액에 따라 매수는 피라미드형, 매도는 역피라미드형으로 매매주문하기

 

 

 


#코스피
#5,000 ~ 10,000 = 10#10,000 ~ 50,000 = 50#50,000 ~ 100,000 = 100#100,000 ~ 500,000 = 500#500,000 ~ 1,000,000 = 1000
#코스닥
#5,000 ~ 10,000 = 10#10,000 ~ 50,000 = 50#50,000 ~ 100원단위

order_money=5100                                 #현재가
max_order_money=1000000                          #총매매금액
mom_ea=int(round(max_order_money/order_money,0)) #총매매금액 나누기 현재가 = 총매매 수량

print("총매매 주식수 : ",mom_ea)
sellbuy_ea=[]
rate_sb=0.027

for i in range(0,10):
    sellbuy_ea.append(int(mom_ea*rate_sb))
    rate_sb = (rate_sb + 0.008) * 1.115

temp=0
for i in range(0,10):
    temp=temp+sellbuy_ea[i]
    temp1=order_money*temp
print("실투자수량:",temp,"실투자금액:",temp1)
print("매수호가주문수량",sellbuy_ea)


#0.5% ~ 10%까지의 매수호가/매도호가 생성
sell_m=[]
buy_m=[]
rate_v=0.005
for i in range(0,20):
    sell_m.append(order_money + order_money * rate_v)
    buy_m.append(order_money - order_money * rate_v)
    rate_v = rate_v + 0.005
#print("매도호가",sell_m)
#0.5% ~ 10%까지의 폭


## 호가를 자리수에따라 반올림하면서 정수화 함.
buyQ=[]
sellQ=[]
for i in range(0,len(buy_m)):
    if buy_m[i] < 1000:
        buyQ.append(int(round(buy_m[i], 0)))
    elif buy_m[i] < 5000:
        buyQ.append(int(round(buy_m[i], -1)))
    elif buy_m[i] < 10000:
        buyQ.append(int(round(buy_m[i], -1)))
    elif buy_m[i] < 50000:
        buyQ.append(int(round(buy_m[i], -2)))
    elif buy_m[i] < 100000:
        buyQ.append(int(round(buy_m[i], -2)))
    elif buy_m[i] < 500000:
        buyQ.append(int(round(buy_m[i], -3)))
    elif buy_m[i] < 1000000:
        buyQ.append(int(round(buy_m[i], -3)))

for i in range(0,len(sell_m)):
    if sell_m[i] < 1000:
        sellQ.append(int(round(sell_m[i], 0)))
    elif sell_m[i] < 5000:
        sellQ.append(int(round(sell_m[i], -1)))
    elif sell_m[i] < 10000:
        sellQ.append(int(round(sell_m[i], -1)))
    elif sell_m[i] < 50000:
        sellQ.append(int(round(sell_m[i], -2)))
    elif sell_m[i] < 100000:
        sellQ.append(int(round(sell_m[i], -2)))
    elif sell_m[i] < 500000:
        sellQ.append(int(round(sell_m[i], -3)))
    elif sell_m[i] < 1000000:
        sellQ.append(int(round(sell_m[i], -3)))

print("매도호가:",sellQ,"\n매수호가:",buyQ)


## 상한가 구하기
highlow = 0.28
max_money=order_money + order_money * highlow
min_money=order_money - order_money * highlow
#print(order_money,max_money,min_money)

## 상한가 자리수에 따라 반올림하고 정수화하기
if order_money < 1000:
    max_money = int(round(order_money + order_money * highlow, 0))
    min_money = int(round(order_money - order_money * highlow, 0))
    print('현재가:',order_money,'상한가:',max_money,'하한가:',min_money)

if order_money < 5000:
    max_money = int(round(order_money + order_money * highlow, -1))
    min_money = int(round(order_money - order_money * highlow, -1))
    print('현재가:',order_money,'상한가:',max_money,'하한가:',min_money)

elif order_money < 10000:
    max_money = int(round(order_money + order_money * highlow, -1))
    min_money = int(round(order_money - order_money * highlow, -1))
    print('현재가:',order_money,'상한가:',max_money,'하한가:',min_money)

elif order_money < 50000:
    max_money = int(round(order_money + order_money * highlow, -2))
    min_money = int(round(order_money - order_money * highlow, -2))
    print('현재가:',order_money,'상한가:',max_money,'하한가:',min_money)

elif order_money < 100000:
    max_money = int(round(order_money + order_money * highlow, -3))
    min_money = int(round(order_money - order_money * highlow, -3))
    print('현재가:',order_money,'상한가:',max_money,'하한가:',min_money)

elif order_money < 500000:
    max_money = int(round(order_money + order_money * highlow, -4))
    min_money = int(round(order_money - order_money * highlow, -4))
    print('현재가:',order_money,'상한가:',max_money,'하한가:',min_money)

elif order_money < 1000000:
    max_money = int(round(order_money + order_money * highlow, -5))
    min_money = int(round(order_money - order_money * highlow, -5))
    print('현재가:',order_money,'상한가:',max_money,'하한가:',min_money)
    
로그인 후 댓글쓰기가 가능합니다.

?

List of Articles
번호 분류 제목 날짜 조회 수
77 AutoHotKey autohotkey)매월 1일의 요일 구하기 1 2013.01.27 15286
76 AutoHotKey autohotkey) 화면보호기, 바탕화면 control 창 열기 3 2012.03.17 8367
75 AutoHotKey Autohotkey) 화면보호기(ScreenSaver) On/Off 방법 17 2012.03.16 40728
74 AutoHotKey autohotkey) 화면보호기 실행 전 클릭으로 화면보호 안걸리게 하기 2012.03.15 8879
73 AutoHotKey autohotkey) 핑테스트 프로그램 1 file 2011.12.31 18956
72 AutoHotKey autohotkey) 편입 변수 4 2012.03.13 28920
71 AutoHotKey autohotkey) 파일리스트 가져오기 3 2012.11.26 15003
70 AutoHotKey autohotkey) 윈도우 ahk_id 추출하기 2 2012.03.06 30102
69 AutoHotKey autohotkey) 웹페이지의 프레임 내용보기 & 클릭하기 2011.11.29 15155
68 AutoHotKey autohotkey) 오토핫키에서 자주쓰는 함수모음 2013.10.30 33721
67 AutoHotKey autohotkey) 스크린세이버 활성화 / 비활성화 시키기. 2012.03.17 8060
66 AutoHotKey autohotkey) 맥어드레스 추출 2 2011.12.21 15086
65 AutoHotKey autohotkey) 런처시스템 3 2012.05.30 14303
64 AutoHotKey autohotkey) 네 코드를 보여, 내가 당신에게서 배우고 싶어요 1 2012.01.08 15118
63 AutoHotKey autohotkey) WinSpector spy를 이용한 post,sendmessage Control ID 추출하기 3 file 2012.02.22 10909
62 AutoHotKey autohotkey) Virus? 6 2011.12.31 34687
61 AutoHotKey autohotkey) postmessage mouse control 13 2012.02.22 28639
60 AutoHotKey autohotkey) Mutex에 대해서 1 4 2011.12.31 24131
59 AutoHotKey autohotkey) IPv6 모두 사용안함 설정하기 1 file 2011.12.30 19137
58 AutoHotKey Autohotkey) Find WM_COMMAND parameter with Winspector 17 2012.02.22 35877
Board Pagination Prev 1 ... 41 42 43 44 45 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소