This commit is contained in:
dsyoon
2021-10-05 17:38:54 +09:00
parent f38871c40f
commit e4d12343c9
3 changed files with 773 additions and 8 deletions

View File

@@ -857,7 +857,7 @@ class HTS:
def buyRealTime(self, stock_code, given_day):
PREVIOUS_PRICE = 0
BUY_COUNT = 200
BUY_COUNT = 100
TOTAL_BUY_AMT = 0
logFp = open(given_day+".log", "w")
@@ -894,23 +894,23 @@ class HTS:
if bs_buy_price > 0:
if PREVIOUS_PRICE > 0:
if PREVIOUS_PRICE > bs_buy_price:
if BUY_COUNT > 240:
BUY_COUNT = 240
if BUY_COUNT <= 140:
if BUY_COUNT > 140:
BUY_COUNT = 140
if BUY_COUNT <= 40:
BUY_COUNT = 40
BUY_COUNT += 10
elif PREVIOUS_PRICE < bs_buy_price:
if BUY_COUNT > 250:
BUY_COUNT = 260
if BUY_COUNT <= 150:
if BUY_COUNT > 160:
BUY_COUNT = 160
if BUY_COUNT <= 60:
BUY_COUNT = 60
BUY_COUNT -= 10
PREVIOUS_PRICE = bs_buy_price
# 매수 주문
# 현재까지 매입금액이 7백만원 이하일 때만 매수를 한다.
if TOTAL_BUY_AMT < 5000000:
if TOTAL_BUY_AMT < 2000000:
self.requestOrder("2", stock_code, BUY_COUNT , bs_buy_price)
## 매도 주문 (아래 잔고를 체크해서 매도를 호출하는 것으로 시도한다.)
@@ -975,6 +975,7 @@ if __name__ == "__main__":
#hts.simulate(stock_code, given_day)
given_day = datetime.today().strftime('%Y%m%d')
#hts.writeStockData(stock_codes, given_day)
hts.buyRealTime(stock_codes[0], given_day)
print ("done...")