Skip to content

Commit

Permalink
Merge pull request fasiondog#135 from fasiondog/feature/tools
Browse files Browse the repository at this point in the history
Feature/tools example/notebook 未打入安装包
  • Loading branch information
fasiondog authored Dec 6, 2023
2 parents e5e8a26 + 75ae4c1 commit 918fe2b
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 52 deletions.
46 changes: 0 additions & 46 deletions LICENSE.996

This file was deleted.

1 change: 1 addition & 0 deletions hikyuu/examples/notebook/Demo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1"
1 change: 1 addition & 0 deletions hikyuu/examples/notebook/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1"
1 change: 1 addition & 0 deletions hikyuu/examples/notebook/images/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1"
Empty file added hikyuu/test/__init__.py
Empty file.
61 changes: 61 additions & 0 deletions hikyuu/tools/mysql_clear_last_day_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/python
# -*- coding: utf8 -*-
#
# Create on: 2023-12-06
# Author: fasiondog

#
# 用于清除 mysql 最后一日的数据。
# 防止在开市时间段内,不小心导入了数据,导致当天数据错误。
#

import datetime
import mysql.connector
from hikyuu.util import *


@hku_catch(trace=True)
def get_all_tables(conn, market, typ):
cur = conn.cursor()
sql = f"SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema='{market}_{typ}'"
cur.execute(sql)
x = cur.fetchall()
cur.close()
return [f'`{v[0]}`.`{v[1]}`' for v in x]
def clear_today_day_data(conn, market, typ):
tables = get_all_tables(conn, market, typ)
today = datetime.date.today()
# yyyy mm dd hh mm
t = today.year * 100000000 + today.month * 1000000 + today.day * 10000
if typ == 'trans':
# yyyy mm dd hh mm ss
t = t * 100
cur = conn.cursor()
for table in tables:
hku_info(f"clear {table}")
sql = f"delete from {table} where date>={t}"
cur.execute(sql)
cur.close()
conn.commit()
if __name__ == '__main__':
host = '127.0.0.1'
port = 3306
usr = 'root'
pwd = ''

conn = mysql.connector.connect(user=usr, password=pwd, host=host, port=port)

x = get_all_tables(conn, 'bj', 'day')
market_list = ['sh', 'sz', 'bj']
typ_list = ['time', 'trans', 'day', 'week', 'month', 'quarter',
'halfyear', 'year', 'min', 'min5', 'min15', 'min30', 'min60']
for market in market_list:
for typ in typ_list:
clear_today_day_data(conn, market, typ)

conn.close()
15 changes: 9 additions & 6 deletions sub_setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# -*- coding:utf-8 -*-

import platform
try:
Expand Down Expand Up @@ -34,7 +34,7 @@ def parse_requirements(filename):
py_version = int(py_version[0]) * 10 + int(py_version[1])

hku_name = "hikyuu"
#hku_version = "1.0.9"
# hku_version = "1.0.9"
hku_author = "fasiondog"
hku_author_email = "[email protected]"

Expand Down Expand Up @@ -66,6 +66,9 @@ def parse_requirements(filename):
'hikyuu/data/sqlite_mem_sql',
'hikyuu/data_driver',
'hikyuu/examples',
'hikyuu/examples/notebook',
'hikyuu/examples/notebook/images',
'hikyuu/examples/notebook/Demo',
'hikyuu/flat',
'hikyuu/fetcher',
'hikyuu/fetcher/proxy',
Expand All @@ -78,7 +81,7 @@ def parse_requirements(filename):
'hikyuu/shell',
'hikyuu/strategy',
'hikyuu/strategy/demo',
#'hikyuu/test',
'hikyuu/test',
'hikyuu/tools',
'hikyuu/trade_manage',
'hikyuu/trade_sys',
Expand All @@ -97,12 +100,12 @@ def parse_requirements(filename):
keywords=hku_keywords,
platforms=hku_platforms,
url=hku_url,
packages=packages, #find_packages(),
packages=packages, # find_packages(),
zip_safe=False,
include_package_data=True,
package_data={
'': [
'*.rst', '*.pyd', '*.ini', '*.sql', '*.properties', '*.xml',
'*.rst', '*.pyd', '*.png', '*.md', '*.ipynb', '*.ini', '*.sql', '*.properties', '*.xml',
'LICENSE.txt', '*.dll', '*.exe', '*.ico', '*.so', '*.dylib',
'*.so.*', '*.qm', 'libboost_serialization*',
'libboost_python{}*'.format(py_version)
Expand Down Expand Up @@ -143,4 +146,4 @@ def parse_requirements(filename):
]
},
install_requires=requirements,
)
)

0 comments on commit 918fe2b

Please sign in to comment.