Skip to content

Commit

Permalink
v4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chen-001 committed Mar 14, 2024
0 parents commit 5969918
Show file tree
Hide file tree
Showing 202 changed files with 56,451 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
33 changes: 33 additions & 0 deletions .github/workflows/documentation-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy to Github Pages
on:
pull_request:

paths:
- "docs/**"
- "mkdocs.yml"
- "pure_ocean_breeze/**"
push:
paths:
- "docs/**"
- "mkdocs.yml"
- "pure_ocean_breeze/**"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.x
- uses: actions/cache@v2
with:
key: ${{ github.ref }}
path: .cache
- run: pip install mkdocstrings-python
- run: pip uninstall mkdocs -y
- run: pip install mkdocs-material-zhcorrect
- run: mkdocs build
- run: mkdocs gh-deploy --force


35 changes: 35 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# action的名称
name: Upload Python Package

on:
# 当setup.py分支有push时,触发action
pull_request:

paths:
- "pure_ocean_breeze/__init__.py"

push:

paths:
- "pure_ocean_breeze/__init__.py"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: ${{secrets.PYPI_USERNAME}}
password: ${{secrets.PYPI_PASSWORD}}
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@


# on:
# create:
# branches:
# - master

# # Sequence of patterns matched against refs/tags
# tags:
# - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
# # pull_request:
# # branches:
# # - master
# # # Sequence of patterns matched against refs/tags
# # tags:
# # - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
# name: Create Release

# jobs:
# build:
# name: Create Release
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# # - name: Get version
# # id: get_version
# # run: echo ::set-output name=VERSION::${tags/}
# - name: Create Tag
# id: create_tag
# uses: jaywcjlove/create-tag-action@main
# with:
# test: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'
# - name: Create Release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: v${{ steps.create_tag.outputs.version }}
# release_name: v${{ steps.create_tag.outputs.version }}
# body: 详见[更新日志](https://github.com/chen-001/pure_ocean_breeze/blob/master/更新日志/更新日志.md)
# draft: false
# prerelease: false


name: Release

on:
create:
tags:
- 'v*'

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v2
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: 详见[更新日志](https://github.com/chen-001/pure_ocean_breeze/blob/master/更新日志/更新日志.md)
draft: false
prerelease: false
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
site/
factor/
requirements.txt
.obsidian
Binary file added Github同步Pypi操作手册/Actions.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions Github同步Pypi操作手册/Github同步Pypi操作手册.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
### Github同步Pypi操作手册
---
* #### 步骤一 ➡️ 创建workflow
>1.**repository**主页找到**Actions**
>![Acitons](Actions.jpg)
>2.**Actions**中找到**Publish Python Package**
>![Publish_python_package](Publish_python_package.jpg)
>3. 点击**Configure**创建**workflow**
>![workflow](workflow.jpg)
>4. 此时自动在主分支下创建了`.github/workflows/python-publish.yml`文件
>
>👏**至此第一步结束啦👏**
* #### 步骤二 ➡️ 设置自动更新动作
>1. **解释**:`python-publish.yml`中的内容即更新动作
>2. 复制如下模板,替换`python-publish.yml`中的内容
>>```yml
>># action的名称
>>name: Upload Python Package
>>
>>on:
>> # 当setup.py分支有push时,触发action
>> push:
>> paths:
>> - 'setup.py'
>>
>>jobs:
>> deploy:
>> runs-on: ubuntu-latest
>> steps:
>> - uses: actions/checkout@v3
>> - name: Set up Python
>> uses: actions/setup-python@v4
>> with:
>> python-version: '3.x'
>> - name: Install dependencies
>> run: |
>> python -m pip install --upgrade pip
>> pip install build
>> - name: Build package
>> run: python -m build
>> - name: Publish package
>> uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
>> with:
>> user: ${{secrets.PYPI_USERNAME}}
>> password: ${{secrets.PYPI_PASSWORD}}
>>```
>3. 提交创建`python-publish.yml`文件
>![start-commit](start_commit.jpg)
>
>👏**至此第二步结束啦👏**
* #### 步骤三 ➡️ 设置Pypi账号密码
>1. **解释**:为了不在`python-publish.yml`文件中暴露自己Pypi的账号密码,需要在Github的仓库密钥中设置自己的账号密码。对应在上述`python-publish.yml`文件中的
>>```yml
>>user: ${{secrets.PYPI_USERNAME}}
>>password: ${{secrets.PYPI_PASSWORD}}
>>```
>2. 打开**repository**的**settings**(⚠️注意,并非个人账户的settings)
>![settings](settings.jpg)
>3. 选择左侧**Secrets**下的**Actions**,然后点击右上角的**New repository secret**
>![secrets](secrets.jpg)
>4. 添加新secret,pypi的账号,在Name中输入**PYPI_USERNAME**,在Value中输入自己Pypi账号
>![add_username](add_username.jpg)
>5. 再添加一个secret,pypi的密码,在Name中输入**PYPI_PASSWORD**,在Value中输入自己的Pypi密码
>![secrets_again](secrets_again.jpg)
>![add_password](add_password.jpg)
>
>👏**至此第三步结束啦👏**
* #### 步骤四 ➡️ 上传`setup.py`文件
>1. 上传`setup.py`文件
>![setup_py](setup_py.jpg)
>
>👏**至此第四步结束啦👏**
* #### 使用说明
>1. 更新Pypi新版本:更新`setup.py`文件并push,会触发前面设置的Action,从而自动更新Pypi新版本
>2. 其他文件的更新:只要不包含`setup.py`的更新,就不会触发更新Pypi版本的Action
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Github同步Pypi操作手册/add_password.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Github同步Pypi操作手册/add_username.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Github同步Pypi操作手册/secrets.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Github同步Pypi操作手册/secrets_again.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Github同步Pypi操作手册/settings.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Github同步Pypi操作手册/setup_py.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Github同步Pypi操作手册/start_commit.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Github同步Pypi操作手册/workflow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 chenzongwei

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE 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
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# pure_ocean_breeze
#### **众人的因子框架**
##### 我们的口号是:量价因子才是最牛的!
***

### 全新大版本📢
* v4.0.0 — 2023.06.28
> 因子框架4.0版本来啦!逐笔数据&任意秒级数据&全新的因子成果数据库来啦!
* v3.0.0 — 2022.08.16

>回测框架3.0版本来啦! 模块拆分&说明文档来啦![pure_ocean_breeze说明文档](https://chen-001.github.io/pure_ocean_breeze/)
* v2.0.0 — 2022.07.12
>回测框架2.0版本来啦!数据库&自动更新&最终因子库功能上线啦!
### 安装&使用指南🎯
1. 安装
> 使用`pip install pure_ocean_breeze`命令进行安装
2. 初始化
>* 在初次安装框架时,请进行初始化,以将路径设置到自己的文件里
>* 使用如下语句进行初始化
>>```python
>>import pure_ocean_breeze as p
>>p.ini()
>>```
>* 然后根据提示进行操作即可
>* 请注意路径不要写反斜杠\,而要写成/
>* 经过初始化后,以后就可以直接使用,不论重启电脑或者版本升级,都不用再初始化
>* 如果更换了数据库路径,请重新初始化
3. 日常调用
>* **导入框架**
>>```python
>>import pure_ocean_breeze as p
>>```
>* **一键回测**
>>```python
>>shen=p.pure_moonnight(fac)
>>```
>>`fac`为因子矩阵
>* **因子合成运算** 其他用法详见[说明文档](https://chen-001.github.io/pure_ocean_breeze/)
>* **其余内容敬请期待**
#### 作者😉
>* 量价选股因子黄金矿工💁‍♂️
>* 挖因子兼新技术爱好者💁‍♂️
>* 感谢每一个教我写代码和教我挖因子的人💐
>* 欢迎交流技术优化&因子灵感&工作信息:<winterwinter999@163.com>
#### 相关链接🔗
>* [PyPi](https://pypi.org/project/pure-ocean-breeze/)
>* [pure_ocean_breeze说明文档](https://chen-001.github.io/pure_ocean_breeze/)
>* [Github同步到Pypi操作手册](https://github.com/chen-001/pure_ocean_breeze/blob/master/Github同步Pypi操作手册/Github同步Pypi操作手册.md)
>* [更新日志](https://github.com/chen-001/pure_ocean_breeze/blob/master/更新日志/更新日志.md)
16 changes: 16 additions & 0 deletions database/on_clickhouse/mysql_to_clickhouse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pure_ocean_breeze.pure_ocean_breeze import *

sql=sqlConfig('minute_data')
chc=ClickHouseClient('minute_data')
codes=sql.show_tables(full=False)

fails=[]
for code in tqdm.tqdm(codes):
try:
df=sql.get_data(code)
(np.around(df,2)*100).ffill().dropna().astype(int).assign(code=code).to_sql('minute_data',chc.engine,if_exists='append',index=False)
except Exception:
fails.append(code)
logger.warning(f'{code}失败了,请检查')
logger.success('存储完啦')

40 changes: 40 additions & 0 deletions database/on_clickhouse/ricequant_to_clickhouse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from pure_ocean_breeze.pure_ocean_breeze import *

mipath='/Users/chenzongwei/pythoncode/数据库/Ricequant-minbar/equities'
sql=sqlConfig('minute_data')
chc=ClickHouseClient('minute_data')
files=sorted(os.listdir(mipath))
files=[mipath+'/'+i for i in files]
fails=[]

for path in tqdm.tqdm(files):
code,kind=convert_code(path)
df=read_h5_new(path)
df=df.rename(columns={'datetime':'date','volume':'amount','total_turnover':'money'})
df=df[['date','open','high','low','close','amount','money']].sort_values('date')
df.date=df.date.astype(str).str.slice(stop=8).astype(int)
df=df.groupby('date').apply(lambda x:x.assign(num=list(range(1,x.shape[0]+1))))
df=(np.around(df,2)*100).ffill().dropna().astype(int).assign(code=code)
try:
if kind=='stock':
df.to_sql('minute_data_stock',chc.engine,if_exists='append',index=False)
else:
df.to_sql('minute_data_index',chc.engine,if_exists='append',index=False)
except Exception:
fails.append(code)
logger.warning(f'{code}失败了,请检查')
logger.success('存储完啦')

# again=[i for i in files if fails[0][:6] in i][0]
# again=[i for i in files if '300671' in i][0]
#
# code,kind=convert_code(again)
# df=read_h5_new(again)
# df=df.rename(columns={'datetime':'date','volume':'amount','total_turnover':'money'})
# df=df[['date','open','high','low','close','amount','money']].sort_values('date')
# df.date=df.date.astype(str).str.slice(stop=8).astype(int)
# df=df.groupby('date').apply(lambda x:x.assign(num=list(range(1,x.shape[0]+1))))
# df=(np.around(df,2)*100).ffill().dropna().astype(int).assign(code=code)
# df.to_sql('minute_data_stock',chc.engine,if_exists='append',index=False)
#
# chc.get_data("select * from minute_data.minute_data_stock where code='300671.SZ'")
Loading

0 comments on commit 5969918

Please sign in to comment.