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

量化交易吧 /  量化平台 帖子:3364736 新帖:0

hs123策略

爱德华发表于:5 月 10 日 07:37回复(1)

大家好,我想写一个策略,以每天早上开盘前30分钟的最低点作为买的,以最高点作为买的,这个策略怎么写?有没有会的帮我写一个,谢谢

研究功能简介¶

感谢您使用研究功能~~

研究功能基于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_

研究相关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='2014-01-01', end_date='2015-01-31', frequency='daily', fields=['open','close']) 
df
open close
2014-01-02 2.2199 2.2190
2014-01-03 2.2096 2.1946
2014-01-06 2.1880 2.1421
2014-01-07 2.1271 2.1431
2014-01-08 2.1431 2.1412
2014-01-09 2.1365 2.1281
2014-01-10 2.1262 2.1131
2014-01-13 2.1131 2.0981
2014-01-14 2.0981 2.1121
2014-01-15 2.1112 2.1121
2014-01-16 2.1084 2.1131
2014-01-17 2.1065 2.0831
2014-01-20 2.0821 2.0728
2014-01-21 2.0785 2.0900
2014-01-22 2.0929 2.1475
2014-01-23 2.1446 2.1360
2014-01-24 2.1284 2.1475
2014-01-27 2.1322 2.1197
2014-01-28 2.1264 2.1217
2014-01-29 2.1274 2.1284
2014-01-30 2.1245 2.0987
2014-02-07 2.0814 2.1121
2014-02-10 2.1217 2.1734
2014-02-11 2.1695 2.1839
2014-02-12 2.1849 2.1877
2014-02-13 2.1830 2.1820
2014-02-14 2.1839 2.1897
2014-02-17 2.2107 2.2050
2014-02-18 2.2059 2.1791
2014-02-19 2.1772 2.2079
... ... ...
2014-12-18 3.2471 3.2414
2014-12-19 3.2443 3.2893
2014-12-22 3.2893 3.2663
2014-12-23 3.2423 3.2002
2014-12-24 3.2002 3.1111
2014-12-25 3.1303 3.2241
2014-12-26 3.2261 3.3496
2014-12-29 3.4195 3.3333
2014-12-30 3.3362 3.3333
2014-12-31 3.3410 3.4234
2015-01-05 3.4521 3.5326
2015-01-06 3.5105 3.5086
2015-01-07 3.4914 3.5077
2015-01-08 3.5172 3.4310
2015-01-09 3.4215 3.4061
2015-01-12 3.4071 3.3956
2015-01-13 3.3927 3.3889
2015-01-14 3.3956 3.3812
2015-01-15 3.3812 3.4770
2015-01-16 3.4895 3.5077
2015-01-19 3.3228 3.1571
2015-01-20 3.2045 3.2742
2015-01-21 3.2858 3.4242
2015-01-22 3.4300 3.4300
2015-01-23 3.4542 3.4465
2015-01-26 3.4659 3.4794
2015-01-27 3.4871 3.4446
2015-01-28 3.4184 3.3894
2015-01-29 3.3448 3.3535
2015-01-30 3.3729 3.3119

265 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 美丽生态 SHX 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 神州长城 SZCC 1992-06-16 2200-01-01 stock
000019.XSHE 深深宝A SSBA 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 2200-01-01 stock
000023.XSHE 深天地A STDA 1993-04-29 2200-01-01 stock
000024.XSHE 招商地产 ZSDC 1993-06-07 2015-12-30 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 中粮地产 ZLDC 1993-10-08 2200-01-01 stock
000032.XSHE 深桑达A SSDA 1993-10-28 2200-01-01 stock
000033.XSHE *ST新都 STXD 1994-01-03 2200-01-01 stock
... ... ... ... ... ...
603906.XSHG 龙蟠科技 LPKJ 2017-04-10 2200-01-01 stock
603908.XSHG 牧高笛 mgd 2017-03-07 2200-01-01 stock
603909.XSHG 合诚股份 HCGF 2016-06-28 2200-01-01 stock
603918.XSHG 金桥信息 JQXX 2015-05-28 2200-01-01 stock
603919.XSHG 金徽酒 JHJ 2016-03-10 2200-01-01 stock
603920.XSHG 世运电路 SYDL 2017-04-26 2200-01-01 stock
603928.XSHG 兴业股份 XYGF 2016-12-12 2200-01-01 stock
603929.XSHG 亚翔集成 YXJC 2016-12-30 2200-01-01 stock
603936.XSHG 博敏电子 BMDZ 2015-12-09 2200-01-01 stock
603939.XSHG 益丰药房 YFYF 2015-02-17 2200-01-01 stock
603955.XSHG 大千生态 dqst 2017-03-10 2200-01-01 stock
603958.XSHG 哈森股份 HSGF 2016-06-29 2200-01-01 stock
603959.XSHG 百利科技 BLKJ 2016-05-17 2200-01-01 stock
603960.XSHG 克来机电 kljd 2017-03-14 2200-01-01 stock
603966.XSHG 法兰泰克 FLTK 2017-01-25 2200-01-01 stock
603968.XSHG 醋化股份 CHGF 2015-05-18 2200-01-01 stock
603969.XSHG 银龙股份 YLGF 2015-02-27 2200-01-01 stock
603977.XSHG 国泰集团 GTJT 2016-11-11 2200-01-01 stock
603979.XSHG 金诚信 JCX 2015-06-30 2200-01-01 stock
603986.XSHG 兆易创新 ZYCX 2016-08-18 2200-01-01 stock
603987.XSHG 康德莱 KDL 2016-11-21 2200-01-01 stock
603988.XSHG 中电电机 ZDDJ 2014-11-04 2200-01-01 stock
603989.XSHG 艾华集团 AHJT 2015-05-15 2200-01-01 stock
603990.XSHG 麦迪科技 MDKJ 2016-12-08 2200-01-01 stock
603991.XSHG 至正股份 zzgf 2017-03-08 2200-01-01 stock
603993.XSHG 洛阳钼业 LYMY 2012-10-09 2200-01-01 stock
603996.XSHG 中新科技 ZXKJ 2015-12-22 2200-01-01 stock
603997.XSHG 继峰股份 JFGF 2015-03-02 2200-01-01 stock
603998.XSHG 方盛制药 FSZY 2014-12-05 2200-01-01 stock
603999.XSHG 读者传媒 DZCM 2015-12-10 2200-01-01 stock

3272 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

达人推荐

量化课程

    移动端课程