dsxquant


Namedsxquant JSON
Version 2.2.2 PyPI version JSON
download
home_pagehttps://github.com/dsxkline/dsxquant
SummaryDsxquant 是一个基于python语言开发的的量化工具箱,主要特征是其工具属性,专为上层策略应用提供服务。
upload_time2024-03-24 05:52:18
maintainerNone
docs_urlNone
authorfangyunsm
requires_python<4,>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements Deprecated dsxindexer Flask numpy pandas prettytable progressbar33
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Dsxquant 开源量化工具箱

Dsxquant 是一个基于python语言开发的的量化工具箱,主要特征是其工具属性,专为上层策略应用提供服务。

<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/dsxquant"> <img alt="PyPI" src="https://img.shields.io/pypi/v/dsxquant?label=dsxquant"> <img alt="GitHub code size in bytes" src="https://img.shields.io/github/languages/code-size/dsxkline/dsxquant"> <img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dd/dsxquant"> <img alt="Libraries.io dependency status for GitHub repo" src="https://img.shields.io/librariesio/github/dsxkline/dsxquant"> <img alt="GitHub" src="https://img.shields.io/github/license/dsxkline/dsxquant"> <img alt="GitHub search hit counter" src="https://img.shields.io/github/search/dsxkline/dsxquant/dsxquant"> <img alt="Website" src="https://img.shields.io/website?label=dsxquant%20website&up_message=online&url=https%3A%2F%2Fwww.dsxquant.com"> <img alt="Lines of code" src="https://img.shields.io/tokei/lines/github/dsxkline/dsxquant">

## 一、简介
Dsxquant 采用模块化设计思想,框架集成了数据、回测、策略、因子、仿真、资管、交易等模块。

技术架构

<img src="https://www.dsxquant.com/wp-content/uploads/2023/03/Dsxquant-Main-Engine-2-1024x985.png" width="300" />

## 二、数据结构

文档数据结构描述主要基于Pandas的 Series 和DataFrame,框架接口都支持返回Json数据,Series、DataFrame,支持 csv 文件转换等。

## 三、安装
Dsxquant 托管在 Github,Gitee,PyPi,默认采用PyPi包安装方式

### 1、PyPi 安装

```
pip install dsxquant
```

### 2、Git 源码安装导入

```
git clone https://github.com/dsxkline/dsxquant.git
```

### 3、安装依赖
直接通过依赖文件安装即可,也可以手动一个一个安装

```
pip install -r requirements.txt

Deprecated==1.2.13
dsxindexer==1.0.0
Flask==2.3.2
numpy==1.23.4
pandas==1.5.1
prettytable==3.7.0
progressbar33==2.4

```

## 四、快速上手

安装后直接导入包即可使用

``` python
import dsxquant
# dsxquant 默认维护了一个连接
# 可直接读取实时行情
# result = dsxquant.get_quotes("sh000001,sh600000").series()
result = dsxquant.get_price("sh000001,sh600000").series()
print(result)
```

## 五、连接

连接方式:
同步连接 (默认)connect()
异步连接 syncconnect()
### 示例:

``` python
# 默认采用同步连接
dd = dsxquant.dataser()
if dd.connect():
   # 读取行业分类
   result = dd.get_hangye().series()
   print(result)
```

### 框架支持with语法

```python
# with语法框架设计了自动连接,如果连接不成功会返回None,所以这里判断一下即可
with dsxquant.dataser() as dd:
    # 连接成功可调用
    if dd:
       result = dd.get_quotes("sh000001").datas()
       print(result.data)
```

### 异步订阅模式

```python
# 异步订阅模式,订阅模式请求是异步进行的,订阅成功后服务器会主动推送信息到您的回调函数中,注意请不要手动调用关闭连接方法
dd_async = dsxquant.dataser.asyncconnect()
if dd_async:
    # 异步请求实时行情接口,服务器会主动推送实时行情
    def quotes_callback(response:dsxquant.parser):
        # logger.debug(response.get("msg"))
        result = response.dataframe()
        logger.debug(result)
        pass
    
    result = dd_async.sub_quotes("sh000001,sh600000,sz000001,bj430047,bj430090",quotes_callback)
    logger.debug(result)
```

## 六、订阅

Dsxquant 提供实时行情订阅功能,可批量订阅,也可以全量订阅。订阅功能需要启用异步连接 asyncconnect(),批量订阅最多支持50个股票代码,全量订阅默认全市场变动数据推送。

```python
# 异步订阅模式,订阅模式请求是异步进行的,订阅成功后服务器会主动推送信息到您的回调函数中,注意请不要手动调用关闭连接方法
dd_async = dsxquant.dataser.asyncconnect()
if dd_async:
    # 异步请求实时行情接口,服务器会主动推送实时行情
    def quotes_callback(response:dsxquant.parser):
        # print(response.get("msg"))
        result = response.dataframe()
        print(result)
    # 批量订阅股票代码,批量订阅最多支持50个股票代码
    result = dd_async.sub_quotes("sh000001,sh600000,sz000001,bj430047,bj430090",quotes_callback)
    print(result)
        
    def quotes_all_callback(response:dsxquant.parser):
        dd = response.dataframe()
        # 第一行默认是字段名称数组 ["amount","close",.....]
        names:list = list(dd.values[0])
        # 第二行开始是数据
        quote = dd.loc[1,:]
        code = quote[names.index("code")]
        t = quote[names.index("lasttime")]
        d = quote[names.index("lastdate")]
        t = datetime.datetime.strptime(d+" "+t,"%Y-%m-%d %H:%M:%S")
        s = datetime.datetime.now() - t
        print("%s 笔 %s 时间 %s 当前时间 %s 延时 %s s" % (dd.__len__(),code,t,datetime.datetime.now(),s.seconds))
    # 全量订阅全市场所有股票实时行情
    dd_async.sub_all_quotes(quotes_all_callback)
```

### 取消订阅

```python
success = dd_async.cancel(quote)
if success!=None:
    print("cancel success:"+quote.api_name)
```

## 七、读取市场股票

目前市场仅支持上交所、深交所、北交所。

### 市场枚举值:

```python
# 市场代码
class MARKET:
    SH=0                            # 上交所
    SZ=1                            # 深交所
    BJ=2                            # 北交所
    HK=3                            # 港交所
    US=4                            # 美国
```

### 读取某个市场的所有股票列表

```python
# 读取某个市场的所有股票代码列表
result = dd.get_stocks(dsxquant.market.SZ).series()
print(result)
```

## 八、读取分类列表

主要是读取行业、概念、地域分类的股票代码

### 读取行业分类
```python
# 读取行业分类
result = dd.get_hangye().series()
print(result)
```

输出格式

```

       0
0     煤炭
1   石油石化
2   美容护理
3     环保
4   电力设备
...
25    汽车
26    电子
27  有色金属
28    钢铁
29  农林牧渔
30    综合
```

### 读取概念分类
```python
# 读取概念分类
result = dd.get_gainian().series()
print(result)
```

输出格式

```
         0
0      血氧仪
1    毫米波雷达
2     eSIM
3     AI训练
4     数字哨兵
..     ...
619     举牌
620   军民融合
621    京津冀
622   抗癌药物
623   昨日涨停
```

### 读取地域分类

```python
# 读取地域分类
result = dd.get_diyu().series()
print(result)
```

输出格式

```
           0
0   新疆维吾尔自治区
1    宁夏回族自治区
2        青海省
3        甘肃省
25       辽宁省
...
29       天津市
30       北京市
```

## 九、读取实时行情

目前仅支持A股实时行情,行情来自于网络公开数据,延时10秒以上,供个人量化开发者测试所用,请勿用于商业用途。

```python
 # 读取实时行情并导出csv文件
result = dd.get_quotes([("000002",dsxquant.MARKET.SZ),("600000",dsxquant.MARKET.SH)]).csv("quotes.csv")
print(result)

# 读取实时行情
result = dd.get_quotes([("000002",dsxquant.MARKET.SZ),("600000",dsxquant.MARKET.SH)]).dataframe()
print(result)

# 读取实时行情,批量字符串
result = dd.get_quotes("sh000001,sz000001,sh600000").datas()
print(result.data)

# 读取实时行情,字符串
result = dd.get_quotes("sh000001").datas()
if result.success:
    print(result.data)
```

## 十、读取历史K线

读取上市以来所有的历史K线数据,前后复权数据等。支持读取日K、周K、月K、年K等数据

### 读取日K历史数据

```python
# 读取历史K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.DAY).dataframe()
print(result)
```

输出格式 [日期,开,高,低,收,成交量,成交额]

```
                                                     0
0    20230227,621462.0,13.88,13.68,13.86,621462.0,8...
1    20230224,14.02,14.03,13.80,13.86,729989,101265...
2    20230223,14.00,14.32,13.98,14.05,824491,116553...
3    20230222,14.00,14.12,13.94,14.02,638922,895742...
4    20230221,14.06,14.20,13.92,14.10,990495,139315...
..                                                 ...
315  20211109,17.48,17.65,17.26,17.53,1240573,21631...
316  20211108,17.62,17.81,17.36,17.42,1376815,24064...
317  20211105,17.85,18.00,17.57,17.64,1096040,19424...
318  20211104,18.08,18.10,17.80,17.87,983411,176067...
319  20211103,18.10,18.24,17.85,18.03,1114972,20093...
```

### 读取周K历史数据

```python
# 读取周K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.WEEK).dataframe()
print(result)
```

### 读取月K历史数据

```python
# 读取月K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.MONTH).dataframe()
print(result)
```

### 读取年K历史数据

```python
# 读取年K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.YEAR).dataframe()
print(result)
```

## 十一、读取分钟K线

支持读取30天内的历史分钟K线数据,1分钟、5分钟、15分钟、30分钟、60分钟等。

### 读取1分钟历史数据

```python
# 读取1分钟K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.M1,page_size=1000).dataframe()
print(result)
```

返回数据格式
```
                                                     0
0    202302240931,14.02,14.03,13.94,13.96,26062,364...
1    202302240932,13.96,13.96,13.92,13.96,10384,144...
2    202302240933,13.96,13.96,13.93,13.94,6386,8908...
3    202302240934,13.93,13.94,13.92,13.93,10046,139...
4    202302240935,13.93,13.93,13.92,13.93,4432,6172...
..                                                 ...
475  202302031456,14.35,14.36,14.34,14.35,3920,5624...
476  202302031457,14.36,14.36,14.34,14.34,5109,7332...
477  202302031458,14.35,14.35,14.35,14.35,585,84005...
478        202302031459,14.35,14.35,14.35,14.35,0,0.00
479  202302031500,14.32,14.32,14.32,14.32,21701,310...
```

### 读取5分钟历史数据

```python
# 读取5分钟K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.M5,page_size=1000).dataframe()
print(result)
```

### 读取15分钟历史数据

```python
# 读取15分钟K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.M15,page_size=1000).dataframe()
print(result)
```

### 读取30分钟历史数据
```python
# 读取30分钟K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.M30,page_size=1000).dataframe()
print(result)
```

### 读取60分钟历史数据

```python
# 读取60分钟K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.M60,page_size=1000).dataframe()
print(result)
```

## 十二、复权因子

框架复权因子采用的是涨跌幅复权算法,算法已开源,主要采用分红配股和股改数据进行计算,详细算法介绍可参考文章《量化基础算法:K线涨跌幅复权算法揭秘和实现》

### 获取复权因子

```python
# 请求复权因子
result = dd.get_factors("000001",dsxquant.MARKET.SZ).dataframe()
print(result)
```

输出格式,除权日的复权因子列表 {日期:[前复权因子,后复权因子]}
```

20220722    0.982475,60.840279
20210514    0.974809,59.774055
20200528    0.958463,59.307677
20190626    0.948114,58.313133
20180712    0.933428,57.683542
20170721    0.919984,56.790039
20160616    0.755418,55.972096
20150413    0.623983,45.959846
20140612    0.512923,37.963297
20130620    0.317744,31.206389
20121019    0.315393,19.331661
20081031    0.241891,19.188569
20070618    0.219832,14.716718
20030929    0.216301,13.374637
20020723    0.214064,13.159841
20001106    0.186992,13.023705
19991018    0.182043,11.376639
19970825    0.120593,11.075537
19960527     0.060297,7.336915
19950925      0.04872,3.668457
19940711     0.031303,2.964128
19930524     0.016436,1.904488
```

得到复权因子后,根据对应的日期即可计算出前后复权数据,计算方法参考 《量化基础算法:K线涨跌幅复权算法揭秘和实现》

## 十三、分红配股

获取上市以来所有的分红配股信息,此信息来源于网络公开数据,由Dsxquant整理清洗。

### 获取分红配股

```python
# 请求分红配股信息
result = dd.get_sharebonus("000001",dsxquant.MARKET.SZ).dataframe()
print(result)
```

返回数据格式,参数名称可参考 接口文档

```
code              sz000001
per_ten_allo              
allo_price                
anno_day        2022-07-15
per_ten_send             0
per_ten_incr             0
per_cash_div          2.28
share_day       2022-07-22
reg_day         2022-07-21
list_day              
```

## 十四、财务报表

财务报表数据来源于网络公开数据,由Dsxquant收集整理,提供财务指标、资产负债表、利润表、现金流量表等报表查询。

### 获取财务指标

```python
# 财务指标
result = dd.get_finance("000002",dsxquant.MARKET.SZ,report_type=dsxquant.config.REPORT_TYPE.DEFAULT).dataframe()
print(result)
```

返回数据格式

```
CODE                 sz000002
DATE               2022-09-30
ZZC      1832624105913.530029
LDZC     1482234397741.830078
GDZC       14951487488.129999
ZFZ      1426655627128.919922
LDFZ     1168326002698.350098
JZC       405968478784.610107
MGJZC                19.73719
YYSR      337673241644.890015
YYLR       37447020773.470001
LRZE       37731123134.410004
JLR            27244596166.41
MGSY                   1.4697
```

### 获取资产负债表

```python
# 资产负债表
result = dd.get_finance("000002",dsxquant.MARKET.SZ,report_type=dsxquant.config.REPORT_TYPE.BALANCESHEET).dataframe()
print(result)
```
返回数据格式
```
report_date               2022-09-30
zc_1                                
zc_2                                
zc_3                                
zc_20                               
                        ...         
fzgdqy_2                        None
fzgdqy_total    1832624105913.530029
op_1                            None
op_2                            None
code                        sz000002
```

### 获取现金流量表

```python
# 现金流量表
result = dd.get_finance("000002",dsxquant.MARKET.SZ,report_type=dsxquant.config.REPORT_TYPE.CASHFLOW).dataframe()
print(result)
```

返回数据格式

```
report_date    2022-09-30
jy_in_1                  
jy_in_2                  
jy_in_3                  
jy_in_4              None
                  ...    
je_11                    
fbcce_add                
op_1                 None
op_2                 None
code             sz000002
```

### 获取利润表

```python
# 利润表
result = dd.get_finance("000002",dsxquant.MARKET.SZ,report_type=dsxquant.config.REPORT_TYPE.PROFIT).dataframe()
print(result)
```

返回数据格式

```
report_date             2022-09-30
yyzsr          337673241644.890015
sr_1           337673241644.890015
sr_2                          None
sr_3                          None
                      ...         
zhsy_3          26123838848.540001
zhsy_4          15412047995.690001
zhsy_5              10711790852.85
zhsy_6                        None
code                      sz000002
```

## 十五、分时线
仅支持查询30天内分时线历史数据

```python
# 请求分时图信息,默认是最新一个交易日的信息
result = dd.get_timeshring("000001",dsxquant.MARKET.SZ).datas()
if result.success:
    print(result.data)
```

返回数据格式

```
[
['0925', 13.85, 659700.0, 9136845.0, 13.85], 
['0930', 13.85, 3384822.0, 46903478.453999996, 13.857], 
['0931', 13.82, 1444600.0, 20009154.6, 13.851], 
['0932', 13.85, 1255300.0, 17382139.099999998, 13.847], 
['0933', 13.88, 2193900.0, 30396484.5, 13.855], 
['0934', 13.86, 913600.0, 12658841.6, 13.856], 
...
['1454', 13.95, 404100.0, 5612949.0, 13.89], 
['1455', 13.95, 670000.0, 9306970.0, 13.891], 
['1456', 13.95, 300500.0, 4174245.5, 13.891], 
['1500', 13.96, 993594.0, 13803007.848, 13.892]
]
```

## 十六、逐笔交易

只支持查询30天内的历史逐笔交易信息

### 获取逐笔交易信息

```python
# 请求逐笔交易
result = dd.get_translist("000001",dsxquant.MARKET.SZ).dataframe()
print(result)
```

返回数据格式

```
      0      1         2             3       4
0  1500  13.96  993594.0  1.380301e+07  13.892
1  1456  13.95  300500.0  4.174246e+06  13.891
2  1455  13.95  670000.0  9.306970e+06  13.891
3  1454  13.95  404100.0  5.612949e+06  13.890
4  1453  13.94  537500.0  7.465875e+06  13.890
5  1452  13.96  356300.0  4.949007e+06  13.890
6  1451  13.96  246100.0  3.418083e+06  13.889
7  1450  13.95  671800.0  9.330630e+06  13.889
8  1449  13.96  253800.0  3.525028e+06  13.889
9  1448  13.96  423200.0  5.877402e+06  13.888
```

## 十七、回测

目前支持简单回测功能,支持日线和分钟线级别的历史数据回测


```python
from dsxquant.engins.engin import Engin
from dsxquant.backtest.back_test import BackTest
from dsxquant import StrategyEngin,EmulationEngin,DataFeed,EventType
from dsxquant.strategy.common.macross_strategy import MACrossStrategy
import dsxquant
# 先启动系统引擎
engin = Engin().start()
# 安装模块
engin.install(StrategyEngin,EmulationEngin,DataFeed)
# 调用回测,这个例子是日线回测
backtest = BackTest(MACrossStrategy,"sz000001",start="20200412",end="20230427",data=EventType.DAYLINE)
engin.install(backtest)
# 等待回测完成并显示回测结果  
backtest.show()
engin.shutdown()

```

## 十八、RESTful Api 接口
采用Flask框架设计了一套RESTful API,支持一键启动,支持Nginx部署等

```python
import dsxquant
# 这里用于本地测试,生产部署请用Nginx等服务
dsxquant.restfulapi.run()

```
启动后通过浏览器进行访问 http://127.0.0.1:5000/price?symbols=sh000001,sz000001

### Nginx 配置
Nginx 只需要做反向代理配置即可
```
server {
    listen 80;
    server_name example.com;

    location / {
        uwsgi_pass 127.0.0.1:5001;
        include uwsgi_params;
    }
}
```

### uwsgi 配置ini文件即可

这里的端口号要跟Nginx反向代理配置的端口一致,其中 module 为执行的python文件,dsxquant.restful.app, callable为Flask项目的app对象,其他参数可以参考Flask文档

```
[uwsgi]
socket = 127.0.0.1:5001
module = dsxquant.restful.app
callable = app
processes = 4
threads = 2
stats = 127.0.0.1:5000

```

### 启动uwsgi服务

配置好Nginx和uwsgi配置文件后,需要启动uwsgi服务,只需运行如下uwsgi命令即可,安装uwsgi可参考uwsgi官网


```
uwsgi app.ini

```
启动后即可在浏览器访问API接口


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dsxkline/dsxquant",
    "name": "dsxquant",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "fangyunsm",
    "author_email": "fangyunsm <934476300@qq.com>",
    "download_url": "https://files.pythonhosted.org/packages/da/00/49e2473b7321778c5418486e4641e9bd799894607e16036a1e9eb501e5d6/dsxquant-2.2.2.tar.gz",
    "platform": null,
    "description": "# Dsxquant \u5f00\u6e90\u91cf\u5316\u5de5\u5177\u7bb1\n\nDsxquant \u662f\u4e00\u4e2a\u57fa\u4e8epython\u8bed\u8a00\u5f00\u53d1\u7684\u7684\u91cf\u5316\u5de5\u5177\u7bb1\uff0c\u4e3b\u8981\u7279\u5f81\u662f\u5176\u5de5\u5177\u5c5e\u6027\uff0c\u4e13\u4e3a\u4e0a\u5c42\u7b56\u7565\u5e94\u7528\u63d0\u4f9b\u670d\u52a1\u3002\n\n<img alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/dsxquant\"> <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/dsxquant?label=dsxquant\"> <img alt=\"GitHub code size in bytes\" src=\"https://img.shields.io/github/languages/code-size/dsxkline/dsxquant\"> <img alt=\"PyPI - Downloads\" src=\"https://img.shields.io/pypi/dd/dsxquant\"> <img alt=\"Libraries.io dependency status for GitHub repo\" src=\"https://img.shields.io/librariesio/github/dsxkline/dsxquant\"> <img alt=\"GitHub\" src=\"https://img.shields.io/github/license/dsxkline/dsxquant\"> <img alt=\"GitHub search hit counter\" src=\"https://img.shields.io/github/search/dsxkline/dsxquant/dsxquant\"> <img alt=\"Website\" src=\"https://img.shields.io/website?label=dsxquant%20website&up_message=online&url=https%3A%2F%2Fwww.dsxquant.com\"> <img alt=\"Lines of code\" src=\"https://img.shields.io/tokei/lines/github/dsxkline/dsxquant\">\n\n## \u4e00\u3001\u7b80\u4ecb\nDsxquant \u91c7\u7528\u6a21\u5757\u5316\u8bbe\u8ba1\u601d\u60f3\uff0c\u6846\u67b6\u96c6\u6210\u4e86\u6570\u636e\u3001\u56de\u6d4b\u3001\u7b56\u7565\u3001\u56e0\u5b50\u3001\u4eff\u771f\u3001\u8d44\u7ba1\u3001\u4ea4\u6613\u7b49\u6a21\u5757\u3002\n\n\u6280\u672f\u67b6\u6784\n\n<img src=\"https://www.dsxquant.com/wp-content/uploads/2023/03/Dsxquant-Main-Engine-2-1024x985.png\" width=\"300\" />\n\n## \u4e8c\u3001\u6570\u636e\u7ed3\u6784\n\n\u6587\u6863\u6570\u636e\u7ed3\u6784\u63cf\u8ff0\u4e3b\u8981\u57fa\u4e8ePandas\u7684 Series \u548cDataFrame\uff0c\u6846\u67b6\u63a5\u53e3\u90fd\u652f\u6301\u8fd4\u56deJson\u6570\u636e\uff0cSeries\u3001DataFrame\uff0c\u652f\u6301 csv \u6587\u4ef6\u8f6c\u6362\u7b49\u3002\n\n## \u4e09\u3001\u5b89\u88c5\nDsxquant \u6258\u7ba1\u5728 Github,Gitee,PyPi\uff0c\u9ed8\u8ba4\u91c7\u7528PyPi\u5305\u5b89\u88c5\u65b9\u5f0f\n\n### 1\u3001PyPi \u5b89\u88c5\n\n```\npip install dsxquant\n```\n\n### 2\u3001Git \u6e90\u7801\u5b89\u88c5\u5bfc\u5165\n\n```\ngit clone https://github.com/dsxkline/dsxquant.git\n```\n\n### 3\u3001\u5b89\u88c5\u4f9d\u8d56\n\u76f4\u63a5\u901a\u8fc7\u4f9d\u8d56\u6587\u4ef6\u5b89\u88c5\u5373\u53ef\uff0c\u4e5f\u53ef\u4ee5\u624b\u52a8\u4e00\u4e2a\u4e00\u4e2a\u5b89\u88c5\n\n```\npip install -r requirements.txt\n\nDeprecated==1.2.13\ndsxindexer==1.0.0\nFlask==2.3.2\nnumpy==1.23.4\npandas==1.5.1\nprettytable==3.7.0\nprogressbar33==2.4\n\n```\n\n## \u56db\u3001\u5feb\u901f\u4e0a\u624b\n\n\u5b89\u88c5\u540e\u76f4\u63a5\u5bfc\u5165\u5305\u5373\u53ef\u4f7f\u7528\n\n``` python\nimport dsxquant\n# dsxquant \u9ed8\u8ba4\u7ef4\u62a4\u4e86\u4e00\u4e2a\u8fde\u63a5\n# \u53ef\u76f4\u63a5\u8bfb\u53d6\u5b9e\u65f6\u884c\u60c5\n# result = dsxquant.get_quotes(\"sh000001,sh600000\").series()\nresult = dsxquant.get_price(\"sh000001,sh600000\").series()\nprint(result)\n```\n\n## \u4e94\u3001\u8fde\u63a5\n\n\u8fde\u63a5\u65b9\u5f0f\uff1a\n\u540c\u6b65\u8fde\u63a5 \uff08\u9ed8\u8ba4\uff09connect()\n\u5f02\u6b65\u8fde\u63a5 syncconnect()\n### \u793a\u4f8b\uff1a\n\n``` python\n# \u9ed8\u8ba4\u91c7\u7528\u540c\u6b65\u8fde\u63a5\ndd = dsxquant.dataser()\nif dd.connect():\n   # \u8bfb\u53d6\u884c\u4e1a\u5206\u7c7b\n   result = dd.get_hangye().series()\n   print(result)\n```\n\n### \u6846\u67b6\u652f\u6301with\u8bed\u6cd5\n\n```python\n# with\u8bed\u6cd5\u6846\u67b6\u8bbe\u8ba1\u4e86\u81ea\u52a8\u8fde\u63a5\uff0c\u5982\u679c\u8fde\u63a5\u4e0d\u6210\u529f\u4f1a\u8fd4\u56deNone\uff0c\u6240\u4ee5\u8fd9\u91cc\u5224\u65ad\u4e00\u4e0b\u5373\u53ef\nwith dsxquant.dataser() as dd:\n    # \u8fde\u63a5\u6210\u529f\u53ef\u8c03\u7528\n    if dd:\n       result = dd.get_quotes(\"sh000001\").datas()\n       print(result.data)\n```\n\n### \u5f02\u6b65\u8ba2\u9605\u6a21\u5f0f\n\n```python\n# \u5f02\u6b65\u8ba2\u9605\u6a21\u5f0f\uff0c\u8ba2\u9605\u6a21\u5f0f\u8bf7\u6c42\u662f\u5f02\u6b65\u8fdb\u884c\u7684\uff0c\u8ba2\u9605\u6210\u529f\u540e\u670d\u52a1\u5668\u4f1a\u4e3b\u52a8\u63a8\u9001\u4fe1\u606f\u5230\u60a8\u7684\u56de\u8c03\u51fd\u6570\u4e2d,\u6ce8\u610f\u8bf7\u4e0d\u8981\u624b\u52a8\u8c03\u7528\u5173\u95ed\u8fde\u63a5\u65b9\u6cd5\ndd_async = dsxquant.dataser.asyncconnect()\nif dd_async:\n    # \u5f02\u6b65\u8bf7\u6c42\u5b9e\u65f6\u884c\u60c5\u63a5\u53e3\uff0c\u670d\u52a1\u5668\u4f1a\u4e3b\u52a8\u63a8\u9001\u5b9e\u65f6\u884c\u60c5\n    def quotes_callback(response:dsxquant.parser):\n        # logger.debug(response.get(\"msg\"))\n        result = response.dataframe()\n        logger.debug(result)\n        pass\n    \n    result = dd_async.sub_quotes(\"sh000001,sh600000,sz000001,bj430047,bj430090\",quotes_callback)\n    logger.debug(result)\n```\n\n## \u516d\u3001\u8ba2\u9605\n\nDsxquant \u63d0\u4f9b\u5b9e\u65f6\u884c\u60c5\u8ba2\u9605\u529f\u80fd\uff0c\u53ef\u6279\u91cf\u8ba2\u9605\uff0c\u4e5f\u53ef\u4ee5\u5168\u91cf\u8ba2\u9605\u3002\u8ba2\u9605\u529f\u80fd\u9700\u8981\u542f\u7528\u5f02\u6b65\u8fde\u63a5 asyncconnect()\uff0c\u6279\u91cf\u8ba2\u9605\u6700\u591a\u652f\u630150\u4e2a\u80a1\u7968\u4ee3\u7801\uff0c\u5168\u91cf\u8ba2\u9605\u9ed8\u8ba4\u5168\u5e02\u573a\u53d8\u52a8\u6570\u636e\u63a8\u9001\u3002\n\n```python\n# \u5f02\u6b65\u8ba2\u9605\u6a21\u5f0f\uff0c\u8ba2\u9605\u6a21\u5f0f\u8bf7\u6c42\u662f\u5f02\u6b65\u8fdb\u884c\u7684\uff0c\u8ba2\u9605\u6210\u529f\u540e\u670d\u52a1\u5668\u4f1a\u4e3b\u52a8\u63a8\u9001\u4fe1\u606f\u5230\u60a8\u7684\u56de\u8c03\u51fd\u6570\u4e2d,\u6ce8\u610f\u8bf7\u4e0d\u8981\u624b\u52a8\u8c03\u7528\u5173\u95ed\u8fde\u63a5\u65b9\u6cd5\ndd_async = dsxquant.dataser.asyncconnect()\nif dd_async:\n    # \u5f02\u6b65\u8bf7\u6c42\u5b9e\u65f6\u884c\u60c5\u63a5\u53e3\uff0c\u670d\u52a1\u5668\u4f1a\u4e3b\u52a8\u63a8\u9001\u5b9e\u65f6\u884c\u60c5\n    def quotes_callback(response:dsxquant.parser):\n        # print(response.get(\"msg\"))\n        result = response.dataframe()\n        print(result)\n    # \u6279\u91cf\u8ba2\u9605\u80a1\u7968\u4ee3\u7801,\u6279\u91cf\u8ba2\u9605\u6700\u591a\u652f\u630150\u4e2a\u80a1\u7968\u4ee3\u7801\n    result = dd_async.sub_quotes(\"sh000001,sh600000,sz000001,bj430047,bj430090\",quotes_callback)\n    print(result)\n        \n    def quotes_all_callback(response:dsxquant.parser):\n        dd = response.dataframe()\n        # \u7b2c\u4e00\u884c\u9ed8\u8ba4\u662f\u5b57\u6bb5\u540d\u79f0\u6570\u7ec4 [\"amount\",\"close\",.....]\n        names:list = list(dd.values[0])\n        # \u7b2c\u4e8c\u884c\u5f00\u59cb\u662f\u6570\u636e\n        quote = dd.loc[1,:]\n        code = quote[names.index(\"code\")]\n        t = quote[names.index(\"lasttime\")]\n        d = quote[names.index(\"lastdate\")]\n        t = datetime.datetime.strptime(d+\" \"+t,\"%Y-%m-%d %H:%M:%S\")\n        s = datetime.datetime.now() - t\n        print(\"%s \u7b14 %s \u65f6\u95f4 %s \u5f53\u524d\u65f6\u95f4 %s \u5ef6\u65f6 %s s\" % (dd.__len__(),code,t,datetime.datetime.now(),s.seconds))\n    # \u5168\u91cf\u8ba2\u9605\u5168\u5e02\u573a\u6240\u6709\u80a1\u7968\u5b9e\u65f6\u884c\u60c5\n    dd_async.sub_all_quotes(quotes_all_callback)\n```\n\n### \u53d6\u6d88\u8ba2\u9605\n\n```python\nsuccess = dd_async.cancel(quote)\nif success!=None:\n    print(\"cancel success:\"+quote.api_name)\n```\n\n## \u4e03\u3001\u8bfb\u53d6\u5e02\u573a\u80a1\u7968\n\n\u76ee\u524d\u5e02\u573a\u4ec5\u652f\u6301\u4e0a\u4ea4\u6240\u3001\u6df1\u4ea4\u6240\u3001\u5317\u4ea4\u6240\u3002\n\n### \u5e02\u573a\u679a\u4e3e\u503c\uff1a\n\n```python\n# \u5e02\u573a\u4ee3\u7801\nclass MARKET:\n    SH=0                            # \u4e0a\u4ea4\u6240\n    SZ=1                            # \u6df1\u4ea4\u6240\n    BJ=2                            # \u5317\u4ea4\u6240\n    HK=3                            # \u6e2f\u4ea4\u6240\n    US=4                            # \u7f8e\u56fd\n```\n\n### \u8bfb\u53d6\u67d0\u4e2a\u5e02\u573a\u7684\u6240\u6709\u80a1\u7968\u5217\u8868\n\n```python\n# \u8bfb\u53d6\u67d0\u4e2a\u5e02\u573a\u7684\u6240\u6709\u80a1\u7968\u4ee3\u7801\u5217\u8868\nresult = dd.get_stocks(dsxquant.market.SZ).series()\nprint(result)\n```\n\n## \u516b\u3001\u8bfb\u53d6\u5206\u7c7b\u5217\u8868\n\n\u4e3b\u8981\u662f\u8bfb\u53d6\u884c\u4e1a\u3001\u6982\u5ff5\u3001\u5730\u57df\u5206\u7c7b\u7684\u80a1\u7968\u4ee3\u7801\n\n### \u8bfb\u53d6\u884c\u4e1a\u5206\u7c7b\n```python\n# \u8bfb\u53d6\u884c\u4e1a\u5206\u7c7b\nresult = dd.get_hangye().series()\nprint(result)\n```\n\n\u8f93\u51fa\u683c\u5f0f\n\n```\n\n       0\n0     \u7164\u70ad\n1   \u77f3\u6cb9\u77f3\u5316\n2   \u7f8e\u5bb9\u62a4\u7406\n3     \u73af\u4fdd\n4   \u7535\u529b\u8bbe\u5907\n...\n25    \u6c7d\u8f66\n26    \u7535\u5b50\n27  \u6709\u8272\u91d1\u5c5e\n28    \u94a2\u94c1\n29  \u519c\u6797\u7267\u6e14\n30    \u7efc\u5408\n```\n\n### \u8bfb\u53d6\u6982\u5ff5\u5206\u7c7b\n```python\n# \u8bfb\u53d6\u6982\u5ff5\u5206\u7c7b\nresult = dd.get_gainian().series()\nprint(result)\n```\n\n\u8f93\u51fa\u683c\u5f0f\n\n```\n         0\n0      \u8840\u6c27\u4eea\n1    \u6beb\u7c73\u6ce2\u96f7\u8fbe\n2     eSIM\n3     AI\u8bad\u7ec3\n4     \u6570\u5b57\u54e8\u5175\n..     ...\n619     \u4e3e\u724c\n620   \u519b\u6c11\u878d\u5408\n621    \u4eac\u6d25\u5180\n622   \u6297\u764c\u836f\u7269\n623   \u6628\u65e5\u6da8\u505c\n```\n\n### \u8bfb\u53d6\u5730\u57df\u5206\u7c7b\n\n```python\n# \u8bfb\u53d6\u5730\u57df\u5206\u7c7b\nresult = dd.get_diyu().series()\nprint(result)\n```\n\n\u8f93\u51fa\u683c\u5f0f\n\n```\n           0\n0   \u65b0\u7586\u7ef4\u543e\u5c14\u81ea\u6cbb\u533a\n1    \u5b81\u590f\u56de\u65cf\u81ea\u6cbb\u533a\n2        \u9752\u6d77\u7701\n3        \u7518\u8083\u7701\n25       \u8fbd\u5b81\u7701\n...\n29       \u5929\u6d25\u5e02\n30       \u5317\u4eac\u5e02\n```\n\n## \u4e5d\u3001\u8bfb\u53d6\u5b9e\u65f6\u884c\u60c5\n\n\u76ee\u524d\u4ec5\u652f\u6301A\u80a1\u5b9e\u65f6\u884c\u60c5\uff0c\u884c\u60c5\u6765\u81ea\u4e8e\u7f51\u7edc\u516c\u5f00\u6570\u636e\uff0c\u5ef6\u65f610\u79d2\u4ee5\u4e0a\uff0c\u4f9b\u4e2a\u4eba\u91cf\u5316\u5f00\u53d1\u8005\u6d4b\u8bd5\u6240\u7528\uff0c\u8bf7\u52ff\u7528\u4e8e\u5546\u4e1a\u7528\u9014\u3002\n\n```python\n # \u8bfb\u53d6\u5b9e\u65f6\u884c\u60c5\u5e76\u5bfc\u51facsv\u6587\u4ef6\nresult = dd.get_quotes([(\"000002\",dsxquant.MARKET.SZ),(\"600000\",dsxquant.MARKET.SH)]).csv(\"quotes.csv\")\nprint(result)\n\n# \u8bfb\u53d6\u5b9e\u65f6\u884c\u60c5\nresult = dd.get_quotes([(\"000002\",dsxquant.MARKET.SZ),(\"600000\",dsxquant.MARKET.SH)]).dataframe()\nprint(result)\n\n# \u8bfb\u53d6\u5b9e\u65f6\u884c\u60c5\uff0c\u6279\u91cf\u5b57\u7b26\u4e32\nresult = dd.get_quotes(\"sh000001,sz000001,sh600000\").datas()\nprint(result.data)\n\n# \u8bfb\u53d6\u5b9e\u65f6\u884c\u60c5\uff0c\u5b57\u7b26\u4e32\nresult = dd.get_quotes(\"sh000001\").datas()\nif result.success:\n    print(result.data)\n```\n\n## \u5341\u3001\u8bfb\u53d6\u5386\u53f2K\u7ebf\n\n\u8bfb\u53d6\u4e0a\u5e02\u4ee5\u6765\u6240\u6709\u7684\u5386\u53f2K\u7ebf\u6570\u636e\uff0c\u524d\u540e\u590d\u6743\u6570\u636e\u7b49\u3002\u652f\u6301\u8bfb\u53d6\u65e5K\u3001\u5468K\u3001\u6708K\u3001\u5e74K\u7b49\u6570\u636e\n\n### \u8bfb\u53d6\u65e5K\u5386\u53f2\u6570\u636e\n\n```python\n# \u8bfb\u53d6\u5386\u53f2K\u7ebf\u6570\u636e\nresult = dd.get_klines(\"000001\",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.DAY).dataframe()\nprint(result)\n```\n\n\u8f93\u51fa\u683c\u5f0f [\u65e5\u671f,\u5f00,\u9ad8,\u4f4e,\u6536,\u6210\u4ea4\u91cf,\u6210\u4ea4\u989d]\n\n```\n                                                     0\n0    20230227,621462.0,13.88,13.68,13.86,621462.0,8...\n1    20230224,14.02,14.03,13.80,13.86,729989,101265...\n2    20230223,14.00,14.32,13.98,14.05,824491,116553...\n3    20230222,14.00,14.12,13.94,14.02,638922,895742...\n4    20230221,14.06,14.20,13.92,14.10,990495,139315...\n..                                                 ...\n315  20211109,17.48,17.65,17.26,17.53,1240573,21631...\n316  20211108,17.62,17.81,17.36,17.42,1376815,24064...\n317  20211105,17.85,18.00,17.57,17.64,1096040,19424...\n318  20211104,18.08,18.10,17.80,17.87,983411,176067...\n319  20211103,18.10,18.24,17.85,18.03,1114972,20093...\n```\n\n### \u8bfb\u53d6\u5468K\u5386\u53f2\u6570\u636e\n\n```python\n# \u8bfb\u53d6\u5468K\u7ebf\u6570\u636e\nresult = dd.get_klines(\"000001\",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.WEEK).dataframe()\nprint(result)\n```\n\n### \u8bfb\u53d6\u6708K\u5386\u53f2\u6570\u636e\n\n```python\n# \u8bfb\u53d6\u6708K\u7ebf\u6570\u636e\nresult = dd.get_klines(\"000001\",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.MONTH).dataframe()\nprint(result)\n```\n\n### \u8bfb\u53d6\u5e74K\u5386\u53f2\u6570\u636e\n\n```python\n# \u8bfb\u53d6\u5e74K\u7ebf\u6570\u636e\nresult = dd.get_klines(\"000001\",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.YEAR).dataframe()\nprint(result)\n```\n\n## \u5341\u4e00\u3001\u8bfb\u53d6\u5206\u949fK\u7ebf\n\n\u652f\u6301\u8bfb\u53d630\u5929\u5185\u7684\u5386\u53f2\u5206\u949fK\u7ebf\u6570\u636e\uff0c1\u5206\u949f\u30015\u5206\u949f\u300115\u5206\u949f\u300130\u5206\u949f\u300160\u5206\u949f\u7b49\u3002\n\n### \u8bfb\u53d61\u5206\u949f\u5386\u53f2\u6570\u636e\n\n```python\n# \u8bfb\u53d61\u5206\u949fK\u7ebf\u6570\u636e\nresult = dd.get_klines(\"000001\",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.M1,page_size=1000).dataframe()\nprint(result)\n```\n\n\u8fd4\u56de\u6570\u636e\u683c\u5f0f\n```\n                                                     0\n0    202302240931,14.02,14.03,13.94,13.96,26062,364...\n1    202302240932,13.96,13.96,13.92,13.96,10384,144...\n2    202302240933,13.96,13.96,13.93,13.94,6386,8908...\n3    202302240934,13.93,13.94,13.92,13.93,10046,139...\n4    202302240935,13.93,13.93,13.92,13.93,4432,6172...\n..                                                 ...\n475  202302031456,14.35,14.36,14.34,14.35,3920,5624...\n476  202302031457,14.36,14.36,14.34,14.34,5109,7332...\n477  202302031458,14.35,14.35,14.35,14.35,585,84005...\n478        202302031459,14.35,14.35,14.35,14.35,0,0.00\n479  202302031500,14.32,14.32,14.32,14.32,21701,310...\n```\n\n### \u8bfb\u53d65\u5206\u949f\u5386\u53f2\u6570\u636e\n\n```python\n# \u8bfb\u53d65\u5206\u949fK\u7ebf\u6570\u636e\nresult = dd.get_klines(\"000001\",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.M5,page_size=1000).dataframe()\nprint(result)\n```\n\n### \u8bfb\u53d615\u5206\u949f\u5386\u53f2\u6570\u636e\n\n```python\n# \u8bfb\u53d615\u5206\u949fK\u7ebf\u6570\u636e\nresult = dd.get_klines(\"000001\",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.M15,page_size=1000).dataframe()\nprint(result)\n```\n\n### \u8bfb\u53d630\u5206\u949f\u5386\u53f2\u6570\u636e\n```python\n# \u8bfb\u53d630\u5206\u949fK\u7ebf\u6570\u636e\nresult = dd.get_klines(\"000001\",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.M30,page_size=1000).dataframe()\nprint(result)\n```\n\n### \u8bfb\u53d660\u5206\u949f\u5386\u53f2\u6570\u636e\n\n```python\n# \u8bfb\u53d660\u5206\u949fK\u7ebf\u6570\u636e\nresult = dd.get_klines(\"000001\",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.M60,page_size=1000).dataframe()\nprint(result)\n```\n\n## \u5341\u4e8c\u3001\u590d\u6743\u56e0\u5b50\n\n\u6846\u67b6\u590d\u6743\u56e0\u5b50\u91c7\u7528\u7684\u662f\u6da8\u8dcc\u5e45\u590d\u6743\u7b97\u6cd5\uff0c\u7b97\u6cd5\u5df2\u5f00\u6e90\uff0c\u4e3b\u8981\u91c7\u7528\u5206\u7ea2\u914d\u80a1\u548c\u80a1\u6539\u6570\u636e\u8fdb\u884c\u8ba1\u7b97\uff0c\u8be6\u7ec6\u7b97\u6cd5\u4ecb\u7ecd\u53ef\u53c2\u8003\u6587\u7ae0\u300a\u91cf\u5316\u57fa\u7840\u7b97\u6cd5:K\u7ebf\u6da8\u8dcc\u5e45\u590d\u6743\u7b97\u6cd5\u63ed\u79d8\u548c\u5b9e\u73b0\u300b\n\n### \u83b7\u53d6\u590d\u6743\u56e0\u5b50\n\n```python\n# \u8bf7\u6c42\u590d\u6743\u56e0\u5b50\nresult = dd.get_factors(\"000001\",dsxquant.MARKET.SZ).dataframe()\nprint(result)\n```\n\n\u8f93\u51fa\u683c\u5f0f\uff0c\u9664\u6743\u65e5\u7684\u590d\u6743\u56e0\u5b50\u5217\u8868 {\u65e5\u671f:[\u524d\u590d\u6743\u56e0\u5b50,\u540e\u590d\u6743\u56e0\u5b50]}\n```\n\n20220722    0.982475,60.840279\n20210514    0.974809,59.774055\n20200528    0.958463,59.307677\n20190626    0.948114,58.313133\n20180712    0.933428,57.683542\n20170721    0.919984,56.790039\n20160616    0.755418,55.972096\n20150413    0.623983,45.959846\n20140612    0.512923,37.963297\n20130620    0.317744,31.206389\n20121019    0.315393,19.331661\n20081031    0.241891,19.188569\n20070618    0.219832,14.716718\n20030929    0.216301,13.374637\n20020723    0.214064,13.159841\n20001106    0.186992,13.023705\n19991018    0.182043,11.376639\n19970825    0.120593,11.075537\n19960527     0.060297,7.336915\n19950925      0.04872,3.668457\n19940711     0.031303,2.964128\n19930524     0.016436,1.904488\n```\n\n\u5f97\u5230\u590d\u6743\u56e0\u5b50\u540e\uff0c\u6839\u636e\u5bf9\u5e94\u7684\u65e5\u671f\u5373\u53ef\u8ba1\u7b97\u51fa\u524d\u540e\u590d\u6743\u6570\u636e,\u8ba1\u7b97\u65b9\u6cd5\u53c2\u8003 \u300a\u91cf\u5316\u57fa\u7840\u7b97\u6cd5:K\u7ebf\u6da8\u8dcc\u5e45\u590d\u6743\u7b97\u6cd5\u63ed\u79d8\u548c\u5b9e\u73b0\u300b\n\n## \u5341\u4e09\u3001\u5206\u7ea2\u914d\u80a1\n\n\u83b7\u53d6\u4e0a\u5e02\u4ee5\u6765\u6240\u6709\u7684\u5206\u7ea2\u914d\u80a1\u4fe1\u606f\uff0c\u6b64\u4fe1\u606f\u6765\u6e90\u4e8e\u7f51\u7edc\u516c\u5f00\u6570\u636e\uff0c\u7531Dsxquant\u6574\u7406\u6e05\u6d17\u3002\n\n### \u83b7\u53d6\u5206\u7ea2\u914d\u80a1\n\n```python\n# \u8bf7\u6c42\u5206\u7ea2\u914d\u80a1\u4fe1\u606f\nresult = dd.get_sharebonus(\"000001\",dsxquant.MARKET.SZ).dataframe()\nprint(result)\n```\n\n\u8fd4\u56de\u6570\u636e\u683c\u5f0f\uff0c\u53c2\u6570\u540d\u79f0\u53ef\u53c2\u8003 \u63a5\u53e3\u6587\u6863\n\n```\ncode              sz000001\nper_ten_allo              \nallo_price                \nanno_day        2022-07-15\nper_ten_send             0\nper_ten_incr             0\nper_cash_div          2.28\nshare_day       2022-07-22\nreg_day         2022-07-21\nlist_day              \n```\n\n## \u5341\u56db\u3001\u8d22\u52a1\u62a5\u8868\n\n\u8d22\u52a1\u62a5\u8868\u6570\u636e\u6765\u6e90\u4e8e\u7f51\u7edc\u516c\u5f00\u6570\u636e\uff0c\u7531Dsxquant\u6536\u96c6\u6574\u7406\uff0c\u63d0\u4f9b\u8d22\u52a1\u6307\u6807\u3001\u8d44\u4ea7\u8d1f\u503a\u8868\u3001\u5229\u6da6\u8868\u3001\u73b0\u91d1\u6d41\u91cf\u8868\u7b49\u62a5\u8868\u67e5\u8be2\u3002\n\n### \u83b7\u53d6\u8d22\u52a1\u6307\u6807\n\n```python\n# \u8d22\u52a1\u6307\u6807\nresult = dd.get_finance(\"000002\",dsxquant.MARKET.SZ,report_type=dsxquant.config.REPORT_TYPE.DEFAULT).dataframe()\nprint(result)\n```\n\n\u8fd4\u56de\u6570\u636e\u683c\u5f0f\n\n```\nCODE                 sz000002\nDATE               2022-09-30\nZZC      1832624105913.530029\nLDZC     1482234397741.830078\nGDZC       14951487488.129999\nZFZ      1426655627128.919922\nLDFZ     1168326002698.350098\nJZC       405968478784.610107\nMGJZC                19.73719\nYYSR      337673241644.890015\nYYLR       37447020773.470001\nLRZE       37731123134.410004\nJLR            27244596166.41\nMGSY                   1.4697\n```\n\n### \u83b7\u53d6\u8d44\u4ea7\u8d1f\u503a\u8868\n\n```python\n# \u8d44\u4ea7\u8d1f\u503a\u8868\nresult = dd.get_finance(\"000002\",dsxquant.MARKET.SZ,report_type=dsxquant.config.REPORT_TYPE.BALANCESHEET).dataframe()\nprint(result)\n```\n\u8fd4\u56de\u6570\u636e\u683c\u5f0f\n```\nreport_date               2022-09-30\nzc_1                                \nzc_2                                \nzc_3                                \nzc_20                               \n                        ...         \nfzgdqy_2                        None\nfzgdqy_total    1832624105913.530029\nop_1                            None\nop_2                            None\ncode                        sz000002\n```\n\n### \u83b7\u53d6\u73b0\u91d1\u6d41\u91cf\u8868\n\n```python\n# \u73b0\u91d1\u6d41\u91cf\u8868\nresult = dd.get_finance(\"000002\",dsxquant.MARKET.SZ,report_type=dsxquant.config.REPORT_TYPE.CASHFLOW).dataframe()\nprint(result)\n```\n\n\u8fd4\u56de\u6570\u636e\u683c\u5f0f\n\n```\nreport_date    2022-09-30\njy_in_1                  \njy_in_2                  \njy_in_3                  \njy_in_4              None\n                  ...    \nje_11                    \nfbcce_add                \nop_1                 None\nop_2                 None\ncode             sz000002\n```\n\n### \u83b7\u53d6\u5229\u6da6\u8868\n\n```python\n# \u5229\u6da6\u8868\nresult = dd.get_finance(\"000002\",dsxquant.MARKET.SZ,report_type=dsxquant.config.REPORT_TYPE.PROFIT).dataframe()\nprint(result)\n```\n\n\u8fd4\u56de\u6570\u636e\u683c\u5f0f\n\n```\nreport_date             2022-09-30\nyyzsr          337673241644.890015\nsr_1           337673241644.890015\nsr_2                          None\nsr_3                          None\n                      ...         \nzhsy_3          26123838848.540001\nzhsy_4          15412047995.690001\nzhsy_5              10711790852.85\nzhsy_6                        None\ncode                      sz000002\n```\n\n## \u5341\u4e94\u3001\u5206\u65f6\u7ebf\n\u4ec5\u652f\u6301\u67e5\u8be230\u5929\u5185\u5206\u65f6\u7ebf\u5386\u53f2\u6570\u636e\n\n```python\n# \u8bf7\u6c42\u5206\u65f6\u56fe\u4fe1\u606f\uff0c\u9ed8\u8ba4\u662f\u6700\u65b0\u4e00\u4e2a\u4ea4\u6613\u65e5\u7684\u4fe1\u606f\nresult = dd.get_timeshring(\"000001\",dsxquant.MARKET.SZ).datas()\nif result.success:\n    print(result.data)\n```\n\n\u8fd4\u56de\u6570\u636e\u683c\u5f0f\n\n```\n[\n['0925', 13.85, 659700.0, 9136845.0, 13.85], \n['0930', 13.85, 3384822.0, 46903478.453999996, 13.857], \n['0931', 13.82, 1444600.0, 20009154.6, 13.851], \n['0932', 13.85, 1255300.0, 17382139.099999998, 13.847], \n['0933', 13.88, 2193900.0, 30396484.5, 13.855], \n['0934', 13.86, 913600.0, 12658841.6, 13.856], \n...\n['1454', 13.95, 404100.0, 5612949.0, 13.89], \n['1455', 13.95, 670000.0, 9306970.0, 13.891], \n['1456', 13.95, 300500.0, 4174245.5, 13.891], \n['1500', 13.96, 993594.0, 13803007.848, 13.892]\n]\n```\n\n## \u5341\u516d\u3001\u9010\u7b14\u4ea4\u6613\n\n\u53ea\u652f\u6301\u67e5\u8be230\u5929\u5185\u7684\u5386\u53f2\u9010\u7b14\u4ea4\u6613\u4fe1\u606f\n\n### \u83b7\u53d6\u9010\u7b14\u4ea4\u6613\u4fe1\u606f\n\n```python\n# \u8bf7\u6c42\u9010\u7b14\u4ea4\u6613\nresult = dd.get_translist(\"000001\",dsxquant.MARKET.SZ).dataframe()\nprint(result)\n```\n\n\u8fd4\u56de\u6570\u636e\u683c\u5f0f\n\n```\n      0      1         2             3       4\n0  1500  13.96  993594.0  1.380301e+07  13.892\n1  1456  13.95  300500.0  4.174246e+06  13.891\n2  1455  13.95  670000.0  9.306970e+06  13.891\n3  1454  13.95  404100.0  5.612949e+06  13.890\n4  1453  13.94  537500.0  7.465875e+06  13.890\n5  1452  13.96  356300.0  4.949007e+06  13.890\n6  1451  13.96  246100.0  3.418083e+06  13.889\n7  1450  13.95  671800.0  9.330630e+06  13.889\n8  1449  13.96  253800.0  3.525028e+06  13.889\n9  1448  13.96  423200.0  5.877402e+06  13.888\n```\n\n## \u5341\u4e03\u3001\u56de\u6d4b\n\n\u76ee\u524d\u652f\u6301\u7b80\u5355\u56de\u6d4b\u529f\u80fd\uff0c\u652f\u6301\u65e5\u7ebf\u548c\u5206\u949f\u7ebf\u7ea7\u522b\u7684\u5386\u53f2\u6570\u636e\u56de\u6d4b\n\n\n```python\nfrom dsxquant.engins.engin import Engin\nfrom dsxquant.backtest.back_test import BackTest\nfrom dsxquant import StrategyEngin,EmulationEngin,DataFeed,EventType\nfrom dsxquant.strategy.common.macross_strategy import MACrossStrategy\nimport dsxquant\n# \u5148\u542f\u52a8\u7cfb\u7edf\u5f15\u64ce\nengin = Engin().start()\n# \u5b89\u88c5\u6a21\u5757\nengin.install(StrategyEngin,EmulationEngin,DataFeed)\n# \u8c03\u7528\u56de\u6d4b,\u8fd9\u4e2a\u4f8b\u5b50\u662f\u65e5\u7ebf\u56de\u6d4b\nbacktest = BackTest(MACrossStrategy,\"sz000001\",start=\"20200412\",end=\"20230427\",data=EventType.DAYLINE)\nengin.install(backtest)\n# \u7b49\u5f85\u56de\u6d4b\u5b8c\u6210\u5e76\u663e\u793a\u56de\u6d4b\u7ed3\u679c  \nbacktest.show()\nengin.shutdown()\n\n```\n\n## \u5341\u516b\u3001RESTful Api \u63a5\u53e3\n\u91c7\u7528Flask\u6846\u67b6\u8bbe\u8ba1\u4e86\u4e00\u5957RESTful API\uff0c\u652f\u6301\u4e00\u952e\u542f\u52a8\uff0c\u652f\u6301Nginx\u90e8\u7f72\u7b49\n\n```python\nimport dsxquant\n# \u8fd9\u91cc\u7528\u4e8e\u672c\u5730\u6d4b\u8bd5\uff0c\u751f\u4ea7\u90e8\u7f72\u8bf7\u7528Nginx\u7b49\u670d\u52a1\ndsxquant.restfulapi.run()\n\n```\n\u542f\u52a8\u540e\u901a\u8fc7\u6d4f\u89c8\u5668\u8fdb\u884c\u8bbf\u95ee http://127.0.0.1:5000/price?symbols=sh000001,sz000001\n\n### Nginx \u914d\u7f6e\nNginx \u53ea\u9700\u8981\u505a\u53cd\u5411\u4ee3\u7406\u914d\u7f6e\u5373\u53ef\n```\nserver {\n    listen 80;\n    server_name example.com;\n\n    location / {\n        uwsgi_pass 127.0.0.1:5001;\n        include uwsgi_params;\n    }\n}\n```\n\n### uwsgi \u914d\u7f6eini\u6587\u4ef6\u5373\u53ef\n\n\u8fd9\u91cc\u7684\u7aef\u53e3\u53f7\u8981\u8ddfNginx\u53cd\u5411\u4ee3\u7406\u914d\u7f6e\u7684\u7aef\u53e3\u4e00\u81f4\uff0c\u5176\u4e2d module \u4e3a\u6267\u884c\u7684python\u6587\u4ef6\uff0cdsxquant.restful.app, callable\u4e3aFlask\u9879\u76ee\u7684app\u5bf9\u8c61\uff0c\u5176\u4ed6\u53c2\u6570\u53ef\u4ee5\u53c2\u8003Flask\u6587\u6863\n\n```\n[uwsgi]\nsocket = 127.0.0.1:5001\nmodule = dsxquant.restful.app\ncallable = app\nprocesses = 4\nthreads = 2\nstats = 127.0.0.1:5000\n\n```\n\n### \u542f\u52a8uwsgi\u670d\u52a1\n\n\u914d\u7f6e\u597dNginx\u548cuwsgi\u914d\u7f6e\u6587\u4ef6\u540e\uff0c\u9700\u8981\u542f\u52a8uwsgi\u670d\u52a1\uff0c\u53ea\u9700\u8fd0\u884c\u5982\u4e0buwsgi\u547d\u4ee4\u5373\u53ef\uff0c\u5b89\u88c5uwsgi\u53ef\u53c2\u8003uwsgi\u5b98\u7f51\n\n\n```\nuwsgi app.ini\n\n```\n\u542f\u52a8\u540e\u5373\u53ef\u5728\u6d4f\u89c8\u5668\u8bbf\u95eeAPI\u63a5\u53e3\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Dsxquant \u662f\u4e00\u4e2a\u57fa\u4e8epython\u8bed\u8a00\u5f00\u53d1\u7684\u7684\u91cf\u5316\u5de5\u5177\u7bb1\uff0c\u4e3b\u8981\u7279\u5f81\u662f\u5176\u5de5\u5177\u5c5e\u6027\uff0c\u4e13\u4e3a\u4e0a\u5c42\u7b56\u7565\u5e94\u7528\u63d0\u4f9b\u670d\u52a1\u3002",
    "version": "2.2.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/dsxkline/dsxquant/issues",
        "Homepage": "https://github.com/dsxkline/dsxquant"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "03808935548c9fed62817d6d04a0d63e59b226b702276e7d11b8a0a5039e5eb7",
                "md5": "a7d27a90cfebc1df88503b668bd5b093",
                "sha256": "f94d5592a431605f081f731a71c085db32cf918927915f41600d87e8aed516d9"
            },
            "downloads": -1,
            "filename": "dsxquant-2.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a7d27a90cfebc1df88503b668bd5b093",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.6",
            "size": 64916,
            "upload_time": "2024-03-24T05:52:16",
            "upload_time_iso_8601": "2024-03-24T05:52:16.054615Z",
            "url": "https://files.pythonhosted.org/packages/03/80/8935548c9fed62817d6d04a0d63e59b226b702276e7d11b8a0a5039e5eb7/dsxquant-2.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "da0049e2473b7321778c5418486e4641e9bd799894607e16036a1e9eb501e5d6",
                "md5": "cf0d36141fe02f04a2c4cca83579a8aa",
                "sha256": "eb8cbd43d2d1e2adbe8ce3ad92c3988bb6b31f1500cbd6cfd90e40f11435b792"
            },
            "downloads": -1,
            "filename": "dsxquant-2.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "cf0d36141fe02f04a2c4cca83579a8aa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.6",
            "size": 44219,
            "upload_time": "2024-03-24T05:52:18",
            "upload_time_iso_8601": "2024-03-24T05:52:18.201781Z",
            "url": "https://files.pythonhosted.org/packages/da/00/49e2473b7321778c5418486e4641e9bd799894607e16036a1e9eb501e5d6/dsxquant-2.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-24 05:52:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dsxkline",
    "github_project": "dsxquant",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "Deprecated",
            "specs": [
                [
                    "==",
                    "1.2.13"
                ]
            ]
        },
        {
            "name": "dsxindexer",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "Flask",
            "specs": [
                [
                    "==",
                    "2.3.2"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "1.23.4"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    "==",
                    "1.5.1"
                ]
            ]
        },
        {
            "name": "prettytable",
            "specs": [
                [
                    "==",
                    "3.7.0"
                ]
            ]
        },
        {
            "name": "progressbar33",
            "specs": [
                [
                    "==",
                    "2.4"
                ]
            ]
        }
    ],
    "lcname": "dsxquant"
}
        
Elapsed time: 0.74785s