From 522a5ff449596b256ff4c791bee235f42d118da1 Mon Sep 17 00:00:00 2001 From: dsyoon Date: Mon, 9 Oct 2023 22:45:45 +0900 Subject: [PATCH] init --- Simulation.py | 4 +-- hts/BuySellChecker.py | 65 ++++++++++++++++++++++--------------------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/Simulation.py b/Simulation.py index 5e79b59..e36d5e5 100644 --- a/Simulation.py +++ b/Simulation.py @@ -242,10 +242,10 @@ if __name__ == "__main__": stock_codes = { #"252670": ['20210924'], #"252670": ['20210901','20210902','20210903','20210906'], - #"252670": ['20210901', '20210902', '20210903', '20210906', '20210907', '20210908', '20210909', '20210910', '20210913', '20210914', '20210915', '20210916', '20210917', '20210923', '20210924', '20210927', '20210928', '20210929', '20210930', '20211001', '20211005'], + "252670": ['20210901', '20210902', '20210903', '20210906', '20210907', '20210908', '20210909', '20210910', '20210913', '20210914', '20210915', '20210916', '20210917', '20210923', '20210924', '20210927', '20210928', '20210929', '20210930', '20211001', '20211005'], #"122630": ['20220901', '20220902', '20220905', '20220906'] #"122630": ['20210916'], - "122630": ['20210901', '20210902', '20210903', '20210906', '20210907', '20210908', '20210909', '20210910', '20210913', '20210914', '20210915', '20210916', '20210917', '20210923', '20210924', '20210927', '20210928', '20210929', '20210930', '20211001', '20211005'], + #"122630": ['20210901', '20210902', '20210903', '20210906', '20210907', '20210908', '20210909', '20210910', '20210913', '20210914', '20210915', '20210916', '20210917', '20210923', '20210924', '20210927', '20210928', '20210929', '20210930', '20211001', '20211005'], } #simulation.simulate(stock_codes) simulation.simulate(stock_codes) diff --git a/hts/BuySellChecker.py b/hts/BuySellChecker.py index 6c040f3..1b3f5de 100644 --- a/hts/BuySellChecker.py +++ b/hts/BuySellChecker.py @@ -124,38 +124,6 @@ class BuySellChecker: return False - def getBuyPriceAndWeight_252670(self, i, data): - buy, weight = -1, -1 - - if i > 50: - up, down = 0, 0 - for idx in range(i, i - (300 + 1), -1): - if data['avg200'][idx-1] < data['avg200'][idx]: - up += 1 - if data['avg200'][idx-1] > data['avg200'][idx]: - down += 1 - if up < down: - if max(data['avg200'][i-20:i])+0.05 < data['avg200'][i]: - buy = data['close'][i] - weight = 0.3 - - up, down = 0, 0 - for idx in range(i, i - (10 + 1), -1): - if data['close'][idx-1] < data['close'][idx]: - up += 1 - elif data['close'][idx - 1] > data['close'][idx]: - down += 1 - if down < up: - buy, weight = -1, -1 - - if data['close'][i] < data['avg200'][i] or data['avg200'][i] + 10 < data['close'][i]: - buy, weight = -1, -1 - - if 2 < data['macd'][i]: - buy, weight = -1, -1 - - return buy, weight - def getBuyPriceAndWeight_122630(self, i, data): buy, weight = -1, -1 @@ -215,6 +183,39 @@ class BuySellChecker: return buy, weight + def getBuyPriceAndWeight_252670(self, i, data): + buy, weight = -1, -1 + + if i > 50: + up, down = 0, 0 + for idx in range(i, i - (300 + 1), -1): + if data['avg200'][idx-1] < data['avg200'][idx]: + up += 1 + if data['avg200'][idx-1] > data['avg200'][idx]: + down += 1 + if up < down: + if max(data['avg200'][i-20:i])+0.05 < data['avg200'][i]: + buy = data['close'][i] + weight = 0.3 + + up, down = 0, 0 + for idx in range(i, i - (10 + 1), -1): + if data['close'][idx-1] < data['close'][idx]: + up += 1 + elif data['close'][idx - 1] > data['close'][idx]: + down += 1 + if down < up: + buy, weight = -1, -1 + + if data['close'][i] < data['avg200'][i] or data['avg200'][i] + 10 < data['close'][i]: + buy, weight = -1, -1 + + if 2 < data['macd'][i]: + buy, weight = -1, -1 + + return buy, weight + + def getSellPriceAndWeight(self, i, data): sell, weight = -1, -1