init
This commit is contained in:
@@ -17,7 +17,6 @@ from plotly import subplots
|
|||||||
import plotly.io as po
|
import plotly.io as po
|
||||||
|
|
||||||
from stock.analysis.Common import Common
|
from stock.analysis.Common import Common
|
||||||
from stock.analysis.RelativePerformance import RelativePerformance
|
|
||||||
from stock.analysis.Stochastic import Stochastic
|
from stock.analysis.Stochastic import Stochastic
|
||||||
from stock.analysis.BolingerBand import BolingerBand
|
from stock.analysis.BolingerBand import BolingerBand
|
||||||
from stock.analysis.IchimokuCloud import IchimokuCloud
|
from stock.analysis.IchimokuCloud import IchimokuCloud
|
||||||
@@ -30,7 +29,6 @@ from hts.BuySellChecker import BuySellChecker
|
|||||||
|
|
||||||
|
|
||||||
class AnalyzerSqlite:
|
class AnalyzerSqlite:
|
||||||
relativePerformance = None
|
|
||||||
stochastic = None
|
stochastic = None
|
||||||
bolingerBand = None
|
bolingerBand = None
|
||||||
ichimokuCloud = None
|
ichimokuCloud = None
|
||||||
@@ -52,7 +50,6 @@ class AnalyzerSqlite:
|
|||||||
def __init__(self, stockFileName=None):
|
def __init__(self, stockFileName=None):
|
||||||
self.common = Common()
|
self.common = Common()
|
||||||
|
|
||||||
self.relativePerformance = RelativePerformance()
|
|
||||||
self.stochastic = Stochastic()
|
self.stochastic = Stochastic()
|
||||||
self.bolingerBand = BolingerBand()
|
self.bolingerBand = BolingerBand()
|
||||||
self.ichimokuCloud = IchimokuCloud()
|
self.ichimokuCloud = IchimokuCloud()
|
||||||
@@ -935,60 +932,6 @@ class AnalyzerSqlite:
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def analyzeRP (self):
|
|
||||||
|
|
||||||
type = {200:None, 52: "weekly", 12: "monthly"}
|
|
||||||
limits = [200, 52, 12]
|
|
||||||
|
|
||||||
for limit in limits:
|
|
||||||
if type[limit]==None:
|
|
||||||
stockAnalysisTableName = 'stock_analysis'
|
|
||||||
else:
|
|
||||||
stockAnalysisTableName = 'stock_analysis_' + type[limit]
|
|
||||||
|
|
||||||
conn = sqlite3.connect(self.stockFileName)
|
|
||||||
cursor = conn.cursor()
|
|
||||||
|
|
||||||
# S: Kospi 구하기 (RP 계산을 위함)
|
|
||||||
kospi = {"CODE": "^KS11", "NAME": "Kospi", "PRICE": []}
|
|
||||||
sql = "SELECT CODE, NAME, ymd, close, diff, open, high, low, volume, avg200 FROM " + stockAnalysisTableName + " where CODE=? order by ymd desc "
|
|
||||||
sql += ' limit ' + str(limit)
|
|
||||||
cursor.execute(sql, (kospi['CODE'],))
|
|
||||||
items = cursor.fetchall()
|
|
||||||
|
|
||||||
items_reverse = reversed(items)
|
|
||||||
for item in items_reverse:
|
|
||||||
kospi['PRICE'].append(self.setItem(item))
|
|
||||||
# E: Kospi 구하기 (RP 계산을 위함)
|
|
||||||
|
|
||||||
# S: 종목 구하기
|
|
||||||
cursor.execute('SELECT distinct code, name FROM ' + stockAnalysisTableName + ' order by code')
|
|
||||||
items = cursor.fetchall()
|
|
||||||
|
|
||||||
for rowid, item in enumerate(items):
|
|
||||||
|
|
||||||
stock = {"CODE": item[0], "NAME": item[1], "PRICE": []}
|
|
||||||
print("Daily # :", rowid, ", CODE: ", stock['CODE'], ", NAME: ", stock['NAME'])
|
|
||||||
|
|
||||||
sql = "SELECT CODE, NAME, ymd, close, diff, open, high, low, volume, avg200 FROM " + stockAnalysisTableName + " where CODE=? order by ymd desc "
|
|
||||||
sql += ' limit ' + str(limit)
|
|
||||||
cursor.execute(sql, (stock['CODE'],))
|
|
||||||
items = cursor.fetchall()
|
|
||||||
|
|
||||||
items_reverse = reversed(items)
|
|
||||||
for item in items_reverse:
|
|
||||||
stock['PRICE'].append(self.setItem(item))
|
|
||||||
|
|
||||||
self.relativePerformance.analyze(stock, kospi)
|
|
||||||
|
|
||||||
sql = "UPDATE " + stockAnalysisTableName + " SET rp=? WHERE CODE=? and ymd=?"
|
|
||||||
|
|
||||||
cursor.execute(sql, (price['rp'], stock["CODE"], price['ymd'],))
|
|
||||||
|
|
||||||
cursor.execute("commit",)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
@@ -1002,8 +945,6 @@ if __name__ == "__main__":
|
|||||||
#analyzer.analyzeGrouping("weekly")
|
#analyzer.analyzeGrouping("weekly")
|
||||||
#analyzer.analyzeGrouping("monthly")
|
#analyzer.analyzeGrouping("monthly")
|
||||||
|
|
||||||
#analyzer.analyzeRP()
|
|
||||||
|
|
||||||
# HTML 출력
|
# HTML 출력
|
||||||
outPath = os.path.join(PROJECT_HOME, "resources", "analysis")
|
outPath = os.path.join(PROJECT_HOME, "resources", "analysis")
|
||||||
if not os.path.isdir(outPath):
|
if not os.path.isdir(outPath):
|
||||||
|
|||||||
Reference in New Issue
Block a user