init
This commit is contained in:
@@ -43,22 +43,27 @@ class HTS_etf(HTS):
|
|||||||
if jangoDic and len(jangoDic.keys()) > 0:
|
if jangoDic and len(jangoDic.keys()) > 0:
|
||||||
for code in jangoDic:
|
for code in jangoDic:
|
||||||
if stock_code is not None:
|
if stock_code is not None:
|
||||||
if code == "A" + stock_code and bs_sell_price is not None:
|
if code == "A" + stock_code:
|
||||||
if jangoDic[code]['매도가능'] > 0:
|
if bs_sell_price is not None:
|
||||||
if jangoDic[code]['평가손익'] < -1.5 or 2 < jangoDic[code]['평가손익']:
|
if jangoDic[code]['매도가능'] > 0:
|
||||||
# 1.5% 손해 혹은 2% 이상 시 수익 매도
|
if jangoDic[code]['평가손익'] < -1.5 or 3 < jangoDic[code]['평가손익']:
|
||||||
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], bs_sell_price)
|
# 1.5% 손해 혹은 2% 이상 시 수익 매도
|
||||||
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", bs_sell_price, jangoDic[code]['매도가능'])
|
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], bs_sell_price)
|
||||||
check = True
|
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", bs_sell_price, jangoDic[code]['매도가능'])
|
||||||
else:
|
check = True
|
||||||
continue
|
else:
|
||||||
|
if jangoDic[code]['매도가능'] > 0:
|
||||||
|
if jangoDic[code]['평가손익'] < -1.5 or 3 < jangoDic[code]['평가손익']:
|
||||||
|
# 1.5% 손해 혹은 2% 이상 시 수익 매도
|
||||||
|
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], jangoDic[code]['현재가'])
|
||||||
|
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", jangoDic[code]['현재가'], jangoDic[code]['매도가능'])
|
||||||
|
check = True
|
||||||
else:
|
else:
|
||||||
if jangoDic[code]['매도가능'] > 0:
|
if jangoDic[code]['매도가능'] > 0:
|
||||||
if jangoDic[code]['평가손익'] < -1.5 or 2 < jangoDic[code]['평가손익']:
|
if jangoDic[code]['평가손익'] < -1.5 or 3 < jangoDic[code]['평가손익']:
|
||||||
# 1.5% 손해 혹은 2% 이상 시 수익 매도
|
# 1.5% 손해 혹은 2% 이상 시 수익 매도
|
||||||
currentStock = self.currentStock(code[1:])
|
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], jangoDic[code]['현재가'])
|
||||||
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], currentStock['close'])
|
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", jangoDic[code]['현재가'], jangoDic[code]['매도가능'])
|
||||||
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", currentStock['close'], jangoDic[code]['매도가능'])
|
|
||||||
check = True
|
check = True
|
||||||
return check
|
return check
|
||||||
|
|
||||||
@@ -120,7 +125,7 @@ class HTS_etf(HTS):
|
|||||||
if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'):
|
if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'):
|
||||||
|
|
||||||
# 매도를 체크한다.
|
# 매도를 체크한다.
|
||||||
self.sellStocks()
|
self.sellStocks(stock_code)
|
||||||
|
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
|||||||
@@ -44,22 +44,27 @@ class HTS_etf(HTS):
|
|||||||
if jangoDic and len(jangoDic.keys()) > 0:
|
if jangoDic and len(jangoDic.keys()) > 0:
|
||||||
for code in jangoDic:
|
for code in jangoDic:
|
||||||
if stock_code is not None:
|
if stock_code is not None:
|
||||||
if code == "A" + stock_code and bs_sell_price is not None:
|
if code == "A" + stock_code:
|
||||||
if jangoDic[code]['매도가능'] > 0:
|
if bs_sell_price is not None:
|
||||||
if jangoDic[code]['평가손익'] < -1.5 or 3 < jangoDic[code]['평가손익']:
|
if jangoDic[code]['매도가능'] > 0:
|
||||||
# 1.5% 손해 혹은 2% 이상 시 수익 매도
|
if jangoDic[code]['평가손익'] < -1.5 or 3 < jangoDic[code]['평가손익']:
|
||||||
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], bs_sell_price)
|
# 1.5% 손해 혹은 2% 이상 시 수익 매도
|
||||||
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", bs_sell_price, jangoDic[code]['매도가능'])
|
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], bs_sell_price)
|
||||||
check = True
|
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", bs_sell_price, jangoDic[code]['매도가능'])
|
||||||
else:
|
check = True
|
||||||
continue
|
else:
|
||||||
|
if jangoDic[code]['매도가능'] > 0:
|
||||||
|
if jangoDic[code]['평가손익'] < -1.5 or 3 < jangoDic[code]['평가손익']:
|
||||||
|
# 1.5% 손해 혹은 2% 이상 시 수익 매도
|
||||||
|
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], jangoDic[code]['현재가'])
|
||||||
|
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", jangoDic[code]['현재가'], jangoDic[code]['매도가능'])
|
||||||
|
check = True
|
||||||
else:
|
else:
|
||||||
if jangoDic[code]['매도가능'] > 0:
|
if jangoDic[code]['매도가능'] > 0:
|
||||||
if jangoDic[code]['평가손익'] < -1.5 or 3 < jangoDic[code]['평가손익']:
|
if jangoDic[code]['평가손익'] < -1.5 or 3 < jangoDic[code]['평가손익']:
|
||||||
# 1.5% 손해 혹은 2% 이상 시 수익 매도
|
# 1.5% 손해 혹은 2% 이상 시 수익 매도
|
||||||
currentStock = self.currentStock(code[1:])
|
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], jangoDic[code]['현재가'])
|
||||||
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], currentStock['close'])
|
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", jangoDic[code]['현재가'], jangoDic[code]['매도가능'])
|
||||||
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", currentStock['close'], jangoDic[code]['매도가능'])
|
|
||||||
check = True
|
check = True
|
||||||
return check
|
return check
|
||||||
|
|
||||||
@@ -121,7 +126,7 @@ class HTS_etf(HTS):
|
|||||||
if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'):
|
if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'):
|
||||||
|
|
||||||
# 매도를 체크한다.
|
# 매도를 체크한다.
|
||||||
self.sellStocks()
|
self.sellStocks(stock_code)
|
||||||
|
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ class BuySellChecker:
|
|||||||
|
|
||||||
def checkTransaction(self, stock_code, data, data_5=None, data_30=None, isRealTime=True):
|
def checkTransaction(self, stock_code, data, data_5=None, data_30=None, isRealTime=True):
|
||||||
# 어제 오늘 데이터로 분석
|
# 어제 오늘 데이터로 분석
|
||||||
bsLine = {stock_code: {}}
|
bsLine = {}
|
||||||
|
|
||||||
size = len(data["close"])
|
size = len(data["close"])
|
||||||
|
|
||||||
@@ -367,19 +367,10 @@ class BuySellChecker:
|
|||||||
if 'last' in bsLine and bsLine['last'] != 'buy':
|
if 'last' in bsLine and bsLine['last'] != 'buy':
|
||||||
sell, weight = -1, -1
|
sell, weight = -1, -1
|
||||||
|
|
||||||
bsLine['buy'][last_index] = buy
|
bsLine['buy'] = [buy]
|
||||||
bsLine['buy_weight'][last_index] = buy_weight
|
bsLine['buy_weight'] = [buy_weight]
|
||||||
bsLine['sell'][last_index] = sell
|
bsLine['sell'] = [sell]
|
||||||
bsLine['sell_weight'][last_index] = sell_weight
|
bsLine['sell_weight'] = [sell_weight]
|
||||||
|
|
||||||
if buy > 0:
|
|
||||||
bsLine['last'] = 'buy'
|
|
||||||
bsLine['last_buy'] = buy
|
|
||||||
bsLine['buy_count'] += 1
|
|
||||||
if sell > 0:
|
|
||||||
bsLine['last'] = 'sell'
|
|
||||||
bsLine['last_buy'] = -1
|
|
||||||
bsLine['buy_count'] = 0
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Type=False, 시뮬레이션 적용
|
# Type=False, 시뮬레이션 적용
|
||||||
|
|||||||
Reference in New Issue
Block a user