init
This commit is contained in:
33194
resources/상장법인목록.xls
33194
resources/상장법인목록.xls
File diff suppressed because it is too large
Load Diff
@@ -62,12 +62,15 @@ class Analyzer:
|
||||
cursor.execute('SELECT * FROM fnguide WHERE rowid=?', (rowid,))
|
||||
result = cursor.fetchone()
|
||||
while result != None:
|
||||
if result[2] == "227950":
|
||||
print (1)
|
||||
data = json.loads(result[2])
|
||||
self.fnguide[result[0]] = True
|
||||
|
||||
if (year1 in data and year2 in data and year3 in data):
|
||||
if (data[year1]['영업이익'] < 0 and data[year2]['영업이익'] < 0 and data[year3]['영업이익'] < 0):
|
||||
# 3년 연속 영업이익이 적자이면 매수하지 않는다.
|
||||
if (data[year1]['영업이익'] < 0 or data[year2]['영업이익'] < 0 or data[year3]['영업이익'] < 0):
|
||||
# and 3년 연속 영업이익이 적자이면 매수하지 않는다.
|
||||
# or: 3년 중 1번이라도 영업이익이 적자이면 매수하지 않는다.
|
||||
self.fnguide[result[0]] = False
|
||||
if (data[year1]['영업이익'] < -100):
|
||||
# 전년 영억적자가 100억 이상이면 매수하지 않는다.
|
||||
@@ -345,6 +348,12 @@ class Analyzer:
|
||||
status += eveningstar_status
|
||||
"""
|
||||
|
||||
# Potential Energy
|
||||
potential_energy_status = self.common.checkPotentialEnergy(STOCK, i)
|
||||
# 365일 중 가장 찾은 금액과 가장 높았던 금액 중 현재가의 위치 계산
|
||||
if potential_energy_status != "":
|
||||
status += potential_energy_status
|
||||
|
||||
return status, buy_price
|
||||
|
||||
# 그래프 출력
|
||||
|
||||
@@ -512,11 +512,32 @@ class Common:
|
||||
어제는 정배열이 아니었는데, 오늘은 정배열인 경우
|
||||
"""
|
||||
if len(stock) > 2:
|
||||
if (not (stock[i-1]["avg120"] < stock[i-1]["avg60"] < stock[i-1]["avg20"] < stock[i-1]["avg5"]) and
|
||||
(stock[i]["avg120"] < stock[i]["avg60"] < stock[i]["avg20"] < stock[i]["avg5"])):
|
||||
if not (stock[i - 1]["avg120"] < stock[i - 1]["avg60"] < stock[i - 1]["avg20"] < stock[i - 1]["avg5"]) and (stock[i]["avg120"] < stock[i]["avg60"] < stock[i]["avg20"] < stock[i]["avg5"]):
|
||||
return "arrange_"
|
||||
return ""
|
||||
|
||||
def checkPotentialEnergy(self, stock, i):
|
||||
# 365일 중 가장 찾은 금액과 가장 높았던 금액 중 현재가의 위치 계산
|
||||
|
||||
top = stock[i]['close']
|
||||
bottom = stock[i]['close']
|
||||
price = stock[i]['close']
|
||||
|
||||
if len(stock) > 365:
|
||||
for i in range(2, 365):
|
||||
if top < stock[-i]["close"]:
|
||||
top = stock[-i]["close"]
|
||||
|
||||
if stock[-i]["close"] < bottom:
|
||||
bottom = stock[-i]["close"]
|
||||
|
||||
if top - bottom > 0:
|
||||
energy = (price - bottom) / (top - bottom)
|
||||
if energy < 0.5:
|
||||
return "e(" + str(round(energy, 2)) + ")_"
|
||||
return ""
|
||||
|
||||
|
||||
def check_W1Rise(self, stock, i, limit):
|
||||
if len(stock) > 5:
|
||||
rate = round((stock[i]["close"] - stock[i-4]["close"]) / stock[i-4]["close"],2)
|
||||
|
||||
@@ -5,6 +5,7 @@ import time
|
||||
|
||||
from stockpredictor.crawler.toSQLite.MetaCrawler import MetaCrawler
|
||||
from stockpredictor.crawler.toSQLite.StockCrawler import StockCrawler
|
||||
from stockpredictor.crawler.toSQLite.FnGuideCrawler import FnGuideCrawler
|
||||
from stockpredictor.analysis.Analyzer import Analyzer
|
||||
|
||||
today = datetime.datetime.now().strftime("%Y-%m-%d")
|
||||
@@ -14,14 +15,13 @@ today = datetime.datetime.now().strftime("%Y-%m-%d")
|
||||
PROJECT_HOME = "../../.."
|
||||
|
||||
start = time.time()
|
||||
inFnguideFileName = PROJECT_HOME + '/resources/fnguide.db'
|
||||
"""
|
||||
inFnguideFileName = PROJECT_HOME + '/resources/fnguide.db'
|
||||
crawler = FnGuideCrawler()
|
||||
print("[KOSPI 상장기업 재무제표 다운로드]")
|
||||
crawler.crawl_fnguide(inFnguideFileName)
|
||||
"""
|
||||
|
||||
|
||||
crawler = MetaCrawler()
|
||||
print("\n[환율 (USD, JPY, EUR, CNY), 원유 (WTI), 국제금]")
|
||||
inFileName = PROJECT_HOME + '/resources/meta_1.db'
|
||||
@@ -59,7 +59,6 @@ inFileName = PROJECT_HOME + '/resources/stock.db'
|
||||
analyzer = Analyzer(PROJECT_HOME, inFileName, inFnguideFileName)
|
||||
analyzer.analyze()
|
||||
|
||||
|
||||
print("\n[종목 결정]")
|
||||
day = datetime.datetime.today().strftime("%Y%m%d")
|
||||
outPath = PROJECT_HOME + "/resources/analysis/" + day
|
||||
@@ -70,7 +69,6 @@ print("print to Html...")
|
||||
analyzer.analyzeToHtml(outPath)
|
||||
# E: 분석까지 진행
|
||||
|
||||
|
||||
print("time : %6.2f 초", (time.time() - start))
|
||||
|
||||
print ("done...")
|
||||
print ("done...")
|
||||
|
||||
@@ -12,7 +12,6 @@ class FnGuideCrawler:
|
||||
def getStockInfo(self):
|
||||
#code_df = pd.read_html('http://kind.krx.co.kr/corpgeneral/corpList.do?method=download&searchType=13', header=0)[0]
|
||||
code_df = pd.read_html(requests.get('http://kind.krx.co.kr/corpgeneral/corpList.do?method=download&searchType=13', headers=self.header).text)
|
||||
# code_df = pd.read_excel('../resources/stock/상장법인목록.xls')
|
||||
|
||||
# 종목코드가 6자리이기 때문에 6자리를 맞춰주기 위해 설정해줌
|
||||
code_df.종목코드 = code_df.종목코드.map('{:06d}'.format)
|
||||
|
||||
Reference in New Issue
Block a user