init
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import os
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
import pandas as pd
|
||||
import plotly.graph_objects as go
|
||||
from plotly import subplots
|
||||
@@ -133,7 +133,20 @@ class Simulation:
|
||||
|
||||
return
|
||||
|
||||
def simulate(self, stock_code, given_day):
|
||||
def getAverageVolume(self, stock_code):
|
||||
index = 0
|
||||
while index < 10:
|
||||
this_day = datetime.today() - timedelta(days=index+1)
|
||||
fileName = "./data/"+stock_code+"_"+this_day.strftime("%Y%m%d")+".csv"
|
||||
#fileName = "./data/" + stock_code + "_20211013.csv"
|
||||
if os.path.isfile(fileName):
|
||||
data = pd.read_csv(fileName)
|
||||
return data
|
||||
index += 1
|
||||
|
||||
return 2000000
|
||||
|
||||
def simulate(self, stock_code, GIVEN_DAY):
|
||||
result = {"check": set(),
|
||||
"time": [],
|
||||
"open": [],
|
||||
@@ -142,8 +155,10 @@ class Simulation:
|
||||
"low": [],
|
||||
"vol": []}
|
||||
|
||||
averageVolume = self.getAverageVolume(stock_code)
|
||||
|
||||
# 데이터를 가지고 온다.
|
||||
self.getCSV("./data/"+stock_code+"_"+given_day+".csv", given_day, result)
|
||||
self.getCSV("./data/"+stock_code+"_"+GIVEN_DAY+".csv", GIVEN_DAY, result)
|
||||
|
||||
# 분석을 통해서 볼린저밴드 상/하단을 계산한다.
|
||||
data = self.buySellChecker.analyze(result)
|
||||
@@ -152,7 +167,7 @@ class Simulation:
|
||||
bsLine = self.checkTransaction(data)
|
||||
|
||||
# 그래프를 그린다.
|
||||
self.draw(stock_code, given_day, data, bsLine)
|
||||
self.draw(stock_code, GIVEN_DAY, data, bsLine)
|
||||
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user