{ "cells": [ { "metadata": { "ExecuteTime": { "end_time": "2026-01-19T10:00:35.820002Z", "start_time": "2026-01-19T10:00:34.354216Z" } }, "cell_type": "code", "source": [ "import pandas as pd\n", "\n", "host = '81.71.3.24'\n", "port = 6785\n", "database = 'leopard_dev'\n", "username = 'leopard'\n", "password = '9NEzFzovnddf@PyEP?e*AYAWnCyd7UhYwQK$pJf>7?ccFiN^x4$eKEZ5~E<7<+~X'" ], "id": "d815a3591c4f9463", "outputs": [], "execution_count": 2 }, { "cell_type": "code", "id": "initial_id", "metadata": { "collapsed": true, "ExecuteTime": { "end_time": "2026-01-19T10:00:42.739695Z", "start_time": "2026-01-19T10:00:35.820726Z" } }, "source": [ "import psycopg2\n", "\n", "dailies_df = pd.DataFrame()\n", "\n", "with psycopg2.connect(host=host, port=port, database=database, user=username, password=password) as connection:\n", " with connection.cursor() as cursor:\n", " # language=PostgreSQL\n", " cursor.execute(\n", " \"\"\"select trade_date, open, close, high, low, factor\n", "from leopard_daily daily\n", " left join leopard_stock stock on stock.id = daily.stock_id\n", "where stock.code = '000001.SZ'\n", " and daily.trade_date between '2025-01-01 00:00:00' and '2025-12-31 23:59:59'\n", "order by daily.trade_date\"\"\"\n", " )\n", " rows = cursor.fetchall()\n", "\n", " dailies_df = pd.DataFrame.from_records(rows, columns=['trade_date', 'open', 'close', 'high', 'low', 'factor'])\n", "\n", "dailies_df" ], "outputs": [ { "data": { "text/plain": [ " trade_date open close high low factor\n", "0 2025-01-02 11.73 11.43 11.77 11.39 127.7841\n", "1 2025-01-03 11.44 11.38 11.54 11.36 127.7841\n", "2 2025-01-06 11.38 11.44 11.48 11.22 127.7841\n", "3 2025-01-07 11.42 11.51 11.53 11.37 127.7841\n", "4 2025-01-08 11.50 11.50 11.63 11.40 127.7841\n", ".. ... ... ... ... ... ...\n", "183 2025-10-09 11.33 11.40 11.41 11.27 131.7878\n", "184 2025-10-10 11.37 11.43 11.49 11.36 131.7878\n", "185 2025-10-13 11.32 11.40 11.46 11.28 131.7878\n", "186 2025-10-14 11.39 11.57 11.60 11.36 131.7878\n", "187 2025-10-15 11.34 11.40 11.42 11.26 134.5794\n", "\n", "[188 rows x 6 columns]" ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
trade_dateopenclosehighlowfactor
02025-01-0211.7311.4311.7711.39127.7841
12025-01-0311.4411.3811.5411.36127.7841
22025-01-0611.3811.4411.4811.22127.7841
32025-01-0711.4211.5111.5311.37127.7841
42025-01-0811.5011.5011.6311.40127.7841
.....................
1832025-10-0911.3311.4011.4111.27131.7878
1842025-10-1011.3711.4311.4911.36131.7878
1852025-10-1311.3211.4011.4611.28131.7878
1862025-10-1411.3911.5711.6011.36131.7878
1872025-10-1511.3411.4011.4211.26134.5794
\n", "

188 rows × 6 columns

\n", "
" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 3 }, { "metadata": { "ExecuteTime": { "end_time": "2026-01-19T10:01:46.133661Z", "start_time": "2026-01-19T10:01:46.044719Z" } }, "cell_type": "code", "source": [ "dailies_df['factor'] = dailies_df['factor'].fillna(1.0)\n", "dailies_df['open'] = dailies_df['open'] * dailies_df['factor']\n", "dailies_df['close'] = dailies_df['close'] * dailies_df['factor']\n", "dailies_df['high'] = dailies_df['high'] * dailies_df['factor']\n", "dailies_df['low'] = dailies_df['low'] * dailies_df['factor']\n", "dailies_df" ], "id": "29226cf1c6fe9f94", "outputs": [ { "data": { "text/plain": [ " trade_date open close high low \\\n", "0 2025-01-02 191536.544976 186637.912112 192189.696025 185984.761064 \n", "1 2025-01-03 186801.199875 185821.473302 188434.077496 185494.897778 \n", "2 2025-01-06 185821.473302 186801.199875 187454.350923 183208.869108 \n", "3 2025-01-07 186474.624350 187944.214209 188270.789734 185658.185540 \n", "4 2025-01-08 187780.926447 187780.926447 189903.667355 186148.048826 \n", ".. ... ... ... ... ... \n", "183 2025-10-09 196779.714513 197995.476209 198169.156451 195737.633059 \n", "184 2025-10-10 197474.435482 198516.516936 199558.598389 197300.755240 \n", "185 2025-10-13 196606.034270 197995.476209 199037.557663 195911.313301 \n", "186 2025-10-14 197821.795966 200948.040328 201469.081055 197300.755240 \n", "187 2025-10-15 205385.713015 206472.409910 206834.642208 203936.783823 \n", "\n", " factor \n", "0 127.7841 \n", "1 127.7841 \n", "2 127.7841 \n", "3 127.7841 \n", "4 127.7841 \n", ".. ... \n", "183 131.7878 \n", "184 131.7878 \n", "185 131.7878 \n", "186 131.7878 \n", "187 134.5794 \n", "\n", "[188 rows x 6 columns]" ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
trade_dateopenclosehighlowfactor
02025-01-02191536.544976186637.912112192189.696025185984.761064127.7841
12025-01-03186801.199875185821.473302188434.077496185494.897778127.7841
22025-01-06185821.473302186801.199875187454.350923183208.869108127.7841
32025-01-07186474.624350187944.214209188270.789734185658.185540127.7841
42025-01-08187780.926447187780.926447189903.667355186148.048826127.7841
.....................
1832025-10-09196779.714513197995.476209198169.156451195737.633059131.7878
1842025-10-10197474.435482198516.516936199558.598389197300.755240131.7878
1852025-10-13196606.034270197995.476209199037.557663195911.313301131.7878
1862025-10-14197821.795966200948.040328201469.081055197300.755240131.7878
1872025-10-15205385.713015206472.409910206834.642208203936.783823134.5794
\n", "

188 rows × 6 columns

\n", "
" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 5 } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 5 }