请 [注册] 或 [登录]  | 返回主站

量化交易吧 /  数理科学 帖子:3119096 新帖:113

聚宽真心不错,欢迎大家使用

555555发表于:8 月 13 日 01:11回复(1)

聚宽真心不错,欢迎大家使用

get_price(security, start_date=None, end_date=None, frequency='daily', fields=None, skip_paused=False, fq='pre', count=None)
#获取一支或者多只标的的行情数据, 按天或者按分钟。不建议获取除1min和1d频率之外的数据

研究功能简介¶

感谢您使用研究功能~~

研究功能基于IPython Notebook,支持灵活的图表处理、数据处理,后续我们还会增加财务数据。

研究功能支持导入第三方库,您可以根据需要引入,查看详情。

研究功能提供分钟级数据,采用Docker技术隔离,资源独立、安全性更高、性能更好,同步支持Python2、Python3。

操作说明¶

操作说明

1 使用帮助(只读)

新手指引,常用API示例。

2 新手指引

研究功能简介,操作说明,常用API示例。

3 常用操作

  • New:

    • Text File:新建txt文件(可修改文件后缀名,修改为任意文件类型);

    • Folder:新建文件夹;

    • Python 2:新建基于Python 2的notebook;

    • Python 3:新建基于Python 3的notebook。

  • Upload:

    • 上传文件,文件上传后可以在研究和回测中使用。

Notebook常用操作¶

  • 使用 “Shift+Enter” 运行每个代码块
  • 使用“?”获取帮助
  • 使用Tab键补全代码
#使用“?”获取帮助示例,使用“Shift+Enter”运行;
get_price?
import pandas as pd
pd.DataFrame?
#使用Tab键补全函数名
get_

NameErrorTraceback (most recent call last)
<ipython-input-3-246eeb2c7b5c> in <module>()
      1 #使用Tab键补全函数名
----> 2 get_

NameError: name 'get_' is not defined

研究相关API¶

研究新增如下API

  • get_price()
  • get_all_securities()
  • get_index_stocks()
  • get_industry_stocks()

  • get_price - 获取历史数据

  • get_extras - 获取基金净值/期货结算价等
  • get_fundamentals - 查询财务数据
  • get_index_stocks - 获取指数成份股
  • get_industry_stocks - 获取行业成份股
  • get_concept_stocks - 获取概念成份股
  • get_all_securities - 获取所有标的信息
  • get_security_info - 获取单个标的信息
  • jqdata.get_all_trade_days - 获取所有交易日
  • jqdata.get_trade_days - 获取指定范围交易日
  • jqdata.get_money_flow - 获取资金流信息
  • 更多详见详见API
#导入需要的库
import pandas as pd
import seaborn as sns
#获取股票510300.XSHG2015年1月的日级交易数据
df = get_price('510300.XSHG', start_date='2015-01-01', end_date='2019-01-31', frequency='daily', fields=['open','close']) 
df
open close
2015-01-05 3.353 3.431
2015-01-06 3.410 3.408
2015-01-07 3.391 3.407
2015-01-08 3.416 3.332
2015-01-09 3.323 3.308
2015-01-12 3.309 3.298
2015-01-13 3.295 3.292
2015-01-14 3.298 3.284
2015-01-15 3.284 3.377
2015-01-16 3.389 3.407
2015-01-19 3.227 3.066
2015-01-20 3.112 3.180
2015-01-21 3.191 3.326
2015-01-22 3.332 3.332
2015-01-23 3.355 3.347
2015-01-26 3.366 3.379
2015-01-27 3.387 3.346
2015-01-28 3.320 3.292
2015-01-29 3.249 3.257
2015-01-30 3.276 3.217
2015-02-02 3.159 3.144
2015-02-03 3.181 3.219
2015-02-04 3.234 3.182
2015-02-05 3.268 3.144
2015-02-06 3.144 3.097
2015-02-09 3.097 3.133
2015-02-10 3.137 3.196
2015-02-11 3.200 3.217
2015-02-12 3.217 3.230
2015-02-13 3.237 3.251
... ... ...
2018-12-19 3.126 3.091
2018-12-20 3.084 3.068
2018-12-21 3.060 3.030
2018-12-24 3.019 3.037
2018-12-25 3.009 3.018
2018-12-26 3.009 3.001
2018-12-27 3.039 2.994
2018-12-28 3.000 3.001
2019-01-02 3.012 2.960
2019-01-03 2.959 2.960
2019-01-04 2.944 3.036
2019-01-07 3.050 3.048
2019-01-08 3.048 3.048
2019-01-09 3.060 3.071
2019-01-10 3.070 3.074
2019-01-11 3.072 3.097
2019-01-14 3.096 3.070
2019-01-15 3.074 3.128
2019-01-16 3.131 3.129
2019-01-17 3.129 3.112
2019-01-18 3.121 3.166
2019-01-21 3.166 3.183
2019-01-22 3.177 3.143
2019-01-23 3.135 3.135
2019-01-24 3.139 3.159
2019-01-25 3.162 3.183
2019-01-28 3.197 3.179
2019-01-29 3.172 3.193
2019-01-30 3.178 3.172
2019-01-31 3.184 3.202

997 rows × 2 columns

#获取平台支持的所有股票, ETF基金信息
get_all_securities()
display_name name start_date end_date type
000001.XSHE 平安银行 PAYH 1991-04-03 2200-01-01 stock
000002.XSHE 万科A WKA 1991-01-29 2200-01-01 stock
000004.XSHE 国农科技 GNKJ 1990-12-01 2200-01-01 stock
000005.XSHE 世纪星源 SJXY 1990-12-10 2200-01-01 stock
000006.XSHE 深振业A SZYA 1992-04-27 2200-01-01 stock
000007.XSHE 全新好 QXH 1992-04-13 2200-01-01 stock
000008.XSHE 神州高铁 SZGT 1992-05-07 2200-01-01 stock
000009.XSHE 中国宝安 ZGBA 1991-06-25 2200-01-01 stock
000010.XSHE *ST美丽 *STML 1995-10-27 2200-01-01 stock
000011.XSHE 深物业A SWYA 1992-03-30 2200-01-01 stock
000012.XSHE 南玻A NBA 1992-02-28 2200-01-01 stock
000014.XSHE 沙河股份 SHGF 1992-06-02 2200-01-01 stock
000016.XSHE 深康佳A SKJA 1992-03-27 2200-01-01 stock
000017.XSHE 深中华A SZHA 1992-03-31 2200-01-01 stock
000018.XSHE *ST神城 *STSC 1992-06-16 2200-01-01 stock
000019.XSHE 深粮控股 SLKG 1992-10-12 2200-01-01 stock
000020.XSHE 深华发A SHFA 1992-04-28 2200-01-01 stock
000021.XSHE 深科技 SKJ 1994-02-02 2200-01-01 stock
000022.XSHE 深赤湾A SCWA 1993-05-05 2018-12-25 stock
000023.XSHE 深天地A STDA 1993-04-29 2200-01-01 stock
000024.XSHE 招商地产 ZSDC 1993-06-07 2015-12-29 stock
000025.XSHE 特力A TLA 1993-06-21 2200-01-01 stock
000026.XSHE 飞亚达A FYDA 1993-06-03 2200-01-01 stock
000027.XSHE 深圳能源 SZNY 1993-09-03 2200-01-01 stock
000028.XSHE 国药一致 GYYZ 1993-08-09 2200-01-01 stock
000029.XSHE 深深房A SSFA 1993-09-15 2200-01-01 stock
000030.XSHE 富奥股份 FAGF 1993-09-29 2200-01-01 stock
000031.XSHE 大悦城 DYC 1993-10-08 2200-01-01 stock
000032.XSHE 深桑达A SSDA 1993-10-28 2200-01-01 stock
000033.XSHE 新都退 STXD 1994-01-03 2017-07-06 stock
... ... ... ... ... ...
603998.XSHG 方盛制药 FSZY 2014-12-05 2200-01-01 stock
603999.XSHG 读者传媒 DZCM 2015-12-10 2200-01-01 stock
688001.XSHG 华兴源创 HXYC 2019-07-22 2200-01-01 stock
688002.XSHG 睿创微纳 RCWN 2019-07-22 2200-01-01 stock
688003.XSHG 天准科技 TZKJ 2019-07-22 2200-01-01 stock
688005.XSHG 容百科技 RBKJ 2019-07-22 2200-01-01 stock
688006.XSHG 杭可科技 HKKJ 2019-07-22 2200-01-01 stock
688007.XSHG 光峰科技 GFKJ 2019-07-22 2200-01-01 stock
688008.XSHG 澜起科技 LQKJ 2019-07-22 2200-01-01 stock
688009.XSHG 中国通号 ZGTH 2019-07-22 2200-01-01 stock
688010.XSHG 福光股份 FGGF 2019-07-22 2200-01-01 stock
688011.XSHG 新光光电 XGGD 2019-07-22 2200-01-01 stock
688012.XSHG 中微公司 ZWGS 2019-07-22 2200-01-01 stock
688015.XSHG 交控科技 JKKJ 2019-07-22 2200-01-01 stock
688016.XSHG 心脉医疗 XMYL 2019-07-22 2200-01-01 stock
688018.XSHG 乐鑫科技 LXKJ 2019-07-22 2200-01-01 stock
688019.XSHG 安集科技 AJKJ 2019-07-22 2200-01-01 stock
688020.XSHG 方邦股份 FBGF 2019-07-22 2200-01-01 stock
688022.XSHG 瀚川智能 HCZN 2019-07-22 2200-01-01 stock
688028.XSHG 沃尔德 WED 2019-07-22 2200-01-01 stock
688029.XSHG 南微医学 NWYX 2019-07-22 2200-01-01 stock
688033.XSHG 天宜上佳 TYSJ 2019-07-22 2200-01-01 stock
688066.XSHG 航天宏图 HTHT 2019-07-22 2200-01-01 stock
688088.XSHG 虹软科技 HRKJ 2019-07-22 2200-01-01 stock
688099.XSHG 晶晨股份 JCGF 2019-08-08 2200-01-01 stock
688122.XSHG 西部超导 XBCD 2019-07-22 2200-01-01 stock
688188.XSHG 柏楚电子 BCDZ 2019-08-08 2200-01-01 stock
688321.XSHG 微芯生物 WXSW 2019-08-12 2200-01-01 stock
688333.XSHG 铂力特 BLT 2019-07-22 2200-01-01 stock
688388.XSHG 嘉元科技 JYKJ 2019-07-22 2200-01-01 stock

3755 rows × 5 columns

#获取沪深300指数的所有股票
get_index_stocks('000300.XSHG')
[u'000001.XSHE',
 u'000002.XSHE',
 u'000008.XSHE',
 u'000009.XSHE',
 u'000027.XSHE',
 u'000039.XSHE',
 u'000060.XSHE',
 u'000061.XSHE',
 u'000063.XSHE',
 u'000069.XSHE',
 u'000100.XSHE',
 u'000156.XSHE',
 u'000157.XSHE',
 u'000166.XSHE',
 u'000333.XSHE',
 u'000338.XSHE',
 u'000402.XSHE',
 u'000413.XSHE',
 u'000415.XSHE',
 u'000423.XSHE',
 u'000425.XSHE',
 u'000503.XSHE',
 u'000538.XSHE',
 u'000540.XSHE',
 u'000555.XSHE',
 u'000559.XSHE',
 u'000568.XSHE',
 u'000623.XSHE',
 u'000625.XSHE',
 u'000627.XSHE',
 u'000630.XSHE',
 u'000651.XSHE',
 u'000671.XSHE',
 u'000686.XSHE',
 u'000709.XSHE',
 u'000712.XSHE',
 u'000718.XSHE',
 u'000725.XSHE',
 u'000728.XSHE',
 u'000738.XSHE',
 u'000750.XSHE',
 u'000768.XSHE',
 u'000776.XSHE',
 u'000778.XSHE',
 u'000783.XSHE',
 u'000792.XSHE',
 u'000793.XSHE',
 u'000800.XSHE',
 u'000826.XSHE',
 u'000839.XSHE',
 u'000858.XSHE',
 u'000876.XSHE',
 u'000895.XSHE',
 u'000917.XSHE',
 u'000938.XSHE',
 u'000963.XSHE',
 u'000977.XSHE',
 u'000983.XSHE',
 u'001979.XSHE',
 u'002007.XSHE',
 u'002008.XSHE',
 u'002024.XSHE',
 u'002027.XSHE',
 u'002049.XSHE',
 u'002065.XSHE',
 u'002074.XSHE',
 u'002081.XSHE',
 u'002085.XSHE',
 u'002129.XSHE',
 u'002131.XSHE',
 u'002142.XSHE',
 u'002146.XSHE',
 u'002152.XSHE',
 u'002153.XSHE',
 u'002174.XSHE',
 u'002183.XSHE',
 u'002195.XSHE',
 u'002202.XSHE',
 u'002230.XSHE',
 u'002236.XSHE',
 u'002241.XSHE',
 u'002252.XSHE',
 u'002292.XSHE',
 u'002299.XSHE',
 u'002304.XSHE',
 u'002310.XSHE',
 u'002385.XSHE',
 u'002415.XSHE',
 u'002424.XSHE',
 u'002426.XSHE',
 u'002450.XSHE',
 u'002456.XSHE',
 u'002465.XSHE',
 u'002466.XSHE',
 u'002470.XSHE',
 u'002475.XSHE',
 u'002500.XSHE',
 u'002568.XSHE',
 u'002594.XSHE',
 u'002673.XSHE',
 u'002714.XSHE',
 u'002736.XSHE',
 u'002739.XSHE',
 u'002797.XSHE',
 u'300002.XSHE',
 u'300015.XSHE',
 u'300017.XSHE',
 u'300024.XSHE',
 u'300027.XSHE',
 u'300033.XSHE',
 u'300058.XSHE',
 u'300059.XSHE',
 u'300070.XSHE',
 u'300072.XSHE',
 u'300085.XSHE',
 u'300104.XSHE',
 u'300124.XSHE',
 u'300133.XSHE',
 u'300144.XSHE',
 u'300146.XSHE',
 u'300168.XSHE',
 u'300182.XSHE',
 u'300251.XSHE',
 u'300315.XSHE',
 u'600000.XSHG',
 u'600008.XSHG',
 u'600009.XSHG',
 u'600010.XSHG',
 u'600015.XSHG',
 u'600016.XSHG',
 u'600018.XSHG',
 u'600019.XSHG',
 u'600021.XSHG',
 u'600023.XSHG',
 u'600028.XSHG',
 u'600029.XSHG',
 u'600030.XSHG',
 u'600031.XSHG',
 u'600036.XSHG',
 u'600037.XSHG',
 u'600038.XSHG',
 u'600048.XSHG',
 u'600050.XSHG',
 u'600060.XSHG',
 u'600061.XSHG',
 u'600066.XSHG',
 u'600068.XSHG',
 u'600074.XSHG',
 u'600085.XSHG',
 u'600089.XSHG',
 u'600100.XSHG',
 u'600104.XSHG',
 u'600109.XSHG',
 u'600111.XSHG',
 u'600115.XSHG',
 u'600118.XSHG',
 u'600150.XSHG',
 u'600153.XSHG',
 u'600157.XSHG',
 u'600170.XSHG',
 u'600177.XSHG',
 u'600188.XSHG',
 u'600196.XSHG',
 u'600208.XSHG',
 u'600221.XSHG',
 u'600252.XSHG',
 u'600256.XSHG',
 u'600271.XSHG',
 u'600276.XSHG',
 u'600297.XSHG',
 u'600309.XSHG',
 u'600332.XSHG',
 u'600340.XSHG',
 u'600352.XSHG',
 u'600362.XSHG',
 u'600369.XSHG',
 u'600372.XSHG',
 u'600373.XSHG',
 u'600376.XSHG',
 u'600383.XSHG',
 u'600406.XSHG',
 u'600415.XSHG',
 u'600446.XSHG',
 u'600482.XSHG',
 u'600485.XSHG',
 u'600489.XSHG',
 u'600498.XSHG',
 u'600518.XSHG',
 u'600519.XSHG',
 u'600535.XSHG',
 u'600547.XSHG',
 u'600549.XSHG',
 u'600570.XSHG',
 u'600582.XSHG',
 u'600583.XSHG',
 u'600585.XSHG',
 u'600588.XSHG',
 u'600606.XSHG',
 u'600637.XSHG',
 u'600648.XSHG',
 u'600649.XSHG',
 u'600654.XSHG',
 u'600660.XSHG',
 u'600663.XSHG',
 u'600666.XSHG',
 u'600674.XSHG',
 u'600685.XSHG',
 u'600688.XSHG',
 u'600690.XSHG',
 u'600703.XSHG',
 u'600704.XSHG',
 u'600705.XSHG',
 u'600718.XSHG',
 u'600737.XSHG',
 u'600739.XSHG',
 u'600741.XSHG',
 u'600754.XSHG',
 u'600783.XSHG',
 u'600795.XSHG',
 u'600804.XSHG',
 u'600816.XSHG',
 u'600820.XSHG',
 u'600827.XSHG',
 u'600837.XSHG',
 u'600839.XSHG',
 u'600867.XSHG',
 u'600871.XSHG',
 u'600873.XSHG',
 u'600875.XSHG',
 u'600886.XSHG',
 u'600887.XSHG',
 u'600893.XSHG',
 u'600895.XSHG',
 u'600900.XSHG',
 u'600958.XSHG',
 u'600959.XSHG',
 u'600999.XSHG',
 u'601006.XSHG',
 u'601009.XSHG',
 u'601018.XSHG',
 u'601021.XSHG',
 u'601088.XSHG',
 u'601099.XSHG',
 u'601111.XSHG',
 u'601118.XSHG',
 u'601127.XSHG',
 u'601155.XSHG',
 u'601166.XSHG',
 u'601169.XSHG',
 u'601186.XSHG',
 u'601198.XSHG',
 u'601211.XSHG',
 u'601216.XSHG',
 u'601225.XSHG',
 u'601258.XSHG',
 u'601288.XSHG',
 u'601318.XSHG',
 u'601328.XSHG',
 u'601333.XSHG',
 u'601336.XSHG',
 u'601377.XSHG',
 u'601390.XSHG',
 u'601398.XSHG',
 u'601555.XSHG',
 u'601600.XSHG',
 u'601601.XSHG',
 u'601607.XSHG',
 u'601608.XSHG',
 u'601611.XSHG',
 u'601618.XSHG',
 u'601628.XSHG',
 u'601633.XSHG',
 u'601668.XSHG',
 u'601669.XSHG',
 u'601688.XSHG',
 u'601718.XSHG',
 u'601727.XSHG',
 u'601766.XSHG',
 u'601788.XSHG',
 u'601800.XSHG',
 u'601818.XSHG',
 u'601857.XSHG',
 u'601866.XSHG',
 u'601872.XSHG',
 u'601877.XSHG',
 u'601888.XSHG',
 u'601899.XSHG',
 u'601901.XSHG',
 u'601919.XSHG',
 u'601928.XSHG',
 u'601933.XSHG',
 u'601939.XSHG',
 u'601958.XSHG',
 u'601985.XSHG',
 u'601988.XSHG',
 u'601989.XSHG',
 u'601998.XSHG',
 u'603000.XSHG',
 u'603885.XSHG',
 u'603993.XSHG']
#获取互联网和相关行业的所有股票
get_industry_stocks('I64')
[u'000503.XSHE',
 u'002095.XSHE',
 u'002113.XSHE',
 u'002131.XSHE',
 u'002174.XSHE',
 u'002175.XSHE',
 u'002315.XSHE',
 u'002354.XSHE',
 u'002439.XSHE',
 u'002464.XSHE',
 u'002467.XSHE',
 u'002517.XSHE',
 u'002555.XSHE',
 u'002558.XSHE',
 u'002624.XSHE',
 u'300031.XSHE',
 u'300052.XSHE',
 u'300059.XSHE',
 u'300104.XSHE',
 u'300113.XSHE',
 u'300226.XSHE',
 u'300295.XSHE',
 u'300315.XSHE',
 u'300343.XSHE',
 u'300392.XSHE',
 u'300418.XSHE',
 u'300431.XSHE',
 u'300467.XSHE',
 u'300494.XSHE',
 u'300571.XSHE',
 u'600634.XSHG',
 u'600652.XSHG',
 u'600804.XSHG',
 u'600986.XSHG',
 u'603000.XSHG',
 u'603258.XSHG',
 u'603444.XSHG',
 u'603881.XSHG',
 u'603888.XSHG']

pandas和seaborn库的使用说明见Tutorials and Documentation(使用帮助)文件夹¶

彩蛋¶

为了增加研究功能的体验,我们新增了如下两个彩蛋

回测和研究打通¶

为了打通回测和研究功能,我们新增了两个回测API,回测过程中需要保存的文件,您可以保存到研究模块,也可以直接调用研究模块的文件。

详见API

回测和研究打通

分享到社区¶

为了便于交流,研究模块支持分享,您可以把notebook分享到社区,与大家交流。

分享到社区

|

全部回复

0/140

达人推荐

量化课程

    移动端课程