{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import adata\n", "\n", "res_df = adata.stock.info.all_code()\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import sqlite3\n", "\n", "conn = sqlite3.connect('big-a.db')\n", "\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5661" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "res_df.to_sql('all_code', con=conn, if_exists='replace', index=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "no_exit = res_df['short_name'].map(lambda x: not x.endswith('退'))\n", "have_date = res_df['list_date'].map(lambda x: not (not x))\n", "no_st = res_df['short_name'].map(lambda x: 'ST' not in x)\n", "no_pt = res_df['short_name'].map(lambda x: 'PT' not in x)\n", "\n", "filtered = res_df[no_exit & no_st & no_pt & res_df['list_date'].notnull()]\n" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5255" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered.to_sql('all_code', con=conn, if_exists='replace', index=False)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "import pandas\n", "\n", "local = pandas.read_sql_table('all_code', con='sqlite:///big-a.db', parse_dates=['list_date'])" ] } ], "metadata": { "kernelspec": { "display_name": "big-a", "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.13.0" } }, "nbformat": 4, "nbformat_minor": 2 }