From bdacbcde9d61494fcc1a660217e0fa1033551184 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Mon, 20 Jan 2025 17:16:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=87=91=E5=AD=97=E5=A1=94?= =?UTF-8?q?=E9=80=89=E8=82=A1=E7=AD=96=E7=95=A5=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 181 ++++----- 财报筛选/loader.py | 4 +- 财报筛选/金字塔选股.ipynb | 747 ++++++++++++-------------------------- 3 files changed, 316 insertions(+), 616 deletions(-) diff --git a/poetry.lock b/poetry.lock index 0392c3f..a4b295b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -15,14 +15,14 @@ files = [ [[package]] name = "akshare" -version = "1.15.73" +version = "1.15.78" description = "AKShare is an elegant and simple financial data interface library for Python, built for human beings!" optional = false python-versions = ">=3.8" groups = ["main"] files = [ - {file = "akshare-1.15.73-py3-none-any.whl", hash = "sha256:cef9a126ffbb6105a3ce946838d2c6bbf4e23a74a9a5b85dd2b8de6848516aed"}, - {file = "akshare-1.15.73.tar.gz", hash = "sha256:43a5593e3f99693f4c270df291941ad8fb9b69f69cfb688608f0277f56bf2ce5"}, + {file = "akshare-1.15.78-py3-none-any.whl", hash = "sha256:4903a7b526dae908c0bcd7876408b233c2df27a02d3d4c62745cee48208ea5b9"}, + {file = "akshare-1.15.78.tar.gz", hash = "sha256:1060d125591a49cf2897989e98aa40768b8501564bbacd9a8cd375524e382907"}, ] [package.dependencies] @@ -619,38 +619,38 @@ tests = ["pytest", "pytest-cov", "pytest-xdist"] [[package]] name = "debugpy" -version = "1.8.11" +version = "1.8.12" description = "An implementation of the Debug Adapter Protocol for Python" optional = false python-versions = ">=3.8" groups = ["main"] files = [ - {file = "debugpy-1.8.11-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:2b26fefc4e31ff85593d68b9022e35e8925714a10ab4858fb1b577a8a48cb8cd"}, - {file = "debugpy-1.8.11-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61bc8b3b265e6949855300e84dc93d02d7a3a637f2aec6d382afd4ceb9120c9f"}, - {file = "debugpy-1.8.11-cp310-cp310-win32.whl", hash = "sha256:c928bbf47f65288574b78518449edaa46c82572d340e2750889bbf8cd92f3737"}, - {file = "debugpy-1.8.11-cp310-cp310-win_amd64.whl", hash = "sha256:8da1db4ca4f22583e834dcabdc7832e56fe16275253ee53ba66627b86e304da1"}, - {file = "debugpy-1.8.11-cp311-cp311-macosx_14_0_universal2.whl", hash = "sha256:85de8474ad53ad546ff1c7c7c89230db215b9b8a02754d41cb5a76f70d0be296"}, - {file = "debugpy-1.8.11-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8ffc382e4afa4aee367bf413f55ed17bd91b191dcaf979890af239dda435f2a1"}, - {file = "debugpy-1.8.11-cp311-cp311-win32.whl", hash = "sha256:40499a9979c55f72f4eb2fc38695419546b62594f8af194b879d2a18439c97a9"}, - {file = "debugpy-1.8.11-cp311-cp311-win_amd64.whl", hash = "sha256:987bce16e86efa86f747d5151c54e91b3c1e36acc03ce1ddb50f9d09d16ded0e"}, - {file = "debugpy-1.8.11-cp312-cp312-macosx_14_0_universal2.whl", hash = "sha256:84e511a7545d11683d32cdb8f809ef63fc17ea2a00455cc62d0a4dbb4ed1c308"}, - {file = "debugpy-1.8.11-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ce291a5aca4985d82875d6779f61375e959208cdf09fcec40001e65fb0a54768"}, - {file = "debugpy-1.8.11-cp312-cp312-win32.whl", hash = "sha256:28e45b3f827d3bf2592f3cf7ae63282e859f3259db44ed2b129093ca0ac7940b"}, - {file = "debugpy-1.8.11-cp312-cp312-win_amd64.whl", hash = "sha256:44b1b8e6253bceada11f714acf4309ffb98bfa9ac55e4fce14f9e5d4484287a1"}, - {file = "debugpy-1.8.11-cp313-cp313-macosx_14_0_universal2.whl", hash = "sha256:8988f7163e4381b0da7696f37eec7aca19deb02e500245df68a7159739bbd0d3"}, - {file = "debugpy-1.8.11-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c1f6a173d1140e557347419767d2b14ac1c9cd847e0b4c5444c7f3144697e4e"}, - {file = "debugpy-1.8.11-cp313-cp313-win32.whl", hash = "sha256:bb3b15e25891f38da3ca0740271e63ab9db61f41d4d8541745cfc1824252cb28"}, - {file = "debugpy-1.8.11-cp313-cp313-win_amd64.whl", hash = "sha256:d8768edcbeb34da9e11bcb8b5c2e0958d25218df7a6e56adf415ef262cd7b6d1"}, - {file = "debugpy-1.8.11-cp38-cp38-macosx_14_0_x86_64.whl", hash = "sha256:ad7efe588c8f5cf940f40c3de0cd683cc5b76819446abaa50dc0829a30c094db"}, - {file = "debugpy-1.8.11-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:189058d03a40103a57144752652b3ab08ff02b7595d0ce1f651b9acc3a3a35a0"}, - {file = "debugpy-1.8.11-cp38-cp38-win32.whl", hash = "sha256:32db46ba45849daed7ccf3f2e26f7a386867b077f39b2a974bb5c4c2c3b0a280"}, - {file = "debugpy-1.8.11-cp38-cp38-win_amd64.whl", hash = "sha256:116bf8342062246ca749013df4f6ea106f23bc159305843491f64672a55af2e5"}, - {file = "debugpy-1.8.11-cp39-cp39-macosx_14_0_x86_64.whl", hash = "sha256:654130ca6ad5de73d978057eaf9e582244ff72d4574b3e106fb8d3d2a0d32458"}, - {file = "debugpy-1.8.11-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:23dc34c5e03b0212fa3c49a874df2b8b1b8fda95160bd79c01eb3ab51ea8d851"}, - {file = "debugpy-1.8.11-cp39-cp39-win32.whl", hash = "sha256:52d8a3166c9f2815bfae05f386114b0b2d274456980d41f320299a8d9a5615a7"}, - {file = "debugpy-1.8.11-cp39-cp39-win_amd64.whl", hash = "sha256:52c3cf9ecda273a19cc092961ee34eb9ba8687d67ba34cc7b79a521c1c64c4c0"}, - {file = "debugpy-1.8.11-py2.py3-none-any.whl", hash = "sha256:0e22f846f4211383e6a416d04b4c13ed174d24cc5d43f5fd52e7821d0ebc8920"}, - {file = "debugpy-1.8.11.tar.gz", hash = "sha256:6ad2688b69235c43b020e04fecccdf6a96c8943ca9c2fb340b8adc103c655e57"}, + {file = "debugpy-1.8.12-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:a2ba7ffe58efeae5b8fad1165357edfe01464f9aef25e814e891ec690e7dd82a"}, + {file = "debugpy-1.8.12-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cbbd4149c4fc5e7d508ece083e78c17442ee13b0e69bfa6bd63003e486770f45"}, + {file = "debugpy-1.8.12-cp310-cp310-win32.whl", hash = "sha256:b202f591204023b3ce62ff9a47baa555dc00bb092219abf5caf0e3718ac20e7c"}, + {file = "debugpy-1.8.12-cp310-cp310-win_amd64.whl", hash = "sha256:9649eced17a98ce816756ce50433b2dd85dfa7bc92ceb60579d68c053f98dff9"}, + {file = "debugpy-1.8.12-cp311-cp311-macosx_14_0_universal2.whl", hash = "sha256:36f4829839ef0afdfdd208bb54f4c3d0eea86106d719811681a8627ae2e53dd5"}, + {file = "debugpy-1.8.12-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a28ed481d530e3138553be60991d2d61103ce6da254e51547b79549675f539b7"}, + {file = "debugpy-1.8.12-cp311-cp311-win32.whl", hash = "sha256:4ad9a94d8f5c9b954e0e3b137cc64ef3f579d0df3c3698fe9c3734ee397e4abb"}, + {file = "debugpy-1.8.12-cp311-cp311-win_amd64.whl", hash = "sha256:4703575b78dd697b294f8c65588dc86874ed787b7348c65da70cfc885efdf1e1"}, + {file = "debugpy-1.8.12-cp312-cp312-macosx_14_0_universal2.whl", hash = "sha256:7e94b643b19e8feb5215fa508aee531387494bf668b2eca27fa769ea11d9f498"}, + {file = "debugpy-1.8.12-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:086b32e233e89a2740c1615c2f775c34ae951508b28b308681dbbb87bba97d06"}, + {file = "debugpy-1.8.12-cp312-cp312-win32.whl", hash = "sha256:2ae5df899732a6051b49ea2632a9ea67f929604fd2b036613a9f12bc3163b92d"}, + {file = "debugpy-1.8.12-cp312-cp312-win_amd64.whl", hash = "sha256:39dfbb6fa09f12fae32639e3286112fc35ae976114f1f3d37375f3130a820969"}, + {file = "debugpy-1.8.12-cp313-cp313-macosx_14_0_universal2.whl", hash = "sha256:696d8ae4dff4cbd06bf6b10d671e088b66669f110c7c4e18a44c43cf75ce966f"}, + {file = "debugpy-1.8.12-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:898fba72b81a654e74412a67c7e0a81e89723cfe2a3ea6fcd3feaa3395138ca9"}, + {file = "debugpy-1.8.12-cp313-cp313-win32.whl", hash = "sha256:22a11c493c70413a01ed03f01c3c3a2fc4478fc6ee186e340487b2edcd6f4180"}, + {file = "debugpy-1.8.12-cp313-cp313-win_amd64.whl", hash = "sha256:fdb3c6d342825ea10b90e43d7f20f01535a72b3a1997850c0c3cefa5c27a4a2c"}, + {file = "debugpy-1.8.12-cp38-cp38-macosx_14_0_x86_64.whl", hash = "sha256:b0232cd42506d0c94f9328aaf0d1d0785f90f87ae72d9759df7e5051be039738"}, + {file = "debugpy-1.8.12-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9af40506a59450f1315168d47a970db1a65aaab5df3833ac389d2899a5d63b3f"}, + {file = "debugpy-1.8.12-cp38-cp38-win32.whl", hash = "sha256:5cc45235fefac57f52680902b7d197fb2f3650112379a6fa9aa1b1c1d3ed3f02"}, + {file = "debugpy-1.8.12-cp38-cp38-win_amd64.whl", hash = "sha256:557cc55b51ab2f3371e238804ffc8510b6ef087673303890f57a24195d096e61"}, + {file = "debugpy-1.8.12-cp39-cp39-macosx_14_0_x86_64.whl", hash = "sha256:b5c6c967d02fee30e157ab5227706f965d5c37679c687b1e7bbc5d9e7128bd41"}, + {file = "debugpy-1.8.12-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:88a77f422f31f170c4b7e9ca58eae2a6c8e04da54121900651dfa8e66c29901a"}, + {file = "debugpy-1.8.12-cp39-cp39-win32.whl", hash = "sha256:a4042edef80364239f5b7b5764e55fd3ffd40c32cf6753da9bda4ff0ac466018"}, + {file = "debugpy-1.8.12-cp39-cp39-win_amd64.whl", hash = "sha256:f30b03b0f27608a0b26c75f0bb8a880c752c0e0b01090551b9d87c7d783e2069"}, + {file = "debugpy-1.8.12-py2.py3-none-any.whl", hash = "sha256:274b6a2040349b5c9864e475284bce5bb062e63dce368a394b8cc865ae3b00c6"}, + {file = "debugpy-1.8.12.tar.gz", hash = "sha256:646530b04f45c830ceae8e491ca1c9320a2d2f0efea3141487c82130aba70dce"}, ] [[package]] @@ -2010,67 +2010,67 @@ test = ["pytest", "pytest-console-scripts", "pytest-jupyter", "pytest-tornasync" [[package]] name = "numpy" -version = "2.2.1" +version = "2.2.2" description = "Fundamental package for array computing in Python" optional = false python-versions = ">=3.10" groups = ["main"] files = [ - {file = "numpy-2.2.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:5edb4e4caf751c1518e6a26a83501fda79bff41cc59dac48d70e6d65d4ec4440"}, - {file = "numpy-2.2.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:aa3017c40d513ccac9621a2364f939d39e550c542eb2a894b4c8da92b38896ab"}, - {file = "numpy-2.2.1-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:61048b4a49b1c93fe13426e04e04fdf5a03f456616f6e98c7576144677598675"}, - {file = "numpy-2.2.1-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:7671dc19c7019103ca44e8d94917eba8534c76133523ca8406822efdd19c9308"}, - {file = "numpy-2.2.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4250888bcb96617e00bfa28ac24850a83c9f3a16db471eca2ee1f1714df0f957"}, - {file = "numpy-2.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a7746f235c47abc72b102d3bce9977714c2444bdfaea7888d241b4c4bb6a78bf"}, - {file = "numpy-2.2.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:059e6a747ae84fce488c3ee397cee7e5f905fd1bda5fb18c66bc41807ff119b2"}, - {file = "numpy-2.2.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:f62aa6ee4eb43b024b0e5a01cf65a0bb078ef8c395e8713c6e8a12a697144528"}, - {file = "numpy-2.2.1-cp310-cp310-win32.whl", hash = "sha256:48fd472630715e1c1c89bf1feab55c29098cb403cc184b4859f9c86d4fcb6a95"}, - {file = "numpy-2.2.1-cp310-cp310-win_amd64.whl", hash = "sha256:b541032178a718c165a49638d28272b771053f628382d5e9d1c93df23ff58dbf"}, - {file = "numpy-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:40f9e544c1c56ba8f1cf7686a8c9b5bb249e665d40d626a23899ba6d5d9e1484"}, - {file = "numpy-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f9b57eaa3b0cd8db52049ed0330747b0364e899e8a606a624813452b8203d5f7"}, - {file = "numpy-2.2.1-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:bc8a37ad5b22c08e2dbd27df2b3ef7e5c0864235805b1e718a235bcb200cf1cb"}, - {file = "numpy-2.2.1-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:9036d6365d13b6cbe8f27a0eaf73ddcc070cae584e5ff94bb45e3e9d729feab5"}, - {file = "numpy-2.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:51faf345324db860b515d3f364eaa93d0e0551a88d6218a7d61286554d190d73"}, - {file = "numpy-2.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:38efc1e56b73cc9b182fe55e56e63b044dd26a72128fd2fbd502f75555d92591"}, - {file = "numpy-2.2.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:31b89fa67a8042e96715c68e071a1200c4e172f93b0fbe01a14c0ff3ff820fc8"}, - {file = "numpy-2.2.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:4c86e2a209199ead7ee0af65e1d9992d1dce7e1f63c4b9a616500f93820658d0"}, - {file = "numpy-2.2.1-cp311-cp311-win32.whl", hash = "sha256:b34d87e8a3090ea626003f87f9392b3929a7bbf4104a05b6667348b6bd4bf1cd"}, - {file = "numpy-2.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:360137f8fb1b753c5cde3ac388597ad680eccbbbb3865ab65efea062c4a1fd16"}, - {file = "numpy-2.2.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:694f9e921a0c8f252980e85bce61ebbd07ed2b7d4fa72d0e4246f2f8aa6642ab"}, - {file = "numpy-2.2.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3683a8d166f2692664262fd4900f207791d005fb088d7fdb973cc8d663626faa"}, - {file = "numpy-2.2.1-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:780077d95eafc2ccc3ced969db22377b3864e5b9a0ea5eb347cc93b3ea900315"}, - {file = "numpy-2.2.1-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:55ba24ebe208344aa7a00e4482f65742969a039c2acfcb910bc6fcd776eb4355"}, - {file = "numpy-2.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9b1d07b53b78bf84a96898c1bc139ad7f10fda7423f5fd158fd0f47ec5e01ac7"}, - {file = "numpy-2.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5062dc1a4e32a10dc2b8b13cedd58988261416e811c1dc4dbdea4f57eea61b0d"}, - {file = "numpy-2.2.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:fce4f615f8ca31b2e61aa0eb5865a21e14f5629515c9151850aa936c02a1ee51"}, - {file = "numpy-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:67d4cda6fa6ffa073b08c8372aa5fa767ceb10c9a0587c707505a6d426f4e046"}, - {file = "numpy-2.2.1-cp312-cp312-win32.whl", hash = "sha256:32cb94448be47c500d2c7a95f93e2f21a01f1fd05dd2beea1ccd049bb6001cd2"}, - {file = "numpy-2.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:ba5511d8f31c033a5fcbda22dd5c813630af98c70b2661f2d2c654ae3cdfcfc8"}, - {file = "numpy-2.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f1d09e520217618e76396377c81fba6f290d5f926f50c35f3a5f72b01a0da780"}, - {file = "numpy-2.2.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3ecc47cd7f6ea0336042be87d9e7da378e5c7e9b3c8ad0f7c966f714fc10d821"}, - {file = "numpy-2.2.1-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:f419290bc8968a46c4933158c91a0012b7a99bb2e465d5ef5293879742f8797e"}, - {file = "numpy-2.2.1-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:5b6c390bfaef8c45a260554888966618328d30e72173697e5cabe6b285fb2348"}, - {file = "numpy-2.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:526fc406ab991a340744aad7e25251dd47a6720a685fa3331e5c59fef5282a59"}, - {file = "numpy-2.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f74e6fdeb9a265624ec3a3918430205dff1df7e95a230779746a6af78bc615af"}, - {file = "numpy-2.2.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:53c09385ff0b72ba79d8715683c1168c12e0b6e84fb0372e97553d1ea91efe51"}, - {file = "numpy-2.2.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f3eac17d9ec51be534685ba877b6ab5edc3ab7ec95c8f163e5d7b39859524716"}, - {file = "numpy-2.2.1-cp313-cp313-win32.whl", hash = "sha256:9ad014faa93dbb52c80d8f4d3dcf855865c876c9660cb9bd7553843dd03a4b1e"}, - {file = "numpy-2.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:164a829b6aacf79ca47ba4814b130c4020b202522a93d7bff2202bfb33b61c60"}, - {file = "numpy-2.2.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:4dfda918a13cc4f81e9118dea249e192ab167a0bb1966272d5503e39234d694e"}, - {file = "numpy-2.2.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:733585f9f4b62e9b3528dd1070ec4f52b8acf64215b60a845fa13ebd73cd0712"}, - {file = "numpy-2.2.1-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:89b16a18e7bba224ce5114db863e7029803c179979e1af6ad6a6b11f70545008"}, - {file = "numpy-2.2.1-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:676f4eebf6b2d430300f1f4f4c2461685f8269f94c89698d832cdf9277f30b84"}, - {file = "numpy-2.2.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:27f5cdf9f493b35f7e41e8368e7d7b4bbafaf9660cba53fb21d2cd174ec09631"}, - {file = "numpy-2.2.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c1ad395cf254c4fbb5b2132fee391f361a6e8c1adbd28f2cd8e79308a615fe9d"}, - {file = "numpy-2.2.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:08ef779aed40dbc52729d6ffe7dd51df85796a702afbf68a4f4e41fafdc8bda5"}, - {file = "numpy-2.2.1-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:26c9c4382b19fcfbbed3238a14abf7ff223890ea1936b8890f058e7ba35e8d71"}, - {file = "numpy-2.2.1-cp313-cp313t-win32.whl", hash = "sha256:93cf4e045bae74c90ca833cba583c14b62cb4ba2cba0abd2b141ab52548247e2"}, - {file = "numpy-2.2.1-cp313-cp313t-win_amd64.whl", hash = "sha256:bff7d8ec20f5f42607599f9994770fa65d76edca264a87b5e4ea5629bce12268"}, - {file = "numpy-2.2.1-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:7ba9cc93a91d86365a5d270dee221fdc04fb68d7478e6bf6af650de78a8339e3"}, - {file = "numpy-2.2.1-pp310-pypy310_pp73-macosx_14_0_x86_64.whl", hash = "sha256:3d03883435a19794e41f147612a77a8f56d4e52822337844fff3d4040a142964"}, - {file = "numpy-2.2.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4511d9e6071452b944207c8ce46ad2f897307910b402ea5fa975da32e0102800"}, - {file = "numpy-2.2.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:5c5cc0cbabe9452038ed984d05ac87910f89370b9242371bd9079cb4af61811e"}, - {file = "numpy-2.2.1.tar.gz", hash = "sha256:45681fd7128c8ad1c379f0ca0776a8b0c6583d2f69889ddac01559dfe4390918"}, + {file = "numpy-2.2.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7079129b64cb78bdc8d611d1fd7e8002c0a2565da6a47c4df8062349fee90e3e"}, + {file = "numpy-2.2.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2ec6c689c61df613b783aeb21f945c4cbe6c51c28cb70aae8430577ab39f163e"}, + {file = "numpy-2.2.2-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:40c7ff5da22cd391944a28c6a9c638a5eef77fcf71d6e3a79e1d9d9e82752715"}, + {file = "numpy-2.2.2-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:995f9e8181723852ca458e22de5d9b7d3ba4da3f11cc1cb113f093b271d7965a"}, + {file = "numpy-2.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b78ea78450fd96a498f50ee096f69c75379af5138f7881a51355ab0e11286c97"}, + {file = "numpy-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3fbe72d347fbc59f94124125e73fc4976a06927ebc503ec5afbfb35f193cd957"}, + {file = "numpy-2.2.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:8e6da5cffbbe571f93588f562ed130ea63ee206d12851b60819512dd3e1ba50d"}, + {file = "numpy-2.2.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:09d6a2032faf25e8d0cadde7fd6145118ac55d2740132c1d845f98721b5ebcfd"}, + {file = "numpy-2.2.2-cp310-cp310-win32.whl", hash = "sha256:159ff6ee4c4a36a23fe01b7c3d07bd8c14cc433d9720f977fcd52c13c0098160"}, + {file = "numpy-2.2.2-cp310-cp310-win_amd64.whl", hash = "sha256:64bd6e1762cd7f0986a740fee4dff927b9ec2c5e4d9a28d056eb17d332158014"}, + {file = "numpy-2.2.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:642199e98af1bd2b6aeb8ecf726972d238c9877b0f6e8221ee5ab945ec8a2189"}, + {file = "numpy-2.2.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:6d9fc9d812c81e6168b6d405bf00b8d6739a7f72ef22a9214c4241e0dc70b323"}, + {file = "numpy-2.2.2-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:c7d1fd447e33ee20c1f33f2c8e6634211124a9aabde3c617687d8b739aa69eac"}, + {file = "numpy-2.2.2-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:451e854cfae0febe723077bd0cf0a4302a5d84ff25f0bfece8f29206c7bed02e"}, + {file = "numpy-2.2.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bd249bc894af67cbd8bad2c22e7cbcd46cf87ddfca1f1289d1e7e54868cc785c"}, + {file = "numpy-2.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:02935e2c3c0c6cbe9c7955a8efa8908dd4221d7755644c59d1bba28b94fd334f"}, + {file = "numpy-2.2.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:a972cec723e0563aa0823ee2ab1df0cb196ed0778f173b381c871a03719d4826"}, + {file = "numpy-2.2.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:d6d6a0910c3b4368d89dde073e630882cdb266755565155bc33520283b2d9df8"}, + {file = "numpy-2.2.2-cp311-cp311-win32.whl", hash = "sha256:860fd59990c37c3ef913c3ae390b3929d005243acca1a86facb0773e2d8d9e50"}, + {file = "numpy-2.2.2-cp311-cp311-win_amd64.whl", hash = "sha256:da1eeb460ecce8d5b8608826595c777728cdf28ce7b5a5a8c8ac8d949beadcf2"}, + {file = "numpy-2.2.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:ac9bea18d6d58a995fac1b2cb4488e17eceeac413af014b1dd26170b766d8467"}, + {file = "numpy-2.2.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:23ae9f0c2d889b7b2d88a3791f6c09e2ef827c2446f1c4a3e3e76328ee4afd9a"}, + {file = "numpy-2.2.2-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:3074634ea4d6df66be04f6728ee1d173cfded75d002c75fac79503a880bf3825"}, + {file = "numpy-2.2.2-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:8ec0636d3f7d68520afc6ac2dc4b8341ddb725039de042faf0e311599f54eb37"}, + {file = "numpy-2.2.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2ffbb1acd69fdf8e89dd60ef6182ca90a743620957afb7066385a7bbe88dc748"}, + {file = "numpy-2.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0349b025e15ea9d05c3d63f9657707a4e1d471128a3b1d876c095f328f8ff7f0"}, + {file = "numpy-2.2.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:463247edcee4a5537841d5350bc87fe8e92d7dd0e8c71c995d2c6eecb8208278"}, + {file = "numpy-2.2.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:9dd47ff0cb2a656ad69c38da850df3454da88ee9a6fde0ba79acceee0e79daba"}, + {file = "numpy-2.2.2-cp312-cp312-win32.whl", hash = "sha256:4525b88c11906d5ab1b0ec1f290996c0020dd318af8b49acaa46f198b1ffc283"}, + {file = "numpy-2.2.2-cp312-cp312-win_amd64.whl", hash = "sha256:5acea83b801e98541619af398cc0109ff48016955cc0818f478ee9ef1c5c3dcb"}, + {file = "numpy-2.2.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:b208cfd4f5fe34e1535c08983a1a6803fdbc7a1e86cf13dd0c61de0b51a0aadc"}, + {file = "numpy-2.2.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:d0bbe7dd86dca64854f4b6ce2ea5c60b51e36dfd597300057cf473d3615f2369"}, + {file = "numpy-2.2.2-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:22ea3bb552ade325530e72a0c557cdf2dea8914d3a5e1fecf58fa5dbcc6f43cd"}, + {file = "numpy-2.2.2-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:128c41c085cab8a85dc29e66ed88c05613dccf6bc28b3866cd16050a2f5448be"}, + {file = "numpy-2.2.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:250c16b277e3b809ac20d1f590716597481061b514223c7badb7a0f9993c7f84"}, + {file = "numpy-2.2.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e0c8854b09bc4de7b041148d8550d3bd712b5c21ff6a8ed308085f190235d7ff"}, + {file = "numpy-2.2.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:b6fb9c32a91ec32a689ec6410def76443e3c750e7cfc3fb2206b985ffb2b85f0"}, + {file = "numpy-2.2.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:57b4012e04cc12b78590a334907e01b3a85efb2107df2b8733ff1ed05fce71de"}, + {file = "numpy-2.2.2-cp313-cp313-win32.whl", hash = "sha256:4dbd80e453bd34bd003b16bd802fac70ad76bd463f81f0c518d1245b1c55e3d9"}, + {file = "numpy-2.2.2-cp313-cp313-win_amd64.whl", hash = "sha256:5a8c863ceacae696aff37d1fd636121f1a512117652e5dfb86031c8d84836369"}, + {file = "numpy-2.2.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:b3482cb7b3325faa5f6bc179649406058253d91ceda359c104dac0ad320e1391"}, + {file = "numpy-2.2.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:9491100aba630910489c1d0158034e1c9a6546f0b1340f716d522dc103788e39"}, + {file = "numpy-2.2.2-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:41184c416143defa34cc8eb9d070b0a5ba4f13a0fa96a709e20584638254b317"}, + {file = "numpy-2.2.2-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:7dca87ca328f5ea7dafc907c5ec100d187911f94825f8700caac0b3f4c384b49"}, + {file = "numpy-2.2.2-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0bc61b307655d1a7f9f4b043628b9f2b721e80839914ede634e3d485913e1fb2"}, + {file = "numpy-2.2.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9fad446ad0bc886855ddf5909cbf8cb5d0faa637aaa6277fb4b19ade134ab3c7"}, + {file = "numpy-2.2.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:149d1113ac15005652e8d0d3f6fd599360e1a708a4f98e43c9c77834a28238cb"}, + {file = "numpy-2.2.2-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:106397dbbb1896f99e044efc90360d098b3335060375c26aa89c0d8a97c5f648"}, + {file = "numpy-2.2.2-cp313-cp313t-win32.whl", hash = "sha256:0eec19f8af947a61e968d5429f0bd92fec46d92b0008d0a6685b40d6adf8a4f4"}, + {file = "numpy-2.2.2-cp313-cp313t-win_amd64.whl", hash = "sha256:97b974d3ba0fb4612b77ed35d7627490e8e3dff56ab41454d9e8b23448940576"}, + {file = "numpy-2.2.2-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:b0531f0b0e07643eb089df4c509d30d72c9ef40defa53e41363eca8a8cc61495"}, + {file = "numpy-2.2.2-pp310-pypy310_pp73-macosx_14_0_x86_64.whl", hash = "sha256:e9e82dcb3f2ebbc8cb5ce1102d5f1c5ed236bf8a11730fb45ba82e2841ec21df"}, + {file = "numpy-2.2.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e0d4142eb40ca6f94539e4db929410f2a46052a0fe7a2c1c59f6179c39938d2a"}, + {file = "numpy-2.2.2-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:356ca982c188acbfa6af0d694284d8cf20e95b1c3d0aefa8929376fea9146f60"}, + {file = "numpy-2.2.2.tar.gz", hash = "sha256:ed6906f61834d687738d25988ae117683705636936cc605be0bb208b23df4d8f"}, ] [[package]] @@ -2795,19 +2795,20 @@ cffi = {version = "*", markers = "implementation_name == \"pypy\""} [[package]] name = "referencing" -version = "0.35.1" +version = "0.36.1" description = "JSON Referencing + Python" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" groups = ["main"] files = [ - {file = "referencing-0.35.1-py3-none-any.whl", hash = "sha256:eda6d3234d62814d1c64e305c1331c9a3a6132da475ab6382eaa997b21ee75de"}, - {file = "referencing-0.35.1.tar.gz", hash = "sha256:25b42124a6c8b632a425174f24087783efb348a6f1e0008e63cd4466fedf703c"}, + {file = "referencing-0.36.1-py3-none-any.whl", hash = "sha256:363d9c65f080d0d70bc41c721dce3c7f3e77fc09f269cd5c8813da18069a6794"}, + {file = "referencing-0.36.1.tar.gz", hash = "sha256:ca2e6492769e3602957e9b831b94211599d2aade9477f5d44110d2530cf9aade"}, ] [package.dependencies] attrs = ">=22.2.0" rpds-py = ">=0.7.0" +typing-extensions = {version = ">=4.4.0", markers = "python_version < \"3.13\""} [[package]] name = "requests" diff --git a/财报筛选/loader.py b/财报筛选/loader.py index 5953ea1..9e4ca08 100644 --- a/财报筛选/loader.py +++ b/财报筛选/loader.py @@ -2,8 +2,8 @@ import os.path import pandas as pd -# finance_root = "/Users/lanyuanxiaoyao/SynologyDrive/data/Tushare" -finance_root = "C:\\Users\\lanyuanxiaoyao\\Documents\\Tushare" +finance_root = "/Users/lanyuanxiaoyao/SynologyDrive/data/Tushare" +# finance_root = "C:\\Users\\lanyuanxiaoyao\\Documents\\Tushare" def load_balance_sheet(): diff --git a/财报筛选/金字塔选股.ipynb b/财报筛选/金字塔选股.ipynb index bbcd4a4..96c5282 100644 --- a/财报筛选/金字塔选股.ipynb +++ b/财报筛选/金字塔选股.ipynb @@ -6,25 +6,25 @@ "metadata": { "collapsed": true, "ExecuteTime": { - "end_time": "2025-01-19T16:42:26.631868Z", - "start_time": "2025-01-19T16:42:26.628635Z" + "end_time": "2025-01-20T09:12:32.313699Z", + "start_time": "2025-01-20T09:12:32.310753Z" } }, "source": [ - "import numpy as np\n", + "\n", "import pandas as pd\n", "import tushare as ts\n", "\n", "ts_pro = ts.pro_api(token=\"64ebff4fa679167600b905ee45dd88e76f3963c0ff39157f3f085f0e\")" ], "outputs": [], - "execution_count": 459 + "execution_count": 99 }, { "metadata": { "ExecuteTime": { - "end_time": "2025-01-19T16:42:27.857016Z", - "start_time": "2025-01-19T16:42:26.639161Z" + "end_time": "2025-01-20T09:12:35.800981Z", + "start_time": "2025-01-20T09:12:32.319361Z" } }, "cell_type": "code", @@ -77,7 +77,7 @@ ], "id": "68b2debc14502fd5", "outputs": [], - "execution_count": 460 + "execution_count": 100 }, { "metadata": {}, @@ -88,15 +88,15 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-01-19T16:42:27.931899Z", - "start_time": "2025-01-19T16:42:27.868963Z" + "end_time": "2025-01-20T09:12:35.994681Z", + "start_time": "2025-01-20T09:12:35.828990Z" } }, "cell_type": "code", "source": "finance_df = finance_df.groupby(\"code\").filter(lambda x: len(x) > 6)", "id": "4293bd93ea8f9ed", "outputs": [], - "execution_count": 461 + "execution_count": 101 }, { "metadata": {}, @@ -118,8 +118,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-01-19T16:42:29.192712Z", - "start_time": "2025-01-19T16:42:27.946033Z" + "end_time": "2025-01-20T09:12:38.908153Z", + "start_time": "2025-01-20T09:12:36.022143Z" } }, "cell_type": "code", @@ -151,12 +151,12 @@ "name": "stderr", "output_type": "stream", "text": [ - "C:\\Users\\lanyuanxiaoyao\\AppData\\Local\\Temp\\ipykernel_28824\\1604170078.py:20: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n", + "/var/folders/7h/w0cmp4zj6mn9br_6nyj310m40000gn/T/ipykernel_72996/1604170078.py:20: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n", " finance_df = finance_df.groupby(\"code\").apply(reset_score_for_average_roe).reset_index(drop=True)\n" ] } ], - "execution_count": 462 + "execution_count": 102 }, { "metadata": {}, @@ -173,8 +173,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-01-19T16:42:29.363249Z", - "start_time": "2025-01-19T16:42:29.219453Z" + "end_time": "2025-01-20T09:12:39.103417Z", + "start_time": "2025-01-20T09:12:38.937447Z" } }, "cell_type": "code", @@ -190,7 +190,7 @@ ], "id": "3b585cf8e2eb5e3", "outputs": [], - "execution_count": 463 + "execution_count": 103 }, { "metadata": {}, @@ -206,8 +206,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-01-19T16:42:29.878285Z", - "start_time": "2025-01-19T16:42:29.369862Z" + "end_time": "2025-01-20T09:12:39.922683Z", + "start_time": "2025-01-20T09:12:39.130104Z" } }, "cell_type": "code", @@ -221,7 +221,7 @@ ], "id": "fd5582e080102e20", "outputs": [], - "execution_count": 464 + "execution_count": 104 }, { "metadata": {}, @@ -237,8 +237,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-01-19T16:42:29.905727Z", - "start_time": "2025-01-19T16:42:29.889468Z" + "end_time": "2025-01-20T09:12:39.965030Z", + "start_time": "2025-01-20T09:12:39.946246Z" } }, "cell_type": "code", @@ -258,7 +258,7 @@ ], "id": "bc92e050c82c3768", "outputs": [], - "execution_count": 465 + "execution_count": 105 }, { "metadata": {}, @@ -282,8 +282,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-01-19T16:42:29.923829Z", - "start_time": "2025-01-19T16:42:29.916781Z" + "end_time": "2025-01-20T09:12:40.003327Z", + "start_time": "2025-01-20T09:12:39.990482Z" } }, "cell_type": "code", @@ -312,7 +312,7 @@ ], "id": "baeb44a4fb28b60b", "outputs": [], - "execution_count": 466 + "execution_count": 106 }, { "metadata": {}, @@ -327,8 +327,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-01-19T16:42:30.005541Z", - "start_time": "2025-01-19T16:42:29.935348Z" + "end_time": "2025-01-20T09:12:40.179998Z", + "start_time": "2025-01-20T09:12:40.027705Z" } }, "cell_type": "code", @@ -336,14 +336,15 @@ "finance_df[\"gross_profit_ratio\"] = (finance_df[\"total_revenue\"] - finance_df[\"operating_costs\"]) / finance_df[\n", " \"total_revenue\"]\n", "finance_df[\"gross_profit_ratio_std\"] = finance_df.groupby(\"code\")[\"gross_profit_ratio\"].rolling(\n", - " window=5).std().reset_index(0, drop=True)\n", + " window=5\n", + ").std().reset_index(0, drop=True)\n", "finance_df[\"score_gross_profit_ratio\"] = 0\n", "finance_df[(not finance_df[\"gross_profit_ratio_std\"].isna) & (finance_df[\"gross_profit_ratio_std\"] < 30)] = 50\n", "finance_df[\"score\"] += finance_df[\"score_gross_profit_ratio\"]" ], "id": "9d23bdf60a1839c9", "outputs": [], - "execution_count": 467 + "execution_count": 107 }, { "metadata": {}, @@ -360,8 +361,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-01-19T16:42:30.022774Z", - "start_time": "2025-01-19T16:42:30.016550Z" + "end_time": "2025-01-20T09:12:40.213136Z", + "start_time": "2025-01-20T09:12:40.205548Z" } }, "cell_type": "code", @@ -376,7 +377,7 @@ ], "id": "f7d9486af89cb710", "outputs": [], - "execution_count": 468 + "execution_count": 108 }, { "metadata": {}, @@ -394,8 +395,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-01-19T16:42:46.378919Z", - "start_time": "2025-01-19T16:42:30.718209Z" + "end_time": "2025-01-20T09:12:57.833029Z", + "start_time": "2025-01-20T09:12:40.241875Z" } }, "cell_type": "code", @@ -404,28 +405,29 @@ " # 计算 score_net_income_1\n", " group['net_income_shift_1'] = group['net_income'].shift(1)\n", " group['score_net_income_1'] = (group['net_income'] > group['net_income_shift_1']).map(\n", - " {True: 30, False: -30})\n", - " group = group.mask(pd.isna(group[\"net_income_shift_1\"]), other=0)\n", + " {True: 30, False: -30}\n", + " )\n", " # 计算 score_net_income_2\n", " group['net_income_shift_2'] = group['net_income'].shift(2)\n", " group['score_net_income_2'] = (group['net_income_shift_1'] > group['net_income_shift_2']).map(\n", - " {True: 25, False: -25})\n", + " {True: 25, False: -25}\n", + " )\n", " # 计算 score_net_income_3\n", " group['net_income_shift_3'] = group['net_income'].shift(3)\n", " group['score_net_income_3'] = (group['net_income_shift_2'] > group['net_income_shift_3']).map(\n", - " {True: 20, False: -20})\n", + " {True: 20, False: -20}\n", + " )\n", " # 计算 score_net_income_4\n", " group['net_income_shift_4'] = group['net_income'].shift(4)\n", " group['score_net_income_4'] = (group['net_income_shift_3'] > group['net_income_shift_4']).map(\n", - " {True: 15, False: -15}).fillna(0)\n", + " {True: 15, False: -15}\n", + " )\n", " return group\n", "\n", "\n", "finance_df = finance_df.groupby(\"code\").apply(score_by_net_income_ascending).reset_index(drop=True)\n", - "finance_df[\"score_net_income_ascending\"] = np.sum(\n", - " [finance_df[\"score_net_income_1\"], finance_df[\"score_net_income_2\"], finance_df[\"score_net_income_3\"],\n", - " finance_df[\"score_net_income_4\"]], axis=0)\n", - "finance_df" + "finance_df[\"score_net_income_ascending\"] = finance_df[\"score_net_income_1\"] + finance_df[\"score_net_income_2\"] + \\\n", + " finance_df[\"score_net_income_3\"] + finance_df[\"score_net_income_4\"]" ], "id": "2d1ca7fc7873ce71", "outputs": [ @@ -433,92 +435,107 @@ "name": "stderr", "output_type": "stream", "text": [ - "C:\\Users\\lanyuanxiaoyao\\AppData\\Local\\Temp\\ipykernel_28824\\3206398043.py:22: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n", + "/var/folders/7h/w0cmp4zj6mn9br_6nyj310m40000gn/T/ipykernel_72996/432379325.py:25: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n", " finance_df = finance_df.groupby(\"code\").apply(score_by_net_income_ascending).reset_index(drop=True)\n" ] - }, + } + ], + "execution_count": 109 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2025-01-20T09:13:15.433529Z", + "start_time": "2025-01-20T09:12:57.864097Z" + } + }, + "cell_type": "code", + "source": [ + "def score_by_operating_net_cash_flow_ascending(group):\n", + " # 计算 score_operating_net_cash_flow_1\n", + " group['operating_net_cash_flow_shift_1'] = group['operating_net_cash_flow'].shift(1)\n", + " group['score_operating_net_cash_flow_1'] = (\n", + " group['operating_net_cash_flow'] > group['operating_net_cash_flow_shift_1']).map(\n", + " {True: 30, False: -30}\n", + " )\n", + " # 计算 score_operating_net_cash_flow_2\n", + " group['operating_net_cash_flow_shift_2'] = group['operating_net_cash_flow'].shift(2)\n", + " group['score_operating_net_cash_flow_2'] = (\n", + " group['operating_net_cash_flow_shift_1'] > group['operating_net_cash_flow_shift_2']).map(\n", + " {True: 25, False: -25}\n", + " )\n", + " # 计算 score_operating_net_cash_flow_3\n", + " group['operating_net_cash_flow_shift_3'] = group['operating_net_cash_flow'].shift(3)\n", + " group['score_operating_net_cash_flow_3'] = (\n", + " group['operating_net_cash_flow_shift_2'] > group['operating_net_cash_flow_shift_3']).map(\n", + " {True: 20, False: -20}\n", + " )\n", + " # 计算 score_operating_net_cash_flow_4\n", + " group['operating_net_cash_flow_shift_4'] = group['operating_net_cash_flow'].shift(4)\n", + " group['score_operating_net_cash_flow_4'] = (\n", + " group['operating_net_cash_flow_shift_3'] > group['operating_net_cash_flow_shift_4']).map(\n", + " {True: 15, False: -15}\n", + " )\n", + " return group\n", + "\n", + "\n", + "finance_df = finance_df.groupby(\"code\").apply(score_by_operating_net_cash_flow_ascending).reset_index(drop=True)\n", + "finance_df[\"score_operating_net_cash_flow_ascending\"] = finance_df[\"score_operating_net_cash_flow_1\"] + finance_df[\n", + " \"score_operating_net_cash_flow_2\"] + finance_df[\"score_operating_net_cash_flow_3\"] + finance_df[\n", + " \"score_operating_net_cash_flow_4\"]" + ], + "id": "a90f3721487bd635", + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/var/folders/7h/w0cmp4zj6mn9br_6nyj310m40000gn/T/ipykernel_72996/2138932640.py:29: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n", + " finance_df = finance_df.groupby(\"code\").apply(score_by_operating_net_cash_flow_ascending).reset_index(drop=True)\n" + ] + } + ], + "execution_count": 110 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2025-01-20T09:15:08.342704Z", + "start_time": "2025-01-20T09:15:08.302792Z" + } + }, + "cell_type": "code", + "source": [ + "result_df = finance_df.sort_values(by=['score'], ascending=False, inplace=False)[[\"code\", \"score\"]]\n", + "result_df = result_df.drop_duplicates(\"code\")\n", + "result_df[:20]" + ], + "id": "ef9e6259efc1c1d0", + "outputs": [ { "data": { "text/plain": [ - " code year total_stockholder_interest net_income \\\n", - "0 0 0 0.000000e+00 0.000000e+00 \n", - "1 000001.SZ 2006 6.474463e+09 1.302907e+09 \n", - "2 000001.SZ 2007 1.300606e+10 2.649903e+09 \n", - "3 000001.SZ 2008 1.640079e+10 6.140350e+08 \n", - "4 000001.SZ 2009 2.046961e+10 5.030729e+09 \n", - "... ... ... ... ... \n", - "70725 871981.BJ 2019 1.484536e+08 1.933833e+07 \n", - "70726 871981.BJ 2020 1.963500e+08 3.113004e+07 \n", - "70727 871981.BJ 2021 4.901179e+08 6.549797e+07 \n", - "70728 871981.BJ 2022 5.238630e+08 4.359533e+07 \n", - "70729 871981.BJ 2023 5.044336e+08 -5.665176e+06 \n", - "\n", - " total_assets total_revenue inventories accounts_receivable \\\n", - "0 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 \n", - "1 2.605763e+11 7.135218e+09 NaN NaN \n", - "2 3.525394e+11 1.080750e+10 NaN NaN \n", - "3 4.744402e+11 1.451312e+10 NaN NaN \n", - "4 5.878110e+11 1.511444e+10 NaN NaN \n", - "... ... ... ... ... \n", - "70725 3.438787e+08 2.288707e+08 6.439933e+07 9.145441e+07 \n", - "70726 4.407381e+08 3.221584e+08 7.076865e+07 1.028702e+08 \n", - "70727 7.806398e+08 4.748939e+08 1.102946e+08 1.094223e+08 \n", - "70728 8.141886e+08 3.872667e+08 1.034502e+08 7.252802e+07 \n", - "70729 7.671820e+08 3.613133e+08 1.070212e+08 7.962033e+07 \n", - "\n", - " operating_costs operating_profit ... score_operating_safety_margin \\\n", - "0 0.000000e+00 0.000000e+00 ... 0 \n", - "1 NaN 1.905169e+09 ... 0 \n", - "2 NaN 3.721942e+09 ... 0 \n", - "3 NaN 8.034260e+08 ... 0 \n", - "4 NaN 6.159127e+09 ... 0 \n", - "... ... ... ... ... \n", - "70725 1.759984e+08 1.982603e+07 ... 0 \n", - "70726 2.444144e+08 3.466142e+07 ... 0 \n", - "70727 3.501988e+08 7.194507e+07 ... 0 \n", - "70728 3.141146e+08 2.827675e+07 ... 0 \n", - "70729 3.220560e+08 -1.192680e+07 ... 0 \n", - "\n", - " net_income_shift_1 score_net_income_1 net_income_shift_2 \\\n", - "0 0.000000e+00 0 NaN \n", - "1 3.110076e+08 30 NaN \n", - "2 1.302907e+09 30 0.000000e+00 \n", - "3 2.649903e+09 -30 1.302907e+09 \n", - "4 6.140350e+08 30 2.649903e+09 \n", - "... ... ... ... \n", - "70725 1.875294e+07 30 9.625220e+06 \n", - "70726 1.933833e+07 30 1.875294e+07 \n", - "70727 3.113004e+07 30 1.933833e+07 \n", - "70728 6.549797e+07 -30 3.113004e+07 \n", - "70729 4.359533e+07 -30 6.549797e+07 \n", - "\n", - " score_net_income_2 net_income_shift_3 score_net_income_3 \\\n", - "0 -25 NaN -20 \n", - "1 -25 NaN -20 \n", - "2 25 NaN -20 \n", - "3 25 0.000000e+00 20 \n", - "4 -25 1.302907e+09 20 \n", - "... ... ... ... \n", - "70725 25 0.000000e+00 20 \n", - "70726 25 9.625220e+06 20 \n", - "70727 25 1.875294e+07 20 \n", - "70728 25 1.933833e+07 20 \n", - "70729 -25 3.113004e+07 20 \n", - "\n", - " net_income_shift_4 score_net_income_4 score_net_income_ascending \n", - "0 NaN -15 -60 \n", - "1 NaN -15 -30 \n", - "2 NaN -15 20 \n", - "3 NaN -15 0 \n", - "4 0.00 15 40 \n", - "... ... ... ... \n", - "70725 NaN -15 60 \n", - "70726 0.00 15 90 \n", - "70727 9625220.11 15 90 \n", - "70728 18752944.38 15 30 \n", - "70729 19338331.78 15 -20 \n", - "\n", - "[70730 rows x 46 columns]" + " code score\n", + "48060 600519.SH 810\n", + "45062 600309.SH 810\n", + "58715 601919.SH 790\n", + "17006 002415.SZ 750\n", + "3252 000587.SZ 710\n", + "4129 000651.SZ 710\n", + "64547 603868.SH 710\n", + "56747 601225.SH 710\n", + "4457 000672.SZ 710\n", + "3031 000568.SZ 710\n", + "8872 001201.SZ 710\n", + "31827 300390.SZ 710\n", + "65769 605098.SH 710\n", + "46474 600398.SH 710\n", + "65749 605089.SH 710\n", + "64240 603816.SH 710\n", + "47860 600507.SH 710\n", + "33696 300533.SZ 710\n", + "27948 300146.SZ 710\n", + "35448 300677.SZ 710" ], "text/html": [ "
\n", @@ -540,439 +557,121 @@ " \n", " \n", " code\n", - " year\n", - " total_stockholder_interest\n", - " net_income\n", - " total_assets\n", - " total_revenue\n", - " inventories\n", - " accounts_receivable\n", - " operating_costs\n", - " operating_profit\n", - " ...\n", - " score_operating_safety_margin\n", - " net_income_shift_1\n", - " score_net_income_1\n", - " net_income_shift_2\n", - " score_net_income_2\n", - " net_income_shift_3\n", - " score_net_income_3\n", - " net_income_shift_4\n", - " score_net_income_4\n", - " score_net_income_ascending\n", + " score\n", " \n", " \n", " \n", " \n", - " 0\n", - " 0\n", - " 0\n", - " 0.000000e+00\n", - " 0.000000e+00\n", - " 0.000000e+00\n", - " 0.000000e+00\n", - " 0.000000e+00\n", - " 0.000000e+00\n", - " 0.000000e+00\n", - " 0.000000e+00\n", - " ...\n", - " 0\n", - " 0.000000e+00\n", - " 0\n", - " NaN\n", - " -25\n", - " NaN\n", - " -20\n", - " NaN\n", - " -15\n", - " -60\n", + " 48060\n", + " 600519.SH\n", + " 810\n", " \n", " \n", - " 1\n", - " 000001.SZ\n", - " 2006\n", - " 6.474463e+09\n", - " 1.302907e+09\n", - " 2.605763e+11\n", - " 7.135218e+09\n", - " NaN\n", - " NaN\n", - " NaN\n", - " 1.905169e+09\n", - " ...\n", - " 0\n", - " 3.110076e+08\n", - " 30\n", - " NaN\n", - " -25\n", - " NaN\n", - " -20\n", - " NaN\n", - " -15\n", - " -30\n", + " 45062\n", + " 600309.SH\n", + " 810\n", " \n", " \n", - " 2\n", - " 000001.SZ\n", - " 2007\n", - " 1.300606e+10\n", - " 2.649903e+09\n", - " 3.525394e+11\n", - " 1.080750e+10\n", - " NaN\n", - " NaN\n", - " NaN\n", - " 3.721942e+09\n", - " ...\n", - " 0\n", - " 1.302907e+09\n", - " 30\n", - " 0.000000e+00\n", - " 25\n", - " NaN\n", - " -20\n", - " NaN\n", - " -15\n", - " 20\n", + " 58715\n", + " 601919.SH\n", + " 790\n", " \n", " \n", - " 3\n", - " 000001.SZ\n", - " 2008\n", - " 1.640079e+10\n", - " 6.140350e+08\n", - " 4.744402e+11\n", - " 1.451312e+10\n", - " NaN\n", - " NaN\n", - " NaN\n", - " 8.034260e+08\n", - " ...\n", - " 0\n", - " 2.649903e+09\n", - " -30\n", - " 1.302907e+09\n", - " 25\n", - " 0.000000e+00\n", - " 20\n", - " NaN\n", - " -15\n", - " 0\n", + " 17006\n", + " 002415.SZ\n", + " 750\n", " \n", " \n", - " 4\n", - " 000001.SZ\n", - " 2009\n", - " 2.046961e+10\n", - " 5.030729e+09\n", - " 5.878110e+11\n", - " 1.511444e+10\n", - " NaN\n", - " NaN\n", - " NaN\n", - " 6.159127e+09\n", - " ...\n", - " 0\n", - " 6.140350e+08\n", - " 30\n", - " 2.649903e+09\n", - " -25\n", - " 1.302907e+09\n", - " 20\n", - " 0.00\n", - " 15\n", - " 40\n", + " 3252\n", + " 000587.SZ\n", + " 710\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", + " 4129\n", + " 000651.SZ\n", + " 710\n", " \n", " \n", - " 70725\n", - " 871981.BJ\n", - " 2019\n", - " 1.484536e+08\n", - " 1.933833e+07\n", - " 3.438787e+08\n", - " 2.288707e+08\n", - " 6.439933e+07\n", - " 9.145441e+07\n", - " 1.759984e+08\n", - " 1.982603e+07\n", - " ...\n", - " 0\n", - " 1.875294e+07\n", - " 30\n", - " 9.625220e+06\n", - " 25\n", - " 0.000000e+00\n", - " 20\n", - " NaN\n", - " -15\n", - " 60\n", + " 64547\n", + " 603868.SH\n", + " 710\n", " \n", " \n", - " 70726\n", - " 871981.BJ\n", - " 2020\n", - " 1.963500e+08\n", - " 3.113004e+07\n", - " 4.407381e+08\n", - " 3.221584e+08\n", - " 7.076865e+07\n", - " 1.028702e+08\n", - " 2.444144e+08\n", - " 3.466142e+07\n", - " ...\n", - " 0\n", - " 1.933833e+07\n", - " 30\n", - " 1.875294e+07\n", - " 25\n", - " 9.625220e+06\n", - " 20\n", - " 0.00\n", - " 15\n", - " 90\n", + " 56747\n", + " 601225.SH\n", + " 710\n", " \n", " \n", - " 70727\n", - " 871981.BJ\n", - " 2021\n", - " 4.901179e+08\n", - " 6.549797e+07\n", - " 7.806398e+08\n", - " 4.748939e+08\n", - " 1.102946e+08\n", - " 1.094223e+08\n", - " 3.501988e+08\n", - " 7.194507e+07\n", - " ...\n", - " 0\n", - " 3.113004e+07\n", - " 30\n", - " 1.933833e+07\n", - " 25\n", - " 1.875294e+07\n", - " 20\n", - " 9625220.11\n", - " 15\n", - " 90\n", + " 4457\n", + " 000672.SZ\n", + " 710\n", " \n", " \n", - " 70728\n", - " 871981.BJ\n", - " 2022\n", - " 5.238630e+08\n", - " 4.359533e+07\n", - " 8.141886e+08\n", - " 3.872667e+08\n", - " 1.034502e+08\n", - " 7.252802e+07\n", - " 3.141146e+08\n", - " 2.827675e+07\n", - " ...\n", - " 0\n", - " 6.549797e+07\n", - " -30\n", - " 3.113004e+07\n", - " 25\n", - " 1.933833e+07\n", - " 20\n", - " 18752944.38\n", - " 15\n", - " 30\n", + " 3031\n", + " 000568.SZ\n", + " 710\n", " \n", " \n", - " 70729\n", - " 871981.BJ\n", - " 2023\n", - " 5.044336e+08\n", - " -5.665176e+06\n", - " 7.671820e+08\n", - " 3.613133e+08\n", - " 1.070212e+08\n", - " 7.962033e+07\n", - " 3.220560e+08\n", - " -1.192680e+07\n", - " ...\n", - " 0\n", - " 4.359533e+07\n", - " -30\n", - " 6.549797e+07\n", - " -25\n", - " 3.113004e+07\n", - " 20\n", - " 19338331.78\n", - " 15\n", - " -20\n", + " 8872\n", + " 001201.SZ\n", + " 710\n", + " \n", + " \n", + " 31827\n", + " 300390.SZ\n", + " 710\n", + " \n", + " \n", + " 65769\n", + " 605098.SH\n", + " 710\n", + " \n", + " \n", + " 46474\n", + " 600398.SH\n", + " 710\n", + " \n", + " \n", + " 65749\n", + " 605089.SH\n", + " 710\n", + " \n", + " \n", + " 64240\n", + " 603816.SH\n", + " 710\n", + " \n", + " \n", + " 47860\n", + " 600507.SH\n", + " 710\n", + " \n", + " \n", + " 33696\n", + " 300533.SZ\n", + " 710\n", + " \n", + " \n", + " 27948\n", + " 300146.SZ\n", + " 710\n", + " \n", + " \n", + " 35448\n", + " 300677.SZ\n", + " 710\n", " \n", " \n", "\n", - "

70730 rows × 46 columns

\n", "
" ] }, - "execution_count": 469, + "execution_count": 114, "metadata": {}, "output_type": "execute_result" } ], - "execution_count": 469 - }, - { - "metadata": {}, - "cell_type": "code", - "source": [ - "def score_by_net_income_ascending(code):\n", - " temp_df = finance_df[finance_df[\"code\"] == code].copy()[[\"year\", \"net_income\"]]\n", - " temp_df.sort_values(by=\"year\", ascending=False, inplace=True)\n", - " temp_df.set_index(keys=\"year\", drop=True, inplace=True)\n", - "\n", - " score = 0\n", - " if temp_df.iloc[0].values[0] > temp_df.iloc[1].values[0]:\n", - " score += 30\n", - " else:\n", - " score -= 30\n", - "\n", - " if temp_df.iloc[1].values[0] > temp_df.iloc[2].values[0]:\n", - " score += 25\n", - " else:\n", - " score -= 25\n", - "\n", - " if temp_df.iloc[2].values[0] > temp_df.iloc[3].values[0]:\n", - " score += 20\n", - " else:\n", - " score -= 20\n", - "\n", - " if temp_df.iloc[3].values[0] > temp_df.iloc[4].values[0]:\n", - " score += 15\n", - " else:\n", - " score -= 15\n", - "\n", - " return score\n", - "\n", - "\n", - "codes = list(map(lambda x: add_score(x, score_by_net_income_ascending(x[0])), codes))" - ], - "id": "4ab6a7b485dc9349", - "outputs": [], - "execution_count": null - }, - { - "metadata": {}, - "cell_type": "code", - "source": [ - "def score_by_operating_net_cash_flow_ascending(code):\n", - " temp_df = finance_df[finance_df[\"code\"] == code].copy()[[\"year\", \"operating_net_cash_flow\"]]\n", - " temp_df.sort_values(by=\"year\", ascending=False, inplace=True)\n", - " temp_df.set_index(keys=\"year\", drop=True, inplace=True)\n", - "\n", - " score = 0\n", - " if temp_df.iloc[0].values[0] > temp_df.iloc[1].values[0]:\n", - " score += 30\n", - " else:\n", - " score -= 30\n", - "\n", - " if temp_df.iloc[1].values[0] > temp_df.iloc[2].values[0]:\n", - " score += 25\n", - " else:\n", - " score -= 25\n", - "\n", - " if temp_df.iloc[2].values[0] > temp_df.iloc[3].values[0]:\n", - " score += 20\n", - " else:\n", - " score -= 20\n", - "\n", - " if temp_df.iloc[3].values[0] > temp_df.iloc[4].values[0]:\n", - " score += 15\n", - " else:\n", - " score -= 15\n", - "\n", - " return score\n", - "\n", - "\n", - "codes = list(map(lambda x: add_score(x, score_by_operating_net_cash_flow_ascending(x[0])), codes))" - ], - "id": "d6644089e803a79d", - "outputs": [], - "execution_count": null - }, - { - "metadata": {}, - "cell_type": "code", - "source": [ - "df = pd.DataFrame(\n", - " codes,\n", - " columns=[\"code\", \"name\", \"score\", \"roe_score\", \"roa_score\", \"net_income\", \"assets_turnover_and_cash\",\n", - " \"collection_cash_period_and_sales_period\", \"gross_profit_ratio_volatility\",\n", - " \"operating_safety_margin\", \"net_income_ascending\",\n", - " \"operating_net_cash_flow_ascending\"]\n", - ")\n", - "df.sort_values(by=\"score\", ascending=False, inplace=True)\n", - "df" - ], - "id": "ef9e6259efc1c1d0", - "outputs": [], - "execution_count": null - }, - { - "metadata": {}, - "cell_type": "code", - "source": "df[:100][\"code\"]", - "id": "32b5b4778985afaa", - "outputs": [], - "execution_count": null - }, - { - "metadata": {}, - "cell_type": "code", - "source": [ - "temp_df = finance_df[finance_df[\"code\"] == \"600763.SH\"]\n", - "cal_roe(temp_df)\n", - "cal_roa(temp_df)\n", - "temp_df[[\"year\", \"roe\", \"roa\"]]" - ], - "id": "e6d973f4ff98ebef", - "outputs": [], - "execution_count": null - }, - { - "metadata": {}, - "cell_type": "code", - "source": [ - "temp_df = ts_pro.fina_indicator(\n", - " ts_code=\"600763.SH\", start_date=\"20140101\", end_date=\"20241231\",\n", - " fields=\"ts_code,end_date,roe,roa\"\n", - ")\n", - "temp_df = temp_df[temp_df[\"end_date\"].str.endswith(\"1231\")]\n", - "# temp_df[\"end_date\"] = temp_df[\"end_date\"].str[:4]\n", - "# temp_df = temp_df.drop_duplicates(subset=[\"end_date\"], keep=\"last\")\n", - "temp_df" - ], - "id": "b220252765677c76", - "outputs": [], - "execution_count": null + "execution_count": 114 } ], "metadata": {