20250314修改:增加dingdanliu_nb_mflow
This commit is contained in:
297
findpeaks.ipynb
Normal file
297
findpeaks.ipynb
Normal file
@@ -0,0 +1,297 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<!-- https://mp.weixin.qq.com/s/GM5V-y4W26klL8JwzvHOCw -->"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import akshare as ak\n",
|
||||
"import pandas as pd\n",
|
||||
"from findpeaks import findpeaks\n",
|
||||
"# import qstock as qs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# X=qs.get_data('上证指数',start='20040101',end='20240808').close\n",
|
||||
"# stock_zh_index_daily_df = ak.stock_zh_index_daily(symbol=\"sh000001\").iloc[-240:]\n",
|
||||
"futures_zh_minute_sina_df = ak.futures_zh_minute_sina(symbol=\"IM0\", period=\"5\")\n",
|
||||
"# index_zh_a_hist_df = ak.index_zh_a_hist(symbol=\"000001\", period=\"daily\", start_date=\"20220101\", end_date=\"22350311\")\n",
|
||||
"# stock_zh_index_daily_em_df = ak.stock_zh_index_daily_em(symbol=\"sz399812\")\n",
|
||||
"# stock_zh_index_daily_df = ak.stock_zh_index_daily(symbol=\"sz399552\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# index_zh_a_hist_df.tail(5)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# X = index_zh_a_hist_df['收盘']\n",
|
||||
"X = futures_zh_minute_sina_df.close"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"futures_zh_minute_sina_df.tail(5)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# 初始化\n",
|
||||
"fp = findpeaks(method='topology')\n",
|
||||
"#拟合\n",
|
||||
"results = fp.fit(X)\n",
|
||||
"#可视化\n",
|
||||
"fp.plot()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# from findpeaks import findpeaks\n",
|
||||
"#初始化设置\n",
|
||||
"fp = findpeaks(method='peakdetect', lookahead=200, interpolate=None)\n",
|
||||
"#拟合 peakdetect 方法\n",
|
||||
"results = fp.fit(X)\n",
|
||||
"#可视化\n",
|
||||
"fp.plot()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# 使用凯鲁斯方法初始化findpeaks\n",
|
||||
"# 默认设置是只返回至少有5%差异的峰值和谷值\n",
|
||||
"fp = findpeaks(method='caerus', params={'minperc':5, 'window':50})\n",
|
||||
"\n",
|
||||
"#拟合数据\n",
|
||||
"results = fp.fit(X)\n",
|
||||
"\n",
|
||||
"#可视化\n",
|
||||
"fp.plot()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import akshare as ak\n",
|
||||
"\n",
|
||||
"stock_df = ak.rv_from_stock_zh_a_hist_min_em(\n",
|
||||
" symbol=\"000001\",\n",
|
||||
" start_date=\"2021-10-20 09:30:00\",\n",
|
||||
" end_date=\"2025-3-11 15:00:00\",\n",
|
||||
" period=\"5\",\n",
|
||||
" adjust=\"\"\n",
|
||||
")\n",
|
||||
"volatility_yz_rv_df = ak.volatility_yz_rv(data=stock_df)\n",
|
||||
"print(volatility_yz_rv_df)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import akshare as ak\n",
|
||||
"\n",
|
||||
"option_lhb_em_df = ak.option_lhb_em(symbol=\"mo2503\", indicator=\"期权持仓情况-认沽持仓量\", trade_date=\"20250311\")\n",
|
||||
"print(option_lhb_em_df)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import akshare as ak\n",
|
||||
"\n",
|
||||
"option_minute_em_df = ak.option_minute_em(symbol=\"MO2503-C-6400\")\n",
|
||||
"print(option_minute_em_df)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import akshare as ak\n",
|
||||
"\n",
|
||||
"stock_zh_index_spot_em_df = ak.stock_zh_index_spot_em(symbol=\"上证系列指数\")\n",
|
||||
"stock_zh_index_spot_em_df"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import akshare as ak\n",
|
||||
"\n",
|
||||
"futures_zh_spot_df = ak.futures_zh_spot(symbol='AG2504', market=\"CF\", adjust='0')\n",
|
||||
"print(futures_zh_spot_df)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import time\n",
|
||||
"import akshare as ak\n",
|
||||
"\n",
|
||||
"dce_text = ak.match_main_contract(symbol=\"dce\")\n",
|
||||
"czce_text = ak.match_main_contract(symbol=\"czce\")\n",
|
||||
"shfe_text = ak.match_main_contract(symbol=\"shfe\")\n",
|
||||
"gfex_text = ak.match_main_contract(symbol=\"gfex\")\n",
|
||||
"\n",
|
||||
"while True:\n",
|
||||
" time.sleep(3)\n",
|
||||
" futures_zh_spot_df = ak.futures_zh_spot(\n",
|
||||
" symbol=\",\".join([dce_text, czce_text, shfe_text, gfex_text]),\n",
|
||||
" market=\"CF\",\n",
|
||||
" adjust='0')\n",
|
||||
" # print(futures_zh_spot_df)\n",
|
||||
" futures_zh_spot_df"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import time\n",
|
||||
"import akshare as ak\n",
|
||||
"\n",
|
||||
"cffex_text = ak.match_main_contract(symbol=\"cffex\")\n",
|
||||
"\n",
|
||||
"while True:\n",
|
||||
" time.sleep(3)\n",
|
||||
" futures_zh_spot_df = ak.futures_zh_spot(symbol=cffex_text, market=\"FF\", adjust='0')\n",
|
||||
" print(futures_zh_spot_df)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import akshare as ak\n",
|
||||
"df = ak.futures_symbol_mark() "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import akshare as ak\n",
|
||||
"\n",
|
||||
"futures_zh_realtime_df = ak.futures_zh_realtime(symbol=\"白银\")\n",
|
||||
"print(futures_zh_realtime_df)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import akshare as ak\n",
|
||||
"\n",
|
||||
"futures_nh_volatility_index_df = ak.futures_nh_volatility_index(symbol=\"IC\", period='5')\n",
|
||||
"print(futures_nh_volatility_index_df)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import akshare as ak\n",
|
||||
"shfe_trading_hours = ak.shfe_trading_hours()\n",
|
||||
"print(shfe_trading_hours)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import akshare as ak\n",
|
||||
"\n",
|
||||
"futures_fees_info_df = ak.futures_fees_info()\n",
|
||||
"print(futures_fees_info_df)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.9"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
Reference in New Issue
Block a user