{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 缠论数据递归图表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-11-11T15:54:37.465346Z",
     "iopub.status.busy": "2022-11-11T15:54:37.464840Z",
     "iopub.status.idle": "2022-11-11T15:54:38.823233Z",
     "shell.execute_reply": "2022-11-11T15:54:38.822754Z",
     "shell.execute_reply.started": "2022-11-11T15:54:37.465289Z"
    },
    "tags": [],
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "在使用天勤量化之前，默认您已经知晓并同意以下免责条款，如果不同意请立即停止使用：https://www.shinnytech.com/blog/disclaimer/\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "欢迎使用缠论数据计算工具；\n",
      "项目地址：https://github.com/yijixiuxin/chanlun-pro\n",
      "授权许可有效期：2099-01-01\n"
     ]
    }
   ],
   "source": [
    "import time, datetime\n",
    "from chanlun.exchange.exchange_db import ExchangeDB\n",
    "from chanlun import kcharts\n",
    "from chanlun.cl_utils import *\n",
    "from chanlun.exchange.exchange import *\n",
    "from chanlun.file_db import FileCacheDB"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [],
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "market = 'currency'\n",
    "code = 'ETH/USDT'\n",
    "frequency = '1m'\n",
    "to_frequency = 'currency:30m'  # currency 指代市场，用于周期转换，30m 指代需要转换到的周期\n",
    "cl_config = query_cl_chart_config(market, code) # 根据 web 端的设置进行计算并展示\n",
    "\n",
    "print(cl_config)\n",
    "ex = ExchangeDB(market)\n",
    "fdb = FileCacheDB()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-11-11T15:54:38.829114Z",
     "iopub.status.busy": "2022-11-11T15:54:38.828971Z",
     "iopub.status.idle": "2022-11-11T15:55:00.293115Z",
     "shell.execute_reply": "2022-11-11T15:55:00.292518Z",
     "shell.execute_reply.started": "2022-11-11T15:54:38.829101Z"
    },
    "tags": [],
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "cd = fdb.get_low_to_high_cl_data(ex, market, code, frequency, cl_config)\n",
    "title = '%s - 【%s】 周期数据图表' % (code, to_frequency)\n",
    "render = kcharts.render_charts(title, cd, to_frequency=to_frequency, config=cl_config)\n",
    "render"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [],
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}