From fe36db49277025bed2e7de8dfbdc7be53ef517ad Mon Sep 17 00:00:00 2001 From: fasiondog Date: Wed, 6 Dec 2023 16:50:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?mysql=E6=B8=85=E9=99=A4=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E4=B8=80=E6=97=A5=E6=95=B0=E6=8D=AE=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hikyuu/tools/mysql_clear_last_day_data.py | 61 +++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 hikyuu/tools/mysql_clear_last_day_data.py diff --git a/hikyuu/tools/mysql_clear_last_day_data.py b/hikyuu/tools/mysql_clear_last_day_data.py new file mode 100644 index 000000000..5c0866923 --- /dev/null +++ b/hikyuu/tools/mysql_clear_last_day_data.py @@ -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() From 5ddaf0337f521163c0375eefe64c6eaae763aa93 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Wed, 6 Dec 2023 17:34:34 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fixed=20https://gitee.com/fasiondog/hikyuu/?= =?UTF-8?q?issues/I8M6AF=20=EF=BC=8C=E6=89=93=E5=8C=85example/notebook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hikyuu/examples/notebook/Demo/__init__.py | 1 + hikyuu/examples/notebook/__init__.py | 1 + hikyuu/examples/notebook/images/__init__.py | 1 + hikyuu/test/__init__.py | 0 sub_setup.py | 15 +++++++++------ 5 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 hikyuu/examples/notebook/Demo/__init__.py create mode 100644 hikyuu/examples/notebook/__init__.py create mode 100644 hikyuu/examples/notebook/images/__init__.py create mode 100644 hikyuu/test/__init__.py diff --git a/hikyuu/examples/notebook/Demo/__init__.py b/hikyuu/examples/notebook/Demo/__init__.py new file mode 100644 index 000000000..f102a9cad --- /dev/null +++ b/hikyuu/examples/notebook/Demo/__init__.py @@ -0,0 +1 @@ +__version__ = "0.0.1" diff --git a/hikyuu/examples/notebook/__init__.py b/hikyuu/examples/notebook/__init__.py new file mode 100644 index 000000000..f102a9cad --- /dev/null +++ b/hikyuu/examples/notebook/__init__.py @@ -0,0 +1 @@ +__version__ = "0.0.1" diff --git a/hikyuu/examples/notebook/images/__init__.py b/hikyuu/examples/notebook/images/__init__.py new file mode 100644 index 000000000..f102a9cad --- /dev/null +++ b/hikyuu/examples/notebook/images/__init__.py @@ -0,0 +1 @@ +__version__ = "0.0.1" diff --git a/hikyuu/test/__init__.py b/hikyuu/test/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/sub_setup.py b/sub_setup.py index 3a1863dc0..314d75eac 100644 --- a/sub_setup.py +++ b/sub_setup.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#-*- coding:utf-8 -*- +# -*- coding:utf-8 -*- import platform try: @@ -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 = "fasiondog@sina.com" @@ -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', @@ -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', @@ -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) @@ -143,4 +146,4 @@ def parse_requirements(filename): ] }, install_requires=requirements, -) \ No newline at end of file +) From 75ae4c121b0e2760f05208edc69d48eabc89a429 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Wed, 6 Dec 2023 17:42:26 +0800 Subject: [PATCH 3/3] remove --- LICENSE.996 | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 LICENSE.996 diff --git a/LICENSE.996 b/LICENSE.996 deleted file mode 100644 index 105d831f8..000000000 --- a/LICENSE.996 +++ /dev/null @@ -1,46 +0,0 @@ -Copyright (c) - -Anti 996 License Version 1.0 (Draft) - -Permission is hereby granted to any individual or legal entity -obtaining a copy of this licensed work (including the source code, -documentation and/or related items, hereinafter collectively referred -to as the "licensed work"), free of charge, to deal with the licensed -work for any purpose, including without limitation, the rights to use, -reproduce, modify, prepare derivative works of, distribute, publish -and sublicense the licensed work, subject to the following conditions: - -1. The individual or the legal entity must conspicuously display, -without modification, this License and the notice on each redistributed -or derivative copy of the Licensed Work. - -2. The individual or the legal entity must strictly comply with all -applicable laws, regulations, rules and standards of the jurisdiction -relating to labor and employment where the individual is physically -located or where the individual was born or naturalized; or where the -legal entity is registered or is operating (whichever is stricter). In -case that the jurisdiction has no such laws, regulations, rules and -standards or its laws, regulations, rules and standards are -unenforceable, the individual or the legal entity are required to -comply with Core International Labor Standards. - -3. The individual or the legal entity shall not induce or force its -employee(s), whether full-time or part-time, or its independent -contractor(s), in any methods, to agree in oral or written form, to -directly or indirectly restrict, weaken or relinquish his or her -rights or remedies under such laws, regulations, rules and standards -relating to labor and employment as mentioned above, no matter whether -such written or oral agreement are enforceable under the laws of the -said jurisdiction, nor shall such individual or the legal entity -limit, in any methods, the rights of its employee(s) or independent -contractor(s) from reporting or complaining to the copyright holder or -relevant authorities monitoring the compliance of the license about -its violation(s) of the said license. - -THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION WITH THE -LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK.