73 lines
1.9 KiB
Plaintext
73 lines
1.9 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"metadata": {},
|
|
"cell_type": "code",
|
|
"outputs": [],
|
|
"execution_count": null,
|
|
"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": "1e8d815ee9b8c936"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "initial_id",
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"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"
|
|
]
|
|
}
|
|
],
|
|
"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
|
|
}
|