chore: remove unused.

This commit is contained in:
monoid 2023-07-25 18:18:06 +09:00
parent f089a04ef4
commit d31855785d
6 changed files with 9 additions and 153 deletions

View File

@ -1,3 +1,5 @@
# Stock # Stock
[![Made with Fresh](https://fresh.deno.dev/fresh-badge.svg)](https://fresh.deno.dev)
주식 데이터 수집 및 선별하는 파이썬 코드입니다. 주식 데이터 수집 및 선별하는 파이썬 코드입니다.

24
app.py
View File

@ -1,24 +0,0 @@
import flask
import argparse
parser = argparse.ArgumentParser(description="Stock web server")
parser.add_argument("--port", type=int, default=12001, help="port number")
parser.add_argument("--host", type=str, default="0.0.0.0", help="host address")
parser.add_argument("--debug", action="store_true", help="debug mode")
app = flask.Flask(__name__)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
@app.route("/dist/<m>")
def distServe(m:str):
return flask.send_from_directory("dist", m)
@app.route("/")
def index():
import pages
return flask.render_template("index.html", pages = pages.GenLists)
if __name__ == '__main__':
args = parser.parse_args()
app.run(host=args.host, port=args.port, debug=args.debug)

View File

@ -2,6 +2,7 @@
"lock": false, "lock": false,
"tasks": { "tasks": {
"start": "deno run -A --watch=static/,routes/ dev.ts", "start": "deno run -A --watch=static/,routes/ dev.ts",
"prod_start": "deno run -A main.ts",
"update": "deno run -A -r https://fresh.deno.dev/update ." "update": "deno run -A -r https://fresh.deno.dev/update ."
}, },
"lint": { "lint": {

35
gen.py
View File

@ -5,7 +5,6 @@ import sqlite3
from typing import Dict, List from typing import Dict, List
from render import * from render import *
import db as database import db as database
from jinja2 import Environment, PackageLoader, select_autoescape
import pandas as pd import pandas as pd
import tqdm import tqdm
@ -145,7 +144,6 @@ def collect(data: DataStore, collector: OutputCollector, corp: database.KRXCorp
d5 = d(5) d5 = d(5)
d20 = d(20) d20 = d(20)
d25 = d(25) d25 = d(25)
d30 = d(30)
d45 = d(45) d45 = d(45)
d60 = d(60) d60 = d(60)
d120 = d(120) d120 = d(120)
@ -248,8 +246,6 @@ def collect(data: DataStore, collector: OutputCollector, corp: database.KRXCorp
#rsi_signal = macd.loc[::-1].ewm(span=7).mean().loc[::-1] #rsi_signal = macd.loc[::-1].ewm(span=7).mean().loc[::-1]
parser = argparse.ArgumentParser(description="주식 검색 정보를 출력합니다.") parser = argparse.ArgumentParser(description="주식 검색 정보를 출력합니다.")
parser.add_argument("--format", "-f", choices=["json", "html"], default="html",
help="출력 포맷을 지정합니다. 기본값은 html입니다.")
parser.add_argument("--dir", "-d", default=".", help="출력할 폴더를 지정합니다.") parser.add_argument("--dir", "-d", default=".", help="출력할 폴더를 지정합니다.")
parser.add_argument("--corp", "-c", help="주식 코드를 지정합니다. 지정하지 않으면 kosdaq과 kospi만 검색합니다.") parser.add_argument("--corp", "-c", help="주식 코드를 지정합니다. 지정하지 않으면 kosdaq과 kospi만 검색합니다.")
parser.add_argument("--fullSearch", help="모든 주식을 검색합니다.", action='store_true') parser.add_argument("--fullSearch", help="모든 주식을 검색합니다.", action='store_true')
@ -268,10 +264,6 @@ if __name__ == "__main__":
if args.corp: if args.corp:
krx_corps = [corp for corp in krx_corps if corp.Code == args.corp] krx_corps = [corp for corp in krx_corps if corp.Code == args.corp]
env = Environment(
loader=PackageLoader('render', 'templates'),
autoescape=select_autoescape(['html', 'xml'])
)
collector = OutputCollector() collector = OutputCollector()
prepareCollector(collector) prepareCollector(collector)
@ -281,25 +273,10 @@ if __name__ == "__main__":
dataStore.clearCache() dataStore.clearCache()
for k,v in collector.data.items(): for k,v in collector.data.items():
if args.format == "json": data = json.dumps(v.toDict(), ensure_ascii=False)
data = json.dumps(v.toDict(), indent=4, ensure_ascii=False) if args.printStdout:
if args.printStdout: print(k)
print(k) print(data)
print(data)
else:
with open(os.path.join(args.dir, k + ".json"), "w", encoding="UTF-8") as f:
f.write(data)
else: else:
template = env.get_template("Lists.html") with open(os.path.join(args.dir, k + ".json"), "w", encoding="UTF-8") as f:
f.write(data)
days = v.corpListByDate.keys()
days = list(days)
days.sort(reverse=True)
days = days[:5]
html = template.render(collected=v, title=k, days=days, lastUpdate=datetime.date.today().isoformat())
if args.printStdout:
print(html)
else:
with open(os.path.join(args.dir, k + ".html"), "w", encoding="UTF-8") as f:
f.write(html)

View File

@ -1,60 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stock</title>
<style>
body{
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(to right, #2b2b2b, #3d1844);
color: #fff;
}
.table_item:nth-child(2n){
background: #a7a7a7;
}
.table_item:nth-child(2n+1){
background: #fff;
}
.table_item:hover{
background: #8d8d8d;
}
.container{
display: grid;
grid-template-rows: 24px auto;
background: #f0f0f0;
color: black;
box-shadow: 0px 0px 5px 0px white;
text-decoration: none;
grid-template-columns: repeat({{ 5 }}, 1fr);
}
.container a:link, a:visited{
text-decoration: none;
color: black;
}
.data_header{
border-bottom: 1px solid #a7a7a7;
}
</style>
</head>
<body>
<div style="margin: auto; max-width: 750px;">
<h1>{{title}} Stock List</h1>
<h3>{{lastUpdate}}</h3>
<section class="description">
{{collected.description}}
</section>
<section class="container">
{% for day in days|reverse %}
<div class="data_header">{{ day }}</div>
{% endfor %}
{% for day in days|reverse %}
{% set corplist = collected.corpListByDate[day] %}
<div>{% for item in corplist %}
<div class="table_item"><a href="https://stockplus.com/m/stocks/KOREA-A{{ item.Code }}">{{ item.Name }}({{item.Code}})</a></div>{% endfor %}
</div>
{% endfor %}
</section>
</div>
</body>
</html>

View File

@ -1,40 +0,0 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stock</title>
<style>
body{
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(to right, #2b2b2b, #3d1844);
color: #fff;
}
.container{
display: grid;
background: #f0f0f0;
color: black;
box-shadow: 0px 0px 5px 0px white;
text-decoration: none;
}
.container a:link, a:visited{
text-decoration: none;
color: black;
font-size: 40px;
}
.data_header{
border-bottom: 1px solid #a7a7a7;
}
</style>
</head>
<body>
<div style="margin: auto; max-width: 750px;">
<h1>Main</h1>
<div class="container">
{% for p in pages %}
<a href="/dist/{{p.name}}.html">{{p.name}}</a>
{% endfor %}
</div>
</div>
</body>
</html>