1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-01 18:11:18 +08:00
Files
qlib/examples/data/monitor_analyser_demo.ipynb
2021-06-06 07:51:52 +00:00

131 lines
2.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0e62a81e",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"from tqdm.auto import tqdm\n",
"%matplotlib inline\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c503217b",
"metadata": {},
"outputs": [],
"source": [
"from qlib.data.monitor.analyser import Analyser\n",
"import qlib\n",
"qlib.init()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9c276470",
"metadata": {},
"outputs": [],
"source": [
"class SimpleDFA(Analyser):\n",
" \"\"\"Simple (D)ata(F)rame (A)nalyser\"\"\"\n",
" def analyse(self, data: pd.DataFrame, *args, **kwargs):\n",
" data.plot(*args, **kwargs)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "110262e4",
"metadata": {},
"outputs": [],
"source": [
"from monitor import get_data_df, AutoCM"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0ea38c62",
"metadata": {},
"outputs": [],
"source": [
"# get data\n",
"factor_df = get_data_df([1], verbose=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dbded6fe",
"metadata": {},
"outputs": [],
"source": [
"# metric extractor\n",
"acm = AutoCM()\n",
"mtrc = acm.extract(factor_df)\n",
"print(mtrc)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "65517c81",
"metadata": {},
"outputs": [],
"source": [
"# Analyser\n",
"sa = SimpleDFA()\n",
"sa.analyse(mtrc, title='Auto Correlation')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dab6fb2e",
"metadata": {},
"outputs": [],
"source": []
}
],
"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"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 5
}