init
This commit is contained in:
@@ -9,8 +9,12 @@ from BuySellChecker import BuySellChecker
|
||||
class Simulation:
|
||||
|
||||
buySellChecker = None
|
||||
def __init__(self):
|
||||
stock_code = None
|
||||
|
||||
def __init__(self, stock_code):
|
||||
|
||||
self.buySellChecker = BuySellChecker()
|
||||
self.stock_code = stock_code
|
||||
#self.connect()
|
||||
return
|
||||
|
||||
@@ -50,7 +54,10 @@ class Simulation:
|
||||
bsLine['sell'] = [-1 for i in range(size)]
|
||||
|
||||
for i in range(6, size-5):
|
||||
buy, weight, sell = self.buySellChecker.getPriceAndWeight1(data, i)
|
||||
if self.stock_code == "252670":
|
||||
buy, weight, sell = self.buySellChecker.getPriceAndWeight1(data, i)
|
||||
else:
|
||||
buy, weight, sell = self.buySellChecker.getPriceAndWeight2(data, i)
|
||||
bsLine['buy'][i] = buy
|
||||
bsLine['weight'][i] = weight
|
||||
bsLine['sell'][i] = sell
|
||||
@@ -139,7 +146,7 @@ class Simulation:
|
||||
|
||||
return
|
||||
|
||||
def simulate(self, stock_code, GIVEN_DAY):
|
||||
def simulate(self, GIVEN_DAY):
|
||||
result = {"check": set(),
|
||||
"time": [],
|
||||
"open": [],
|
||||
@@ -149,7 +156,7 @@ class Simulation:
|
||||
"vol": []}
|
||||
|
||||
# 데이터를 가지고 온다.
|
||||
self.getCSV("./data/"+stock_code+"_"+GIVEN_DAY+".csv", GIVEN_DAY, result)
|
||||
self.getCSV("./data/"+self.stock_code+"_"+GIVEN_DAY+".csv", GIVEN_DAY, result)
|
||||
|
||||
# 분석을 통해서 볼린저밴드 상/하단을 계산한다.
|
||||
data = self.buySellChecker.analyze(result)
|
||||
@@ -158,7 +165,7 @@ class Simulation:
|
||||
bsLine = self.checkTransaction(data)
|
||||
|
||||
# 그래프를 그린다.
|
||||
self.draw(stock_code, GIVEN_DAY, data, bsLine)
|
||||
self.draw(self.stock_code, GIVEN_DAY, data, bsLine)
|
||||
|
||||
return
|
||||
|
||||
@@ -174,12 +181,11 @@ if __name__ == "__main__":
|
||||
'20210914','20210915','20210916','20210917','20210923','20210924','20210927','20210928','20210929',
|
||||
'20210930','20211001','20211005','20211006','20211007','20211008','20211012','20211013','20211014',
|
||||
'20211018', '20211019','20211020','20211021','20211022']
|
||||
given_days = ['20211022']
|
||||
|
||||
simulation = Simulation()
|
||||
simulation = Simulation(stock_codes[1])
|
||||
|
||||
given_days = sorted(given_days, reverse=True)
|
||||
for given_day in given_days:
|
||||
simulation.simulate(stock_codes[0], given_day)
|
||||
simulation.simulate(given_day)
|
||||
|
||||
print ("done...")
|
||||
|
||||
Reference in New Issue
Block a user