Skip to content

Commit 1c21b61

Browse files
committed
2 parents 75c29f5 + 4f068fd commit 1c21b61

File tree

89 files changed

+13726
-15665
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+13726
-15665
lines changed

.github/workflows/ci-linux.yml

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
11
name: Linux Build Test and Deploy
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
tags:
8+
- '*'
9+
pull_request:
10+
branches:
11+
- 'master'
412

513
jobs:
614
CI:
715
strategy:
816
matrix:
9-
python-version: [3.6, 3.7, 3.8]
17+
python-version: [3.6.x, 3.7.x, 3.8.x]
1018
python-arch: ["x64"]
1119

1220
env:
21+
PYTHONIOENCODING: "utf-8"
1322
PYTHONHASHSEED: 32
1423
TZ: 'Asia/Shanghai'
1524

1625
runs-on: ubuntu-latest
1726

1827
steps:
19-
- name: checkuot
28+
- name: Checkout
2029
uses: actions/checkout@v1
2130

2231
- name: Setup Node.js 12.x
2332
uses: actions/setup-node@v1
2433
with:
2534
node-version: 12.x
2635

27-
- name: npm install, build, and test
36+
- name: Package web
2837
run: |
2938
cd ./web/
30-
npm ci
31-
npm run build
39+
yarn install --frozen-lockfile
40+
yarn run build
3241
env:
3342
CI: true
3443

@@ -42,32 +51,33 @@ jobs:
4251
run: |
4352
git lfs install
4453
git lfs pull
45-
python -m pip install --upgrade pip wheel setuptools pytest zip-files
54+
python -m pip install --upgrade pip wheel setuptools pytest
4655
python -m pip install -r requirements.txt
56+
python -m pip install Sphinx==2.3.1
4757
python -m pip install autodocsumm sphinx_rtd_theme jieba
4858
4959
- name: Format log path and name
5060
id: log_info
5161
run: |
52-
echo "::set-output name=log_name::Linux_$(date -d today +%Y%m%d)_${{matrix.python-version}}_${{matrix.python-arch}}_$(git rev-parse --short HEAD)"
62+
echo "::set-output name=log_name::Linux_$(date -d today +%Y%m%d)_${{matrix.python-version}}_${{matrix.python-arch}}_$(echo ${GITHUB_SHA:0:7})"
5363
echo "::set-output name=log_archive_path::./log_archive/"
5464
55-
- name: Run Test Case
65+
- name: Run test case
66+
timeout-minutes: 60
5667
run: |
5768
mkdir -p ${{steps.log_info.outputs.log_archive_path}}
5869
python -W ignore::DeprecationWarning -m pytest --no-print-logs \
5970
--log-level=DEBUG \
60-
--log-file=${{steps.log_info.outputs.log_name}}.log
61-
zip-files -o ${{steps.log_info.outputs.log_archive_path}}${{steps.log_info.outputs.log_name}}.zip ./${{steps.log_info.outputs.log_name}}.log
71+
--log-file=${{steps.log_info.outputs.log_archive_path}}${{steps.log_info.outputs.log_name}}.log
6272
6373
- name: Upload log to artifact
6474
if: always()
6575
uses: actions/upload-artifact@v1
6676
with:
67-
name: ${{steps.log_info.outputs.log_name}}.zip
77+
name: ${{steps.log_info.outputs.log_name}}
6878
path: ${{steps.log_info.outputs.log_archive_path}}
6979

70-
- name: build Wheel on Linux Platform
80+
- name: Build wheel on linux platform
7181
run: |
7282
pip list
7383
## wheel包及源码包制作
@@ -83,33 +93,37 @@ jobs:
8393
sphinx-build doc build/doc
8494
8595
- name: Publish to pypi
86-
if: matrix.python-version == '3.6' && startsWith(github.event.ref, 'refs/tags')
96+
if: matrix.python-version == '3.6.x' && startsWith(github.event.ref, 'refs/tags')
8797
uses: pypa/gh-action-pypi-publish@master
8898
with:
8999
user: __token__
90100
password: ${{ secrets.PYPI_PASSWORD }}
91101

92102
- name: Publish to github release
93-
if: matrix.python-version == '3.6' && startsWith(github.event.ref, 'refs/tags')
103+
if: matrix.python-version == '3.6.x' && startsWith(github.event.ref, 'refs/tags')
94104
uses: fnkr/github-action-ghr@v1
95105
env:
96106
GHR_PATH: dist/
97107
GITHUB_TOKEN: ${{ secrets.GITHUB_USER_TOKEN }}
98108

99109
- name: Setup AWS S3 dist path
100-
if: matrix.python-version == '3.6' && startsWith(github.event.ref, 'refs/tags') != true
110+
if: matrix.python-version == '3.6.x' && startsWith(github.event.ref, 'refs/heads')
101111
run: |
102112
echo "::set-env name=DEST_DIR::dist/tqsdk-python/\
103-
$(echo ${GITHUB_REF#refs/heads/})/$(date -d today +%Y%m%d)_$(git rev-parse --short HEAD)/"
113+
$(echo ${GITHUB_REF#refs/heads/})/$(date -d today +%Y%m%d)_$(echo ${GITHUB_SHA:0:7})/"
104114
105115
- name: Setup AWS S3 dist path on tag
106-
if: matrix.python-version == '3.6' && startsWith(github.event.ref, 'refs/tags')
116+
if: matrix.python-version == '3.6.x' && startsWith(github.event.ref, 'refs/tags')
107117
run: |
108-
echo "::set-env name=DEST_DIR::dist/tqsdk-python/\
109-
$(echo ${GITHUB_REF#refs/tags/})/$(date -d today +%Y%m%d)_$(git rev-parse --short HEAD)/"
118+
echo "::set-env name=DEST_DIR::dist/tqsdk-python/$(echo ${GITHUB_REF#refs/tags/})/"
119+
120+
- name: Setup AWS S3 dist path on pull_request
121+
if: matrix.python-version == '3.6.x' && github.event_name == 'pull_request'
122+
run: |
123+
echo "::set-env name=DEST_DIR::dist/tqsdk-python/pr-${{ github.event.number }}/"
110124
111125
- name: Publish dist to AWS S3
112-
if: matrix.python-version == '3.6'
126+
if: matrix.python-version == '3.6.x'
113127
uses: jakejarvis/s3-sync-action@master
114128
env:
115129
AWS_S3_BUCKET: ${{ secrets.BUCKET_NAME }}
@@ -119,17 +133,17 @@ jobs:
119133
SOURCE_DIR: "dist"
120134

121135
- name: Setup branch AWS S3 docs path
122-
if: matrix.python-version == '3.6' && startsWith(github.event.ref, 'refs/tags') != true
136+
if: matrix.python-version == '3.6.x' && startsWith(github.event.ref, 'refs/heads')
123137
run: |
124138
echo "::set-env name=DEST_DIR::docs/tqsdk-python/$(echo ${GITHUB_REF#refs/heads/})/"
125139
126140
- name: Setup branch AWS S3 docs path on Tag
127-
if: matrix.python-version == '3.6' && startsWith(github.event.ref, 'refs/tags')
141+
if: matrix.python-version == '3.6.x' && startsWith(github.event.ref, 'refs/tags')
128142
run: |
129143
echo "::set-env name=DEST_DIR::docs/tqsdk-python/$(echo ${GITHUB_REF#refs/tags/})/"
130144
131145
- name: Publish tag build/doc to AWS S3
132-
if: matrix.python-version == '3.6'
146+
if: matrix.python-version == '3.6.x' && github.event_name != 'pull_request'
133147
uses: jakejarvis/s3-sync-action@master
134148
with:
135149
args: --exclude '.doctrees/*'

.github/workflows/ci-macos.yml

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,46 @@
11
name: MacOS Test
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
tags:
8+
- '*'
9+
pull_request:
10+
branches:
11+
- 'master'
412

513
jobs:
614
CI:
715
strategy:
816
matrix:
9-
python-version: [3.6, 3.7, 3.8]
17+
python-version: [3.6.x, 3.7.x, 3.8.x]
1018
python-arch: ["x64"]
1119

1220
env:
21+
PYTHONIOENCODING: "utf-8"
1322
PYTHONHASHSEED: 32
1423
TZ: 'Asia/Shanghai'
1524

1625
runs-on: macos-latest
1726

1827
steps:
19-
- name: checkuot
28+
- name: Checkout
2029
uses: actions/checkout@v1
2130

31+
- name: Setup Node.js 12.x
32+
uses: actions/setup-node@v1
33+
with:
34+
node-version: 12.x
35+
36+
- name: Package web
37+
run: |
38+
cd ./web/
39+
yarn install --frozen-lockfile
40+
yarn run build
41+
env:
42+
CI: true
43+
2244
- name: Setup Python ${{matrix.python-version}} ${{matrix.python-arch}}
2345
uses: actions/setup-python@v1
2446
with:
@@ -29,27 +51,27 @@ jobs:
2951
run: |
3052
git lfs install
3153
git lfs pull
32-
python -m pip install --upgrade pip wheel setuptools pytest zip-files
54+
python -m pip install --upgrade pip wheel setuptools pytest
3355
python -m pip install -r requirements.txt
3456
python -m pip install autodocsumm sphinx_rtd_theme jieba
3557
3658
- name: Format log path and name
3759
id: log_info
3860
run: |
39-
echo "::set-output name=log_name::macos_$(date +%Y%m%d)_${{matrix.python-version}}_${{matrix.python-arch}}_$(git rev-parse --short HEAD)"
61+
echo "::set-output name=log_name::macos_$(date +%Y%m%d)_${{matrix.python-version}}_${{matrix.python-arch}}_$(echo ${GITHUB_SHA:0:7})"
4062
echo "::set-output name=log_archive_path::./log_archive/"
4163
42-
- name: Run Test Case
64+
- name: Run test case
65+
timeout-minutes: 60
4366
run: |
4467
mkdir -p ${{steps.log_info.outputs.log_archive_path}}
4568
python -W ignore::DeprecationWarning -m pytest --no-print-logs \
4669
--log-level=DEBUG \
47-
--log-file=${{steps.log_info.outputs.log_name}}.log
48-
zip-files -o ${{steps.log_info.outputs.log_archive_path}}${{steps.log_info.outputs.log_name}}.zip ./${{steps.log_info.outputs.log_name}}.log
70+
--log-file=${{steps.log_info.outputs.log_archive_path}}${{steps.log_info.outputs.log_name}}.log
4971
5072
- name: Upload log to artifact
5173
if: always()
5274
uses: actions/upload-artifact@v1
5375
with:
54-
name: ${{steps.log_info.outputs.log_name}}.zip
76+
name: ${{steps.log_info.outputs.log_name}}
5577
path: ${{steps.log_info.outputs.log_archive_path}}

.github/workflows/ci-win.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,47 @@
11
name: Windows Test
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
tags:
8+
- '*'
9+
pull_request:
10+
branches:
11+
- 'master'
412

513
jobs:
614
CI:
715
strategy:
816
matrix:
9-
python-version: [3.6, 3.7, 3.8]
17+
python-version: [3.6.x, 3.7.x, 3.8.x]
1018
python-arch: ["x86", "x64"]
1119

1220
env:
21+
PYTHONIOENCODING: "utf-8"
1322
PYTHONHASHSEED: 32
1423
TZ: "CST-8"
1524

1625
runs-on: windows-latest
1726

1827
steps:
19-
- name: checkuot
28+
- name: Checkout
2029
uses: actions/checkout@v1
2130

31+
- name: Setup Node.js 12.x
32+
uses: actions/setup-node@v1
33+
with:
34+
node-version: 12.x
35+
36+
- name: Package web
37+
run: |
38+
cd ./web/
39+
yarn install --frozen-lockfile
40+
yarn run build
41+
env:
42+
CI: true
43+
44+
2245
- name: Setup Python ${{matrix.python-version}} ${{matrix.python-arch}}
2346
uses: actions/setup-python@v1
2447
with:
@@ -29,27 +52,27 @@ jobs:
2952
run: |
3053
git lfs install
3154
git lfs pull
32-
python -m pip install --upgrade pip wheel setuptools pytest zip-files
55+
python -m pip install --upgrade pip wheel setuptools pytest
3356
python -m pip install -r requirements.txt
3457
python -m pip install autodocsumm sphinx_rtd_theme jieba
3558
3659
- name: Format log path and name
3760
id: log_info
3861
run: |
39-
echo "::set-output name=log_name::win_$(date -d today +%Y%m%d)_${{matrix.python-version}}_${{matrix.python-arch}}_$(git rev-parse --short HEAD)"
62+
echo "::set-output name=log_name::win_$(date -d today +%Y%m%d)_${{matrix.python-version}}_${{matrix.python-arch}}_$(echo ${GITHUB_SHA:0:7})"
4063
echo "::set-output name=log_archive_path::./log_archive/"
4164
42-
- name: Run Test Case
65+
- name: Run test case
66+
timeout-minutes: 60
4367
run: |
4468
mkdir -p ${{steps.log_info.outputs.log_archive_path}}
4569
python -W ignore::DeprecationWarning -m pytest --no-print-logs `
4670
--log-level=DEBUG `
47-
--log-file=${{steps.log_info.outputs.log_name}}.log
48-
zip-files -o ${{steps.log_info.outputs.log_archive_path}}${{steps.log_info.outputs.log_name}}.zip ./${{steps.log_info.outputs.log_name}}.log
71+
--log-file=${{steps.log_info.outputs.log_archive_path}}${{steps.log_info.outputs.log_name}}.log
4972
5073
- name: Upload log to artifact
5174
if: always()
5275
uses: actions/upload-artifact@v1
5376
with:
54-
name: ${{steps.log_info.outputs.log_name}}.zip
77+
name: ${{steps.log_info.outputs.log_name}}
5578
path: ${{steps.log_info.outputs.log_archive_path}}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ nosetests.xml
4545
coverage.xml
4646
*.cover
4747
.hypothesis/
48+
chromedriver
49+
geckodriver
4850

4951
# Translations
5052
*.mo

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img src ="https://raw.githubusercontent.com/shinnytech/tqsdk-python/master/doc/logo.png"/>
33
</p>
44
<p align="center">
5-
<img src ="https://img.shields.io/badge/version-1.5.1-blueviolet.svg"/>
5+
<img src ="https://img.shields.io/badge/version-1.6.3-blueviolet.svg"/>
66
<img src ="https://img.shields.io/badge/platform-windows|linux|macos-green.svg"/>
77
<img src ="https://img.shields.io/badge/python-3.6+-blue.svg" />
88
<img src ="https://img.shields.io/github/license/shinnytech/tqsdk-python.svg?color=orange"/>
@@ -86,7 +86,7 @@ Documentation
8686

8787
Gui
8888
-------------------------------------------------
89-
TqSdk本身自带的web_gui功能,简单一行参数即可支持调用图形化界面,详情参加[web_gui](https://doc.shinnytech.com/pysdk/latest/usage/web_gui.html)
89+
TqSdk本身自带的web_gui功能,简单一行参数即可支持调用图形化界面,详情参考[web_gui](https://doc.shinnytech.com/pysdk/latest/usage/web_gui.html)
9090
<img alt="TqSdk web_gui" src="https://raw.githubusercontent.com/shinnytech/tqsdk-python/master/doc/images/web_gui_backtest.png">
9191

9292
About us

doc/advanced/backtest.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ TqSdk 并不提供专门的参数优化机制. 您可以按照自己的需求,
1919
acc = TqSim() # 每次回测都创建一个新的模拟账户
2020
try:
2121
api = TqApi(acc, backtest=TqBacktest(start_dt=date(2019, 5, 6), end_dt=date(2019, 5, 10)))
22+
account = api.get_account()
2223
klines = api.get_kline_serial(SYMBOL, duration_seconds=60, data_length=LONG + 2)
2324
target_pos = TargetPosTask(api, SYMBOL)
2425
while True:
@@ -32,7 +33,7 @@ TqSdk 并不提供专门的参数优化机制. 您可以按照自己的需求,
3233
target_pos.set_target_volume(1)
3334
except BacktestFinished:
3435
api.close()
35-
print("SHORT=", SHORT, "最终权益=", acc.account["balance"]) # 每次回测结束时, 输出使用的参数和最终权益
36+
print("SHORT=", SHORT, "最终权益=", account["balance"]) # 每次回测结束时, 输出使用的参数和最终权益
3637

3738

3839
多进程并发执行多个回测任务

doc/advanced/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
backtest.rst
1111
multi_strategy.rst
1212
gui.rst
13-
entry.rst
1413
for_vnpy_user.rst
1514
for_ctp_user.rst
15+
unanttended.rst

0 commit comments

Comments
 (0)