스토캐스틱, RSI 추가
This commit is contained in:
@@ -377,13 +377,13 @@ class Analyzer:
|
||||
|
||||
return status, buy_price
|
||||
|
||||
def getPositionalEnergy(self, stock, i):
|
||||
def getPositionalEnergy(self, stock, last_index):
|
||||
# 260 (= 52 * 5)일 중 가장 찾은 금액과 가장 높았던 금액 중 현재가의 위치 계산
|
||||
|
||||
top = stock[i]['close']
|
||||
bottom = stock[i]['close']
|
||||
top = stock[last_index]['close']
|
||||
bottom = stock[last_index]['close']
|
||||
|
||||
for i in range(8, 260):
|
||||
for i in range(1, 260):
|
||||
if i > len(stock) or not stock[-i]:
|
||||
break
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import re
|
||||
import json
|
||||
import sqlite3
|
||||
import requests
|
||||
import math
|
||||
|
||||
class Queue(object):
|
||||
def __init__(self, max):
|
||||
@@ -144,7 +145,8 @@ class StockCrawler:
|
||||
stocks.append({"NAME": 'KODEX 은행', "CODE": "091170", "PRICE": []})
|
||||
stocks.append({"NAME": 'TIGER 탄소효율그린뉴딜', "CODE": "376410", "PRICE": []})
|
||||
|
||||
for stock in stocks:
|
||||
for i, stock in enumerate(stocks):
|
||||
print (i, stock["NAME"], stock["CODE"])
|
||||
cursor.execute('SELECT * FROM ' + tableName + ' WHERE CODE=?', (stock["CODE"],))
|
||||
result = cursor.fetchone()
|
||||
if result != None:
|
||||
@@ -213,6 +215,8 @@ class StockCrawler:
|
||||
lastDay = ""
|
||||
if len(stock) > 0 and len(stock["PRICE"]) - 1 > 0:
|
||||
lastDay = stock["PRICE"][len(stock["PRICE"]) - 1]["DATE"].replace("-", ".")
|
||||
|
||||
date_set = set()
|
||||
lastPage = False
|
||||
# 1페이지에서 1000페이지의 데이터만 가져오기
|
||||
for page in range(1, self.limit_page_count):
|
||||
@@ -220,14 +224,23 @@ class StockCrawler:
|
||||
pg_url = '{url}&page={page}'.format(url=url, page=page)
|
||||
#html = pd.read_html(pg_url, header=0)
|
||||
html = pd.read_html(requests.get(pg_url, headers=self.header).text)
|
||||
count = 0
|
||||
for date in html[0].날짜.values:
|
||||
if type(date) is str:
|
||||
count += 1
|
||||
if date in date_set:
|
||||
lastPage = True
|
||||
break
|
||||
date_set.add(date)
|
||||
|
||||
if date == lastDay:
|
||||
lastPage = True
|
||||
df = df.append(html[0], ignore_index=True)
|
||||
break
|
||||
df = df.append(html[0], ignore_index=True)
|
||||
if lastPage:
|
||||
print("\t- lastpage:", page)
|
||||
break
|
||||
|
||||
"""
|
||||
if count == 10:
|
||||
df = df.append(html[0], ignore_index=True)
|
||||
if lastPage:
|
||||
@@ -238,6 +251,7 @@ class StockCrawler:
|
||||
lastPage = True
|
||||
else:
|
||||
break
|
||||
"""
|
||||
|
||||
# df.dropna()를 이용해 결측값 있는 행 제거
|
||||
df = df.dropna()
|
||||
|
||||
Reference in New Issue
Block a user