This commit is contained in:
dsyoon
2023-03-08 22:05:17 +09:00
parent a9a9bc2f40
commit ad1e0fe959

View File

@@ -32,69 +32,75 @@ week = datetime.today().weekday()
slackBot = SlackBot() slackBot = SlackBot()
error_count = 0
if week in (0, 1, 2, 3, 4): # 0:월, 1:화, 2:수, 3:목, 4:금, 5:토, 6:일 if week in (0, 1, 2, 3, 4): # 0:월, 1:화, 2:수, 3:목, 4:금, 5:토, 6:일
# 재무제표는 3개월마다 다운로드를 한다. while error_count < 3:
fnGuideCrawler = FnGuideCrawler(START_DATE) try:
print("[KOSPI 상장기업 재무제표 다운로드]") # 재무제표는 3개월마다 다운로드를 한다.
fnGuideCrawler.crawl_fnguide(stockFileName) fnGuideCrawler = FnGuideCrawler(START_DATE)
print("[KOSPI 상장기업 재무제표 다운로드]")
fnGuideCrawler.crawl_fnguide(stockFileName)
metaCrawler = MetaCrawler(START_DATE) metaCrawler = MetaCrawler(START_DATE)
print("\n[증시자금동향 (신용잔고, 펀드자금 잔고)]") print("\n[증시자금동향 (신용잔고, 펀드자금 잔고)]")
metaCrawler.crawl_money_trend(stockFileName) metaCrawler.crawl_money_trend(stockFileName)
print("\n[국내 시장금리]") print("\n[국내 시장금리]")
metaCrawler.crawl_interest_rates(stockFileName) metaCrawler.crawl_interest_rates(stockFileName)
print("\n[투자자별 매매동향(Trading_Trend)]") print("\n[투자자별 매매동향(Trading_Trend)]")
metaCrawler.crawl_trading_trend(stockFileName) metaCrawler.crawl_trading_trend(stockFileName)
print("\n[환율 (USD, JPY, EUR, CNY)]") print("\n[환율 (USD, JPY, EUR, CNY)]")
metaCrawler.crawl_exchange(stockFileName) metaCrawler.crawl_exchange(stockFileName)
print("\n[원유 (WTI), 국제금, COPPER, NATURALGAS, CORN, SOYBEAN]") print("\n[원유 (WTI), 국제금, COPPER, NATURALGAS, CORN, SOYBEAN]")
metaCrawler.crawl_meterials(stockFileName) metaCrawler.crawl_meterials(stockFileName)
print("\n[종목 다운로드]") print("\n[종목 다운로드]")
stockCrawler = StockCrawler(START_DATE) stockCrawler = StockCrawler(START_DATE)
stockCrawler.crawl_etf_stocks(stockFileName) stockCrawler.crawl_etf_stocks(stockFileName)
stockCrawler.crawl_stocks(stockFileName) stockCrawler.crawl_stocks(stockFileName)
stockCrawler.crawl_special_stocks(stockFileName) stockCrawler.crawl_special_stocks(stockFileName)
print("\n[종목 분석]") print("\n[종목 분석]")
# S: 분석까지 진행 # S: 분석까지 진행
inFileName = PROJECT_HOME + '/resources/stock.db' inFileName = PROJECT_HOME + '/resources/stock.db'
analyzerSqlite = AnalyzerSqlite(stockFileName) analyzerSqlite = AnalyzerSqlite(stockFileName)
stockStatus = StockStatus(RESOURCE_PATH) stockStatus = StockStatus(RESOURCE_PATH)
analyzerSqlite.analyzeDaily() analyzerSqlite.analyzeDaily()
analyzerSqlite.analyzeGrouping("weekly") analyzerSqlite.analyzeGrouping("weekly")
analyzerSqlite.analyzeGrouping("monthly") analyzerSqlite.analyzeGrouping("monthly")
print("\n[종목 결정]") print("\n[종목 결정]")
# 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):
os.mkdir(outPath) os.mkdir(outPath)
day = datetime.today().strftime("%Y%m%d") day = datetime.today().strftime("%Y%m%d")
before_7_day = datetime.today() + relativedelta(days=-7) before_7_day = datetime.today() + relativedelta(days=-7)
dayList = os.listdir(outPath) dayList = os.listdir(outPath)
for dayDir in dayList: for dayDir in dayList:
if dayDir[0] != '.' and dayDir < before_7_day.strftime("%Y%m%d"): if dayDir[0] != '.' and dayDir < before_7_day.strftime("%Y%m%d"):
if os.path.exists(os.path.join(outPath, dayDir)): if os.path.exists(os.path.join(outPath, dayDir)):
shutil.rmtree(os.path.join(outPath, dayDir)) shutil.rmtree(os.path.join(outPath, dayDir))
outPath = os.path.join(outPath, day) outPath = os.path.join(outPath, day)
if os.path.isdir(outPath): if os.path.isdir(outPath):
shutil.rmtree(outPath) shutil.rmtree(outPath)
os.mkdir(outPath) os.mkdir(outPath)
analyzerSqlite.findCandidates(outPath) analyzerSqlite.findCandidates(outPath)
stockStatus.findCandidates(outPath) stockStatus.findCandidates(outPath)
slackBot.sendMsg("Done. Crawling...") slackBot.sendMsg("Done. Crawling...")
except:
error_count += 1
continue
print("time : %6.2f", (time.time() - start)) print("time : %6.2f", (time.time() - start))
print ("done...") print ("done...")