This commit is contained in:
dosangyoon
2021-08-19 22:50:10 +09:00
parent dc99180073
commit a32463e19a

View File

@@ -374,23 +374,30 @@ class Analyzer:
bottom = stock[i]['close'] bottom = stock[i]['close']
price = stock[i]['close'] price = stock[i]['close']
if len(stock) > 350: for i in range(180, 540):
for i in range(2, 350): if i > len(stock) or not stock[-i]:
if top < stock[-i]["close"]: break
top = stock[-i]["close"]
if stock[-i]["close"] < bottom: if top < stock[-i]["close"]:
bottom = stock[-i]["close"] top = stock[-i]["close"]
if stock[-i]["close"] < bottom:
bottom = stock[-i]["close"]
if top - bottom == 0: if top - bottom == 0:
energy = 100 energy = 100
else: else:
energy = (price - bottom) / (top - bottom) energy = round(((price - bottom) / (top - bottom)), 2)
return round(energy, 2) return energy
def writeFile(self, fig, state, isbuy, buy_price, bolingerband_score, stochastic_score, positionalEnergy, item_name, item_code): def writeFile(self, fig, state, isbuy, buy_price, bolingerband_score, stochastic_score, positionalEnergy, item_name, item_code):
if state != "":
fileName = self.status_path
fileName = "%s/%d__%s__p(%.2f)__b(%.2f)__s(%.2f)__%d__%s_%s.html" % (fileName, isbuy, state, positionalEnergy, bolingerband_score, stochastic_score, buy_price, item_name.replace(" ", ""), item_code)
po.write_html(fig, file=fileName, auto_open=False)
count = 0 count = 0
if bolingerband_score < 0.15: if bolingerband_score < 0.15:
fileName = self.bolingerband_path fileName = self.bolingerband_path
@@ -414,11 +421,6 @@ class Analyzer:
fileName = "%s/%d__p(%.2f)__b(%.2f)__s(%.2f)__%s__%d__%s_%s.html" % (fileName, isbuy, positionalEnergy, bolingerband_score, stochastic_score, state, buy_price, item_name.replace(" ", ""), item_code) fileName = "%s/%d__p(%.2f)__b(%.2f)__s(%.2f)__%s__%d__%s_%s.html" % (fileName, isbuy, positionalEnergy, bolingerband_score, stochastic_score, state, buy_price, item_name.replace(" ", ""), item_code)
po.write_html(fig, file=fileName, auto_open=False) po.write_html(fig, file=fileName, auto_open=False)
if state != "":
fileName = self.outPath
fileName = "%s/%d__%s__p(%.2f)__b(%.2f)__s(%.2f)__%d__%s_%s.html" % (fileName, isbuy, state, positionalEnergy, bolingerband_score, stochastic_score, buy_price, item_name.replace(" ", ""), item_code)
po.write_html(fig, file=fileName, auto_open=False)
return return
def makeDirectory(self, outPath): def makeDirectory(self, outPath):
@@ -442,6 +444,11 @@ class Analyzer:
os.rmdir(self.positionalEnergy_path) os.rmdir(self.positionalEnergy_path)
os.mkdir(self.positionalEnergy_path) os.mkdir(self.positionalEnergy_path)
self.status_path = outPath + "/status"
if os.path.isdir(self.status_path):
os.rmdir(self.status_path)
os.mkdir(self.status_path)
return return
# 그래프 출력 # 그래프 출력