This commit is contained in:
dsyoon
2023-02-18 11:05:06 +09:00
parent f72f1728e3
commit b5384ddc6f
2 changed files with 52 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ class HTS_Stocks (HTS):
self.conn_stock = sqlite3.connect(os.path.join(self.RESOURCE_PATH, "stock.db"))
self.cursor_stock = self.conn_stock.cursor()
return
def disconnectStockDB(self):
@@ -115,8 +116,22 @@ class HTS_Stocks (HTS):
return all_stocks, valid_company
def getSlowK(self, stock_code):
slow_k_week, slow_k_month = -1, -1
self.cursor_stock.execute('select stochastic_slow_k, max(ymd) from stock_analysis_weekly where code=? group by 1 order by ymd desc', (stock_code, ))
items = self.cursor_stock.fetchone()
if len(items)>0:
slow_k_week = items[0]
self.cursor_stock.execute('select stochastic_slow_k, max(ymd) from stock_analysis_monthly where code=? group by 1 order by ymd desc', (stock_code, ))
items = self.cursor_stock.fetchone()
if len(items)>0:
slow_k_month = items[0]
return slow_k_week, slow_k_month
def buyRealTime(self, today, n = 200):
a,b = self.getSlowK("001430")
print ("START...")
THIS_TIME = datetime.now()
@@ -144,6 +159,10 @@ class HTS_Stocks (HTS):
continue
print(idx, stock_code, stock_name, ", CODE: ", stock_code, ", NAME: ", stock_name)
slow_k_week, slow_k_month = self.getSlowK(stock_code)
if slow_k_week < 0 or 20 < slow_k_week or slow_k_month < 0 or 20 < slow_k_month:
continue
stock = self.stockStatus.fetchLastData(self.cursor_stock, stock_code, n)
try:
self.getRealTime_DailyCheck(today, stock_code, stock)