init
This commit is contained in:
@@ -17,9 +17,12 @@ class HTS_122630:
|
||||
objCpCodeMgr = None
|
||||
|
||||
buySellChecker = None
|
||||
stock_code = None
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, stock_code):
|
||||
self.buySellChecker = BuySellChecker()
|
||||
self.stock_code = stock_code
|
||||
|
||||
#self.connect()
|
||||
return
|
||||
|
||||
@@ -545,8 +548,8 @@ class HTS_122630:
|
||||
|
||||
return 0, 0
|
||||
|
||||
def buyRealTime(self, stock_code, GIVEN_DAY):
|
||||
orderChecker = OrderChecker(stock_code)
|
||||
def buyRealTime(self, GIVEN_DAY):
|
||||
orderChecker = OrderChecker(self.stock_code)
|
||||
BASE_COUNT = 10
|
||||
|
||||
timecheckList = pd.read_csv("timecheck.csv").values.tolist()
|
||||
@@ -569,7 +572,7 @@ class HTS_122630:
|
||||
if THIS_TIME.strftime('%Y%m%d %H%M%S') in timecheck and not timecheck[THIS_TIME.strftime('%Y%m%d %H%M%S')]:
|
||||
|
||||
# 데이터를 가지고 온다.
|
||||
self.getRealTime(stock_code, GIVEN_DAY, result)
|
||||
self.getRealTime(self.stock_code, GIVEN_DAY, result)
|
||||
|
||||
# 분석을 통해서 볼린저밴드 상/하단을 계산한다.
|
||||
data = self.buySellChecker.analyze(result)
|
||||
@@ -584,12 +587,12 @@ class HTS_122630:
|
||||
BUY_COUNT = int(BASE_COUNT * 1)
|
||||
|
||||
# 매수를 주문한다.
|
||||
orderNum = self.requestOrder(OrderType.buy, stock_code, BUY_COUNT , bs_buy_price)
|
||||
orderNum = self.requestOrder(OrderType.buy, self.stock_code, BUY_COUNT , bs_buy_price)
|
||||
|
||||
# 미체결 기록을 가져온다.
|
||||
ORDER_LIST = self.requestOrderList()
|
||||
# 매수 주문을 기록한다.
|
||||
orderListToCancel = orderChecker.add(stock_code, OrderType.buy, orderNum, BUY_COUNT, bs_buy_price, ORDER_LIST)
|
||||
orderListToCancel = orderChecker.add(self.stock_code, OrderType.buy, orderNum, BUY_COUNT, bs_buy_price, ORDER_LIST)
|
||||
# 두 시간 이전 미체결을 모두 취소한다.
|
||||
self.cancelOrderList(orderListToCancel)
|
||||
# 로그 출력
|
||||
@@ -599,7 +602,7 @@ class HTS_122630:
|
||||
# 미체결 기록을 가져온다.
|
||||
ORDER_LIST = self.requestOrderList()
|
||||
# 매도 주문을 기록을 가져온다.
|
||||
orderListToCancel = orderChecker.remove(stock_code, OrderType.sell, ORDER_LIST)
|
||||
orderListToCancel = orderChecker.remove(self.stock_code, OrderType.sell, ORDER_LIST)
|
||||
# 매도 미체결을 모두 취소한다.
|
||||
self.cancelOrderList(orderListToCancel)
|
||||
|
||||
@@ -608,7 +611,7 @@ class HTS_122630:
|
||||
# 분석되 가격으로 매도 요청한다.
|
||||
if selling_count != 0 and selling_price != 0:
|
||||
# 매도를 요청한다.
|
||||
orderNum = self.requestOrder(OrderType.sell, stock_code, selling_count, selling_price)
|
||||
orderNum = self.requestOrder(OrderType.sell, self.stock_code, selling_count, selling_price)
|
||||
|
||||
# 로그 출력
|
||||
print("SELL", THIS_TIME.strftime('%Y%m%d %H%M%S'), selling_count, selling_price, len(orderListToCancel), len(ORDER_LIST))
|
||||
@@ -631,7 +634,7 @@ class HTS_122630:
|
||||
selling_count, selling_price = self.getSellingPrice(final_price)
|
||||
# 분석되 가격으로 매도 요청한다.
|
||||
if selling_count != 0 and selling_price != 0:
|
||||
orderNum = self.requestOrder(OrderType.sell, stock_code, selling_count, selling_price)
|
||||
orderNum = self.requestOrder(OrderType.sell, self.stock_code, selling_count, selling_price)
|
||||
# 로그 출력
|
||||
print("SELL", THIS_TIME, selling_count, selling_price)
|
||||
|
||||
@@ -649,11 +652,11 @@ if __name__ == "__main__":
|
||||
RESOURCE_DIR = PROJECT_HOME + "/resources/analysis/"+today.strftime("%Y%m%d")
|
||||
|
||||
# KODEX 인버스 * 2
|
||||
hts = HTS_122630()
|
||||
stock_codes = ["122630"]
|
||||
stock_code = "122630"
|
||||
hts = HTS_122630(stock_code)
|
||||
given_day = datetime.today().strftime('%Y%m%d')
|
||||
|
||||
#hts.writeStockData(stock_codes, "20211025")
|
||||
hts.buyRealTime(stock_codes[0], given_day)
|
||||
hts.buyRealTime(given_day)
|
||||
|
||||
print ("done...")
|
||||
|
||||
Reference in New Issue
Block a user