{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "冒險41_41.5績效畫圖比較.ipynb", "provenance": [], "collapsed_sections": [], "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "" ] }, { "cell_type": "code", "metadata": { "id": "LWJn-Mhq9dd3" }, "source": [ "%matplotlib inline\n", "import numpy as np\n", "import pandas as pd \n", "import matplotlib.pyplot as plt " ], "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "O2liinnQRjRt" }, "source": [ "# 41.5績效畫圖比較" ] }, { "cell_type": "code", "source": [ "#stock_data\n", "df_1 = pd.read_csv('stock_data.csv')\n", "df_1" ], "metadata": { "id": "1cqVIRNpIBsR", "colab": { "base_uri": "https://localhost:8080/", "height": 423 }, "outputId": "cfed78d6-9d0f-4250-bde3-a14adb6cf6ca" }, "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " TIME OPEN MAX MIN CLOSE\n", "0 2010-01-04 65.0 65.0 64.0 64.9\n", "1 2010-01-05 65.0 65.1 63.9 64.5\n", "2 2010-01-06 64.5 64.9 63.7 64.9\n", "3 2010-01-07 64.9 65.0 64.2 64.2\n", "4 2010-01-08 63.5 64.3 63.5 64.0\n", "... ... ... ... ... ...\n", "2949 2021-12-24 606.0 609.0 604.0 604.0\n", "2950 2021-12-27 604.0 610.0 604.0 606.0\n", "2951 2021-12-28 610.0 615.0 610.0 615.0\n", "2952 2021-12-29 615.0 619.0 614.0 616.0\n", "2953 2021-12-30 619.0 620.0 615.0 615.0\n", "\n", "[2954 rows x 5 columns]" ], "text/html": [ "\n", "
\n", " | TIME | \n", "OPEN | \n", "MAX | \n", "MIN | \n", "CLOSE | \n", "
---|---|---|---|---|---|
0 | \n", "2010-01-04 | \n", "65.0 | \n", "65.0 | \n", "64.0 | \n", "64.9 | \n", "
1 | \n", "2010-01-05 | \n", "65.0 | \n", "65.1 | \n", "63.9 | \n", "64.5 | \n", "
2 | \n", "2010-01-06 | \n", "64.5 | \n", "64.9 | \n", "63.7 | \n", "64.9 | \n", "
3 | \n", "2010-01-07 | \n", "64.9 | \n", "65.0 | \n", "64.2 | \n", "64.2 | \n", "
4 | \n", "2010-01-08 | \n", "63.5 | \n", "64.3 | \n", "63.5 | \n", "64.0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2949 | \n", "2021-12-24 | \n", "606.0 | \n", "609.0 | \n", "604.0 | \n", "604.0 | \n", "
2950 | \n", "2021-12-27 | \n", "604.0 | \n", "610.0 | \n", "604.0 | \n", "606.0 | \n", "
2951 | \n", "2021-12-28 | \n", "610.0 | \n", "615.0 | \n", "610.0 | \n", "615.0 | \n", "
2952 | \n", "2021-12-29 | \n", "615.0 | \n", "619.0 | \n", "614.0 | \n", "616.0 | \n", "
2953 | \n", "2021-12-30 | \n", "619.0 | \n", "620.0 | \n", "615.0 | \n", "615.0 | \n", "
2954 rows × 5 columns
\n", "\n", " | TIME | \n", "OPEN | \n", "MAX | \n", "MIN | \n", "CLOSE | \n", "
---|---|---|---|---|---|
0 | \n", "2021-02-01 | \n", "595.0 | \n", "612.0 | \n", "587.0 | \n", "611.0 | \n", "
1 | \n", "2021-02-02 | \n", "629.0 | \n", "638.0 | \n", "622.0 | \n", "632.0 | \n", "
2 | \n", "2021-02-03 | \n", "638.0 | \n", "642.0 | \n", "630.0 | \n", "630.0 | \n", "
3 | \n", "2021-02-04 | \n", "626.0 | \n", "632.0 | \n", "620.0 | \n", "627.0 | \n", "
4 | \n", "2021-02-05 | \n", "638.0 | \n", "641.0 | \n", "631.0 | \n", "632.0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
219 | \n", "2021-12-24 | \n", "606.0 | \n", "609.0 | \n", "604.0 | \n", "604.0 | \n", "
220 | \n", "2021-12-27 | \n", "604.0 | \n", "610.0 | \n", "604.0 | \n", "606.0 | \n", "
221 | \n", "2021-12-28 | \n", "610.0 | \n", "615.0 | \n", "610.0 | \n", "615.0 | \n", "
222 | \n", "2021-12-29 | \n", "615.0 | \n", "619.0 | \n", "614.0 | \n", "616.0 | \n", "
223 | \n", "2021-12-30 | \n", "619.0 | \n", "620.0 | \n", "615.0 | \n", "615.0 | \n", "
224 rows × 5 columns
\n", "\n", " | TIME | \n", "OPEN | \n", "MAX | \n", "MIN | \n", "CLOSE | \n", "日報酬 | \n", "1+日報酬 | \n", "相乘 | \n", "
---|---|---|---|---|---|---|---|---|
TIME | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
2021-02-01 | \n", "2021-02-01 | \n", "595.0 | \n", "612.0 | \n", "587.0 | \n", "611.0 | \n", "\n", " | \n", " | \n", " |
2021-02-02 | \n", "2021-02-02 | \n", "629.0 | \n", "638.0 | \n", "622.0 | \n", "632.0 | \n", "0.03437 | \n", "1.03437 | \n", "1.03437 | \n", "
2021-02-03 | \n", "2021-02-03 | \n", "638.0 | \n", "642.0 | \n", "630.0 | \n", "630.0 | \n", "-0.003165 | \n", "0.996835 | \n", "1.031097 | \n", "
2021-02-04 | \n", "2021-02-04 | \n", "626.0 | \n", "632.0 | \n", "620.0 | \n", "627.0 | \n", "-0.004762 | \n", "0.995238 | \n", "1.026187 | \n", "
2021-02-05 | \n", "2021-02-05 | \n", "638.0 | \n", "641.0 | \n", "631.0 | \n", "632.0 | \n", "0.007974 | \n", "1.007974 | \n", "1.03437 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2021-12-24 | \n", "2021-12-24 | \n", "606.0 | \n", "609.0 | \n", "604.0 | \n", "604.0 | \n", "-0.0033 | \n", "0.9967 | \n", "0.988543 | \n", "
2021-12-27 | \n", "2021-12-27 | \n", "604.0 | \n", "610.0 | \n", "604.0 | \n", "606.0 | \n", "0.003311 | \n", "1.003311 | \n", "0.991817 | \n", "
2021-12-28 | \n", "2021-12-28 | \n", "610.0 | \n", "615.0 | \n", "610.0 | \n", "615.0 | \n", "0.014851 | \n", "1.014851 | \n", "1.006547 | \n", "
2021-12-29 | \n", "2021-12-29 | \n", "615.0 | \n", "619.0 | \n", "614.0 | \n", "616.0 | \n", "0.001626 | \n", "1.001626 | \n", "1.008183 | \n", "
2021-12-30 | \n", "2021-12-30 | \n", "619.0 | \n", "620.0 | \n", "615.0 | \n", "615.0 | \n", "-0.001623 | \n", "0.998377 | \n", "1.006547 | \n", "
224 rows × 8 columns
\n", "\n", " | Unnamed: 0 | \n", "state | \n", "action | \n", "reward | \n", "q | \n", "
---|---|---|---|---|---|
0 | \n", "2710 | \n", "OPEN MAX MIN CLOSE\\nTIME ... | \n", "0 | \n", "0.000000 | \n", "0.000000 | \n", "
1 | \n", "2711 | \n", "OPEN MAX MIN CLOSE\\nTIME ... | \n", "0 | \n", "0.000000 | \n", "0.000000 | \n", "
2 | \n", "2712 | \n", "OPEN MAX MIN CLOSE\\nTIME ... | \n", "0 | \n", "0.000000 | \n", "0.000000 | \n", "
3 | \n", "2713 | \n", "OPEN MAX MIN CLOSE\\nTIME ... | \n", "0 | \n", "0.000000 | \n", "0.000000 | \n", "
4 | \n", "2714 | \n", "OPEN MAX MIN CLOSE\\nTIME ... | \n", "0 | \n", "0.000000 | \n", "0.000000 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
219 | \n", "2929 | \n", "OPEN MAX MIN CLOSE\\nTIME ... | \n", "0 | \n", "-0.003300 | \n", "-0.003300 | \n", "
220 | \n", "2930 | \n", "OPEN MAX MIN CLOSE\\nTIME ... | \n", "0 | \n", "0.003311 | \n", "0.003311 | \n", "
221 | \n", "2931 | \n", "OPEN MAX MIN CLOSE\\nTIME ... | \n", "0 | \n", "0.014851 | \n", "0.014851 | \n", "
222 | \n", "2932 | \n", "OPEN MAX MIN CLOSE\\nTIME ... | \n", "0 | \n", "0.001626 | \n", "0.001626 | \n", "
223 | \n", "2933 | \n", "OPEN MAX MIN CLOSE\\nTIME ... | \n", "0 | \n", "NaN | \n", "NaN | \n", "
224 rows × 5 columns
\n", "\n", " | TIME | \n", "OPEN | \n", "MAX | \n", "MIN | \n", "CLOSE | \n", "日報酬 | \n", "1+日報酬 | \n", "相乘 | \n", "
---|---|---|---|---|---|---|---|---|
TIME | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
2021-02-01 | \n", "2021-02-01 | \n", "595.0 | \n", "612.0 | \n", "587.0 | \n", "611.0 | \n", "\n", " | \n", " | \n", " |
2021-02-02 | \n", "2021-02-02 | \n", "629.0 | \n", "638.0 | \n", "622.0 | \n", "632.0 | \n", "0.03437 | \n", "1.03437 | \n", "1.03437 | \n", "
2021-02-03 | \n", "2021-02-03 | \n", "638.0 | \n", "642.0 | \n", "630.0 | \n", "630.0 | \n", "-0.003165 | \n", "0.996835 | \n", "1.031097 | \n", "
2021-02-04 | \n", "2021-02-04 | \n", "626.0 | \n", "632.0 | \n", "620.0 | \n", "627.0 | \n", "-0.004762 | \n", "0.995238 | \n", "1.026187 | \n", "
2021-02-05 | \n", "2021-02-05 | \n", "638.0 | \n", "641.0 | \n", "631.0 | \n", "632.0 | \n", "0.007974 | \n", "1.007974 | \n", "1.03437 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2021-12-24 | \n", "2021-12-24 | \n", "606.0 | \n", "609.0 | \n", "604.0 | \n", "604.0 | \n", "-0.0033 | \n", "0.9967 | \n", "0.988543 | \n", "
2021-12-27 | \n", "2021-12-27 | \n", "604.0 | \n", "610.0 | \n", "604.0 | \n", "606.0 | \n", "0.003311 | \n", "1.003311 | \n", "0.991817 | \n", "
2021-12-28 | \n", "2021-12-28 | \n", "610.0 | \n", "615.0 | \n", "610.0 | \n", "615.0 | \n", "0.014851 | \n", "1.014851 | \n", "1.006547 | \n", "
2021-12-29 | \n", "2021-12-29 | \n", "615.0 | \n", "619.0 | \n", "614.0 | \n", "616.0 | \n", "0.001626 | \n", "1.001626 | \n", "1.008183 | \n", "
2021-12-30 | \n", "2021-12-30 | \n", "619.0 | \n", "620.0 | \n", "615.0 | \n", "615.0 | \n", "-0.001623 | \n", "0.998377 | \n", "1.006547 | \n", "
224 rows × 8 columns
\n", "\n", " | TIME | \n", "OPEN | \n", "MAX | \n", "MIN | \n", "CLOSE | \n", "日報酬 | \n", "1+日報酬 | \n", "相乘 | \n", "rl_reward | \n", "
---|---|---|---|---|---|---|---|---|---|
TIME | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
2021-02-01 | \n", "2021-02-01 | \n", "595.0 | \n", "612.0 | \n", "587.0 | \n", "611.0 | \n", "\n", " | \n", " | \n", " | 0.0 | \n", "
2021-02-02 | \n", "2021-02-02 | \n", "629.0 | \n", "638.0 | \n", "622.0 | \n", "632.0 | \n", "0.03437 | \n", "1.03437 | \n", "1.03437 | \n", "0.0 | \n", "
2021-02-03 | \n", "2021-02-03 | \n", "638.0 | \n", "642.0 | \n", "630.0 | \n", "630.0 | \n", "-0.003165 | \n", "0.996835 | \n", "1.031097 | \n", "0.0 | \n", "
2021-02-04 | \n", "2021-02-04 | \n", "626.0 | \n", "632.0 | \n", "620.0 | \n", "627.0 | \n", "-0.004762 | \n", "0.995238 | \n", "1.026187 | \n", "0.0 | \n", "
2021-02-05 | \n", "2021-02-05 | \n", "638.0 | \n", "641.0 | \n", "631.0 | \n", "632.0 | \n", "0.007974 | \n", "1.007974 | \n", "1.03437 | \n", "0.0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2021-12-24 | \n", "2021-12-24 | \n", "606.0 | \n", "609.0 | \n", "604.0 | \n", "604.0 | \n", "-0.0033 | \n", "0.9967 | \n", "0.988543 | \n", "-0.0033 | \n", "
2021-12-27 | \n", "2021-12-27 | \n", "604.0 | \n", "610.0 | \n", "604.0 | \n", "606.0 | \n", "0.003311 | \n", "1.003311 | \n", "0.991817 | \n", "0.003311 | \n", "
2021-12-28 | \n", "2021-12-28 | \n", "610.0 | \n", "615.0 | \n", "610.0 | \n", "615.0 | \n", "0.014851 | \n", "1.014851 | \n", "1.006547 | \n", "0.014851 | \n", "
2021-12-29 | \n", "2021-12-29 | \n", "615.0 | \n", "619.0 | \n", "614.0 | \n", "616.0 | \n", "0.001626 | \n", "1.001626 | \n", "1.008183 | \n", "0.001626 | \n", "
2021-12-30 | \n", "2021-12-30 | \n", "619.0 | \n", "620.0 | \n", "615.0 | \n", "615.0 | \n", "-0.001623 | \n", "0.998377 | \n", "1.006547 | \n", "NaN | \n", "
224 rows × 9 columns
\n", "\n", " | TIME | \n", "OPEN | \n", "MAX | \n", "MIN | \n", "CLOSE | \n", "日報酬 | \n", "1+日報酬 | \n", "相乘 | \n", "rl_reward | \n", "1+rl日報酬 | \n", "rl相乘 | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|
TIME | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
2021-02-01 | \n", "2021-02-01 | \n", "595.0 | \n", "612.0 | \n", "587.0 | \n", "611.0 | \n", "\n", " | \n", " | \n", " | 0.0 | \n", "1.0 | \n", "1.0 | \n", "
2021-02-02 | \n", "2021-02-02 | \n", "629.0 | \n", "638.0 | \n", "622.0 | \n", "632.0 | \n", "0.03437 | \n", "1.03437 | \n", "1.03437 | \n", "0.0 | \n", "1.0 | \n", "1.0 | \n", "
2021-02-03 | \n", "2021-02-03 | \n", "638.0 | \n", "642.0 | \n", "630.0 | \n", "630.0 | \n", "-0.003165 | \n", "0.996835 | \n", "1.031097 | \n", "0.0 | \n", "1.0 | \n", "1.0 | \n", "
2021-02-04 | \n", "2021-02-04 | \n", "626.0 | \n", "632.0 | \n", "620.0 | \n", "627.0 | \n", "-0.004762 | \n", "0.995238 | \n", "1.026187 | \n", "0.0 | \n", "1.0 | \n", "1.0 | \n", "
2021-02-05 | \n", "2021-02-05 | \n", "638.0 | \n", "641.0 | \n", "631.0 | \n", "632.0 | \n", "0.007974 | \n", "1.007974 | \n", "1.03437 | \n", "0.0 | \n", "1.0 | \n", "1.0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2021-12-24 | \n", "2021-12-24 | \n", "606.0 | \n", "609.0 | \n", "604.0 | \n", "604.0 | \n", "-0.0033 | \n", "0.9967 | \n", "0.988543 | \n", "-0.0033 | \n", "0.9967 | \n", "1.015126 | \n", "
2021-12-27 | \n", "2021-12-27 | \n", "604.0 | \n", "610.0 | \n", "604.0 | \n", "606.0 | \n", "0.003311 | \n", "1.003311 | \n", "0.991817 | \n", "0.003311 | \n", "1.003311 | \n", "1.018487 | \n", "
2021-12-28 | \n", "2021-12-28 | \n", "610.0 | \n", "615.0 | \n", "610.0 | \n", "615.0 | \n", "0.014851 | \n", "1.014851 | \n", "1.006547 | \n", "0.014851 | \n", "1.014851 | \n", "1.033613 | \n", "
2021-12-29 | \n", "2021-12-29 | \n", "615.0 | \n", "619.0 | \n", "614.0 | \n", "616.0 | \n", "0.001626 | \n", "1.001626 | \n", "1.008183 | \n", "0.001626 | \n", "1.001626 | \n", "1.035294 | \n", "
2021-12-30 | \n", "2021-12-30 | \n", "619.0 | \n", "620.0 | \n", "615.0 | \n", "615.0 | \n", "-0.001623 | \n", "0.998377 | \n", "1.006547 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
224 rows × 11 columns
\n", "