Skip to content

Commit

Permalink
[dev] reconstruct
Browse files Browse the repository at this point in the history
  • Loading branch information
Charmve committed Jul 13, 2024
1 parent de08d02 commit ae6977b
Show file tree
Hide file tree
Showing 280 changed files with 77 additions and 246 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ jqdata.json
pytrader.db
account.json
*.log
gui/__pycache__/
gui/csv/
qbot/gui/__pycache__/
qbot/gui/csv/

pytrader/user_config.sh
*.parquet
Expand Down
100 changes: 7 additions & 93 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,19 @@ Qbot是一个免费的量化投研平台,提供从数据获取、交易策略

```bash
cd ~ # $HOME as workspace
git clone https://github.com/UFund-Me/Qbot.git
git clone https://github.com/UFund-Me/Qbot --depth 1

cd qbot_pro
pip install -r dev/requirements.txt
cd Qbot
pip install -r requirements.txt

export PYTHONPATH=${PYTHONPATH}:$(pwd):$(pwd)/backend/multi-fact/mfm_learner
python main.py #if run on Mac, please use 'pythonw main.py'

# start backend --> #后端服务端
```

> [!NOTE]
> wxPython、Ta-Lib 需要手动安装,pip wheel 在 dev/ 路径下。https://github.com/UFund-Me/Qbot/issues/76
详细文档 https://github.com/UFund-Me/Qbot/blob/main/quick_start.md

<p id="demo">
Expand Down Expand Up @@ -252,95 +254,6 @@ export BLOSC_DIR=/opt/homebrew/opt/c-blosc
</tbody>
</table>

## USAGE ʕ •ᴥ•ʔ

### Installation

[Install Guide](./docs/01-新手指引/Install_guide.md) | [Online documents](https://ufund-me.github.io/Qbot/#/)

```
____________________________________
< Run ``./env_setup.sh`` to say hello >
------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```

### Get Started

本项目分为前端(客户端)和后端两部分,前端由wxPython编写的轻量化GUI客户端,后端分为策略开发、策略回测 ``qbot/strategies``、股票基金评测、模拟交易、在线回测几个部分,对应于客户端从左到右的三个菜单。

#### 前端/客户端

➕ 请注意:本项目建议使用python 3.8、3.9版本,推荐使用conda搭建环境,参考 [Install Guide](./docs/01-新手指引/Install_guide.md)

<sub>* 如果是 Win 系统使用``set``命令.</sub>

```shell
export USER_ID="admin" # replace your info
export PASSWORD="admin1234." # replace your info

pip install -r dev/requirements.txt

# if run on Mac, please use 'pythonw main.py'
python main.py
```

主要包含四个窗口,如果启动界面未显示或有问题可以参考下图中对应的启动方式。👉 点击[这里](gui/mainframe.py)查看源码,下文也有文字介绍。

![image](https://github.com/UFund-Me/Qbot/assets/29084184/9f1dcc07-ca76-4600-a02c-76104fb28c51)

#### 后端/服务端

1. 选基、选股助手(对应前端/客户端第二个菜单:AI选股/选基)

运行命令

```
cd investool
go build
./investool webserver
```

2. 基金策略在线分析(对应于前端/客户端第四个菜单:基金投资策略分析)

需要 node 开发环境: `npm``node`,点击[查看](pyfunds/fund-strategies/README.md)详细操作文档

<details><summary>版本信息(作为参考)</summary>

```
▶ go version
go version go1.20.4 darwin/amd64
~
▶ node --version
v19.7.0
~
▶ npm --version
9.5.0
```

</details>

使用docker运行项目,在项目路径 `pyfunds/fund-strategies/` 下运行以下命令构建项目的docker镜像
```
docker build -t fund_strategy .
```

镜像构建完毕后运行
```
docker run -dp 8000:8000 fund_strategy --name="fund_strategy_instance"
```

等待项目启动过程中,可通过以下命令查看启动日志:
```
docker logs -f fund_strategy_instance
```

启动后,可通过`http://locahost:8000`访问网页。

## Strategy pool

通过Qbot 可以积木式完成策略编写、多因子挖掘,实现数据开发、因子开发、组合优化、交易执行的[量化交易全流程](docs/01-新手指引/量化策略的分类和原理.md#1量化选股策略)
Expand Down Expand Up @@ -801,6 +714,7 @@ A股回测 KDJ+MACD 策略:
体验下来,dagster是很适合金融数据采集、处理,还有机器学习的场景。当然这里的场景更偏向于“批处理”,“定时任务”的处理与编排。

```
cd plugins/dagster
dagster-daemon run &
dagit -h 0.0.0.0 -p 3000
```
Expand Down
4 changes: 2 additions & 2 deletions auto_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def check(code, low, high):
f'{"中国平安"}当前价格为{priceNow}',
title=f'Qbot - {"中国平安"}股票已低于设定值{49}',
open="https://ufund-me.github.io/",
appIcon="./gui/imgs/logo.ico",
appIcon="./qbot/gui/imgs/logo.ico",
)
# pync.notify(
# "Reminder - Drink Water, Sir",
Expand All @@ -141,7 +141,7 @@ def check(code, low, high):
# # appIcon='https://raw.githubusercontent.com/UFund-Me/Qbot/main/gui/imgs/UFund.png',
# # appIcon='https://ufund-me.github.io/img/UFund.png',
# # appIcon='https://ufund-me.github.io/img/logo.ico',
# appIcon="./gui/imgs/logo.ico",
# appIcon="./qbot/gui/imgs/logo.ico",
# )
# show_notification("Title", "notification")
# pync.notify(
Expand Down
107 changes: 30 additions & 77 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,22 @@ Qbot是一个免费的量化投研平台,提供从数据获取、交易策略

```bash
cd ~ # $HOME as workspace
git clone https://github.com/UFund-Me/Qbot.git
git clone https://github.com/UFund-Me/Qbot --depth 1

cd Qbot
pip install -r dev/requirements.txt
pip install -r requirements.txt

export PYTHONPATH=${PYTHONPATH}:$(pwd):$(pwd)/backend/multi-fact/mfm_learner
python main.py #if run on Mac, please use 'pythonw main.py'

```

> [!NOTE]
> wxPython、Ta-Lib 需要手动安装,pip wheel 在 dev/ 路径下。https://github.com/UFund-Me/Qbot/issues/76
详细文档 https://github.com/UFund-Me/Qbot/blob/main/quick_start.md


<p id="demo">
<!-- <img width="" alt="demo" src="https://user-images.githubusercontent.com/29084184/221901048-bb1615fe-674f-40e8-b1e7-ba5db30a82a6.png"> -->
<img width="" alt="demo" src="https://user-images.githubusercontent.com/29084184/223608757-5808e23c-86e4-4b1b-8b03-e04c8f368f5c.gif">
Expand Down Expand Up @@ -173,98 +181,30 @@ export BLOSC_DIR=/opt/homebrew/opt/c-blosc

[Install Guide](https://github.com/UFund-Me/Qbot/blob/main/docs/01-新手指引/Install_guide) | [Online documents](https://ufund-me.github.io/Qbot/#/)

```
____________________________________
< Run ``./env_setup.sh`` to say hello >
------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```

### Get Started

本项目分为前端(客户端)和后端两部分,前端由wxPython编写的轻量化GUI客户端,后端分为策略开发、策略回测 ``qbot/strategies``、股票基金评测、模拟交易、在线回测几个部分,对应于客户端从左到右的三个菜单。

#### 前端/客户端

➕ 请注意:本项目建议使用python 3.8、3.9版本,推荐使用conda搭建环境,参考 [Install Guide](https://github.com/UFund-Me/Qbot/blob/main/docs/01-新手指引/Install_guide)

<sub>* 如果是 Win 系统使用``set``命令.</sub>

```shell
export USER_ID="admin" # replace your info
export PASSWORD="admin1234." # replace your info

pip install -r dev/requirements.txt
git clone https://github.com/UFund-Me/Qbot --depth 1
cd Qbot
pip install -r requirements.txt

# if run on Mac, please use 'pythonw main.py'
python main.py
```
主要包含四个窗口,如果启动界面未显示或有问题可以参考下图中对应的启动方式。👉 点击[这里](https://github.com/UFund-Me/Qbot/blob/main/gui/mainframe.py#L122-L141)查看源码,下文也有文字介绍。

![image](https://github.com/UFund-Me/Qbot/assets/29084184/9f1dcc07-ca76-4600-a02c-76104fb28c51)

#### 后端/服务端

1. 选基、选股助手(对应前端/客户端第二个菜单:AI选股/选基)

运行命令

```
cd investool
go build
./investool webserver
```

2. 基金策略在线分析(对应于前端/客户端第四个菜单:基金投资策略分析)

需要 node 开发环境: `npm``node`,点击[查看](https://github.com/UFund-Me/Qbot/blob/main/pyfunds/fund-strategies/README.md)详细操作文档。

<details><summary>版本信息(作为参考)</summary>

```
▶ go version
go version go1.20.4 darwin/amd64
~
▶ node --version
v19.7.0
~
▶ npm --version
9.5.0
```

</details>

使用docker运行项目,在项目路径下运行以下命令构建项目的docker镜像
```
docker build -t fund_strategy .
```

镜像构建完毕后运行
```
docker run -dp 8000:8000 fund_strategy --name="fund_strategy_instance"
```

等待项目启动过程中,可通过以下命令查看启动日志:
```
docker logs -f fund_strategy_instance
```
> [!NOTE]
> wxPython、Ta-Lib 需要手动安装,pip wheel 在 dev/ 路径下。https://github.com/UFund-Me/Qbot/issues/76
启动后,可通过`http://locahost:8000`访问网页。

## No-code operation (TODO)

<img width="" alt="dagster" src="https://user-images.githubusercontent.com/29084184/221900050-2275a6e2-5c9b-4b81-84e5-0087e8fb58ec.png">
主要包含四个窗口,如果启动界面未显示或有问题可以参考下图中对应的启动方式。👉 点击[这里](https://github.com/UFund-Me/Qbot/blob/main/gui/mainframe.py#L122-L141)查看源码,下文也有文字介绍。

体验下来,dagster是很适合金融数据采集、处理,还有机器学习的场景。当然这里的场景更偏向于“批处理”,“定时任务”的处理与编排。
![image](https://github.com/UFund-Me/Qbot/assets/29084184/9f1dcc07-ca76-4600-a02c-76104fb28c51)

```
dagster-daemon run &
dagit -h 0.0.0.0 -p 3000
```
## Strategy Lib

部分未整理。。。
Expand Down Expand Up @@ -495,6 +435,7 @@ A股回测 KDJ+MACD 策略:
![image](https://github.com/UFund-Me/Qbot/assets/29084184/67338ec5-a6b1-4aa7-9792-1a2c61f353da)

👉 点击[查看](https://github.com/UFund-Me/Qbot/blob/main/pytrader/doc/04.kdj_with_macd/kdj_macd.py)源码

## TODO

- [x] 把策略回测整合在一个上位机中,包括:选基、选股策略、交易策略,模拟交易,实盘交易
Expand All @@ -505,6 +446,18 @@ A股回测 KDJ+MACD 策略:
- [ ] 在线文档的完善,目前主要几个部分:新手使用指引、经典策略原理和源码、智能策略原理和源码、常见问题等;
- [ ] 新的feature开发,欢迎在[issues](https://github.com/UFund-Me/Qbot/issues/)交流;

## No-code operation (TODO)

<img width="" alt="dagster" src="https://user-images.githubusercontent.com/29084184/221900050-2275a6e2-5c9b-4b81-84e5-0087e8fb58ec.png">

体验下来,dagster是很适合金融数据采集、处理,还有机器学习的场景。当然这里的场景更偏向于“批处理”,“定时任务”的处理与编排。

```
cd plugins/dagster
dagster-daemon run &
dagit -h 0.0.0.0 -p 3000
```

## Contributing

We appreciate all contributions to improve Qbot. Please refer to [CONTRIBUTING](.github/CONTRIBUTING) for the contributing guideline.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

<link rel="shortcut icon" type="image/x-icon" href="https://raw.githubusercontent.com/UFund-Me/Qbot/main/gui/imgs/logo.ico" media="screen" />
<link rel="shortcut icon" type="image/x-icon" href="https://raw.githubusercontent.com/UFund-Me/Qbot/main/qbot/gui/imgs/logo.ico" media="screen" />
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
<link rel="stylesheet" href="//unpkg.com/gitalk/dist/gitalk.css">

Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import wx

from gui.mainframe import MainFrame
from qbot.gui.mainframe import MainFrame

if __name__ == "__main__":
app = wx.App()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added plugins/investool/investool
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
14 changes: 7 additions & 7 deletions gui/mainframe.py → qbot/gui/mainframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import subprocess
import threading

from gui.panels.panel_backtest import PanelBacktest
from qbot.gui.panels.panel_backtest import PanelBacktest

# from gui.widgets.widget_matplotlib import MatplotlibPanel
from gui.widgets.widget_web import WebPanel
# from qbot.gui.widgets.widget_matplotlib import MatplotlibPanel
from qbot.gui.widgets.widget_web import WebPanel

TOP_DIR = Path(__file__).parent.parent.parent.joinpath("Qbot")
APP_NAME = "Qbot - Quant AI Robot"
Expand Down Expand Up @@ -89,7 +89,7 @@ def __init__(self, *args, **kw):

# 设置程序图标
icon_file = os.path.join(
os.path.abspath(TOP_DIR.joinpath("gui/imgs")), "logo.ico"
os.path.abspath(TOP_DIR.joinpath("qbot/gui/imgs")), "logo.ico"
)
icon = wx.Icon(icon_file, wx.BITMAP_TYPE_ICO)
self.SetIcon(icon)
Expand Down Expand Up @@ -122,8 +122,7 @@ def __init__(self, *args, **kw):
web = WebPanel(self.m_notebook)
self.m_notebook.AddPage(web, "AI 选股/选基", True)
# run_invest_tool()
web.show_url("http://localhost:4868/")
# web.show_url("https://investool.axiaoxin.com/?from=github")
web.show_url("http://111.229.117.200:4868")

web = WebPanel(self.m_notebook)
self.m_notebook.AddPage(web, "交易策略在线交易", True)
Expand All @@ -136,6 +135,7 @@ def __init__(self, *args, **kw):
self.m_notebook.AddPage(web, "基金投资策略分析", True)
# run_fund_tool()
# web.show_url("http://locahost:8000")
web.show_url("http://sunshowerc.github.io/fund/#/")
# web.show_url("https://ufund-me.github.io/funds-web/#/")
web.show_url("http://111.229.117.200:9090/#/")

self.m_notebook.AddPage(PanelBacktest(self.m_notebook), "可视化股票回测系统", True)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
'''
import wx

from gui.config import DATA_DIR_BKT_RESULT
from gui.widgets.widget_web import WebPanel
from qbot.gui.config import DATA_DIR_BKT_RESULT
from qbot.gui.widgets.widget_web import WebPanel


# https://zhuanlan.zhihu.com/p/376248349
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion qbot_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def send_signal_message_screen(symbol, price, type=default):
f'{symbol}当前价格为{price}',
title=f'Qbot - {symbol}{type}',
open="https://ufund-me.github.io/",
appIcon="./gui/imgs/logo.ico",
appIcon="./qbot/gui/imgs/logo.ico",
)


Expand Down
Loading

0 comments on commit ae6977b

Please sign in to comment.