init
This commit is contained in:
@@ -307,6 +307,67 @@ class BuySellChecker:
|
|||||||
|
|
||||||
return buy, weight, sell
|
return buy, weight, sell
|
||||||
|
|
||||||
|
def getPriceAndWeight_1minute(self, data, i):
|
||||||
|
buy, weight, sell = -1, -1, -1
|
||||||
|
|
||||||
|
################
|
||||||
|
### sell 분석 ###
|
||||||
|
################
|
||||||
|
# 1. 볼린져밴드 상단이 최고와 종가 사이 아래에 있는 경우 매도한다.
|
||||||
|
if (data["high"][i] - data["close"][i]) / 2 + data["close"][i] > data["upper"][i]:
|
||||||
|
sell = data["high"][i]
|
||||||
|
|
||||||
|
if data["slow_k"][i] >= 85:
|
||||||
|
if data["slow_d"][i - 1] < data["slow_k"][i - 1] and data["slow_k"][i] < data["slow_d"][i]:
|
||||||
|
sell = data["high"][i]
|
||||||
|
|
||||||
|
# 3. 2시 이후에는 최고가가 볼린져밴드 상단 위에 있으면 매도한다.
|
||||||
|
if i > 300 and data["high"][i] > data["upper"][i]:
|
||||||
|
sell = data["high"][i]
|
||||||
|
|
||||||
|
##########################
|
||||||
|
### STOCHASTIC buy 분석 ###
|
||||||
|
##########################
|
||||||
|
if i < 40:
|
||||||
|
pre_slow = data["slow_k"][i - 1] / data["slow_d"][i - 1] - 1
|
||||||
|
now_slow = data["slow_k"][i] / data["slow_d"][i] - 1
|
||||||
|
if pre_slow < 0 and 0 < now_slow:
|
||||||
|
if data["slow_k"][i] <= 35:
|
||||||
|
if (data["close"][i] - data["lower"][i]) / (data["upper"][i] - data["lower"][i]) < 0.35:
|
||||||
|
if data["slow_k"][i - 1] < data["slow_d"][i - 1] and data["slow_d"][i] < data["slow_k"][i]:
|
||||||
|
if data['avg3'][i] <= data['avg2'][i]:
|
||||||
|
if data["open"][i] < data["close"][i]:
|
||||||
|
buy = data["close"][i]
|
||||||
|
else:
|
||||||
|
buy = data["low"][i]
|
||||||
|
else:
|
||||||
|
pre_slow = data["slow_k"][i - 1] / data["slow_d"][i - 1] - 1
|
||||||
|
now_slow = data["slow_k"][i] / data["slow_d"][i] - 1
|
||||||
|
if pre_slow < 0 and pre_slow < now_slow and -0.15 < now_slow:
|
||||||
|
if data["slow_k"][i] <= 10:
|
||||||
|
if (data["close"][i] - data["lower"][i]) / (data["upper"][i] - data["lower"][i]) < 0.35:
|
||||||
|
if data["slow_k"][i - 1] < data["slow_d"][i - 1] and data["slow_d"][i] < data["slow_k"][i]:
|
||||||
|
if data['avg3'][i] <= data['avg2'][i]:
|
||||||
|
if data["close"][i] < data["avg5"][i]:
|
||||||
|
buy = data["close"][i]
|
||||||
|
else:
|
||||||
|
buy = data["low"][i]
|
||||||
|
|
||||||
|
#############################
|
||||||
|
### STOCHASTIC weight 분석 ###
|
||||||
|
#############################
|
||||||
|
if data["slow_k"][i] in (0, 1, 2, 3):
|
||||||
|
weight = 1
|
||||||
|
if data["slow_k"][i] in (4, 5, 6, 7, 8):
|
||||||
|
weight = 1
|
||||||
|
elif data["slow_k"][i] in (9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20):
|
||||||
|
weight = 1
|
||||||
|
elif data["slow_k"][i] in (21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35):
|
||||||
|
weight = 1
|
||||||
|
|
||||||
|
return buy, weight, sell
|
||||||
|
|
||||||
|
|
||||||
def analyze(self, result):
|
def analyze(self, result):
|
||||||
df = pd.DataFrame(result["close"])
|
df = pd.DataFrame(result["close"])
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class HTS_252670:
|
|||||||
|
|
||||||
def all_stocks(self):
|
def all_stocks(self):
|
||||||
# 종목코드 리스트 구하기
|
# 종목코드 리스트 구하기
|
||||||
|
|
||||||
self.objCpCodeMgr = win32com.client.Dispatch("CpUtil.CpCodeMgr")
|
self.objCpCodeMgr = win32com.client.Dispatch("CpUtil.CpCodeMgr")
|
||||||
codeList = self.objCpCodeMgr.GetStockListByMarket(1) # 거래소
|
codeList = self.objCpCodeMgr.GetStockListByMarket(1) # 거래소
|
||||||
codeList2 = self.objCpCodeMgr.GetStockListByMarket(2) # 코스닥
|
codeList2 = self.objCpCodeMgr.GetStockListByMarket(2) # 코스닥
|
||||||
@@ -481,9 +482,9 @@ class HTS_252670:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
open = objStockChart.GetDataValue(2, i)
|
open = objStockChart.GetDataValue(2, i)
|
||||||
close = objStockChart.GetDataValue(5, i)
|
|
||||||
high = objStockChart.GetDataValue(3, i)
|
high = objStockChart.GetDataValue(3, i)
|
||||||
low = objStockChart.GetDataValue(4, i)
|
low = objStockChart.GetDataValue(4, i)
|
||||||
|
close = objStockChart.GetDataValue(5, i)
|
||||||
vol = objStockChart.GetDataValue(6, i)
|
vol = objStockChart.GetDataValue(6, i)
|
||||||
|
|
||||||
if len(result["check"]) == 0:
|
if len(result["check"]) == 0:
|
||||||
@@ -520,6 +521,7 @@ class HTS_252670:
|
|||||||
return -1, -1, -1
|
return -1, -1, -1
|
||||||
|
|
||||||
buy, weight, sell = self.buySellChecker.getPriceAndWeight1(data, i)
|
buy, weight, sell = self.buySellChecker.getPriceAndWeight1(data, i)
|
||||||
|
#buy, weight, sell = self.buySellChecker.getPriceAndWeight_1minute(data, i)
|
||||||
return buy, weight, sell
|
return buy, weight, sell
|
||||||
|
|
||||||
def getSellingPrice(self, final_price):
|
def getSellingPrice(self, final_price):
|
||||||
@@ -549,7 +551,7 @@ class HTS_252670:
|
|||||||
|
|
||||||
def buyRealTime(self, GIVEN_DAY):
|
def buyRealTime(self, GIVEN_DAY):
|
||||||
orderChecker = OrderChecker(self.stock_code)
|
orderChecker = OrderChecker(self.stock_code)
|
||||||
BASE_COUNT = 40
|
BASE_COUNT = 190
|
||||||
|
|
||||||
timecheckList = pd.read_csv("timecheck.csv").values.tolist()
|
timecheckList = pd.read_csv("timecheck.csv").values.tolist()
|
||||||
timecheck = {GIVEN_DAY + " " + str(second).zfill(6):False for second, check in timecheckList}
|
timecheck = {GIVEN_DAY + " " + str(second).zfill(6):False for second, check in timecheckList}
|
||||||
@@ -617,10 +619,12 @@ class HTS_252670:
|
|||||||
print("SELL", THIS_TIME.strftime('%Y%m%d %H%M%S'), selling_count, selling_price, len(orderListToCancel), len(ORDER_LIST))
|
print("SELL", THIS_TIME.strftime('%Y%m%d %H%M%S'), selling_count, selling_price, len(orderListToCancel), len(ORDER_LIST))
|
||||||
"""
|
"""
|
||||||
# 로그 출력
|
# 로그 출력
|
||||||
print("TIMECHECK: %s, price: %d, low: %d, lower: %.2f, avg5: %.2f, slow_k_1: %.2f, slow_d_1: %.2f, slow_k: %.2f, slow_d: %.2f, rsi: %.2f, rsis: %.2f" %
|
print("TIMECHECK: %s, price: %d, \n\t\t\topen: %d, close: %d, low: %d, high: %d, lower: %.2f, upper: %.2f, \n\t\t\tavg2: %.2f, avg3: %.2f, avg5: %.2f, \n\t\t\tslow_k_1: %.2f, slow_k: %.2f, slow_d_1: %.2f, slow_d: %.2f, \n\t\t\trsi_1: %.2f, rsis_1: %.2f, rsi: %.2f, rsis: %.2f" %
|
||||||
(str(THIS_TIME), final_price, data["low"][data_size-1], data["lower"][data_size-1], data["avg5"][data_size-1],
|
(str(THIS_TIME), final_price,
|
||||||
data["slow_k"][data_size-2], data["slow_d"][data_size-2], data["slow_k"][data_size-1], data["slow_d"][data_size-1],
|
data["open"][data_size-1], data["close"][data_size-1], data["low"][data_size-1], data["high"][data_size-1], data["lower"][data_size-1], data["upper"][data_size-1],
|
||||||
data["rsi"][data_size-1], data["rsis"][data_size-1]))
|
data["avg2"][data_size-1], data["avg3"][data_size-1], data["avg5"][data_size-1],
|
||||||
|
data["slow_k"][data_size-2], data["slow_k"][data_size-1], data["slow_d"][data_size-2], data["slow_d"][data_size-1],
|
||||||
|
data["rsi"][data_size-2], data["rsis"][data_size-2], data["rsi"][data_size-1], data["rsis"][data_size-1]))
|
||||||
timecheck[THIS_TIME] = True
|
timecheck[THIS_TIME] = True
|
||||||
"""
|
"""
|
||||||
if datetime.strptime(GIVEN_DAY + " 151530", '%Y%m%d %H%M%S') < THIS_TIME:
|
if datetime.strptime(GIVEN_DAY + " 151530", '%Y%m%d %H%M%S') < THIS_TIME:
|
||||||
|
|||||||
Reference in New Issue
Block a user