Python SDK for the CANSLIM Yanxiang cloud API
Project description
canslim-yanxiang
canslim-yanxiang is the lightweight Python SDK for the CANSLIM cloud service.
It uses an API key and HTTPS to call /api/sdk/v1. Database credentials,
membership checks, indicator calculations, and stock screening stay on the
server; an SDK user never connects to the production database directly.
Version 0.1.0 includes L1 market and financial queries, L2-Class1 stock analysis, L2-Class2 industry analysis, L2-Class3 CANSLIM card indicators, and L2-Class4 rule-based stock screening.
Install
Install the production package from PyPI:
python -m pip install --upgrade canslim-yanxiang
Verify the installation:
python -c "import canslim_yanxiang as cs; print(cs.__version__)"
On macOS (Intel or Apple Silicon), use Python 3.10 or newer:
python3 -m pip install --upgrade canslim-yanxiang
python3 -c "import canslim_yanxiang as cs; print(cs.__version__)"
The SDK is platform-independent and does not include B-XTrender.
For repository development:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e .
Configure
Set the cloud endpoint and API key in the current PowerShell session:
$env:CANSLIM_API_BASE_URL = "https://your-domain.example/api/sdk/v1"
$env:CANSLIM_API_KEY = "csk_live_xxx"
Configuration can also be supplied in Python:
import canslim_yanxiang as cs
cs.configure(
base_url="https://your-domain.example/api/sdk/v1",
api_key="csk_live_xxx",
)
The API key is never written into the package. The server validates membership level and account expiry for every call.
L1 Queries
import canslim_yanxiang as cs
stocks = cs.stock_search("600519")
info = cs.stock_basic_info("600519")
latest = cs.stock_price_latest("600519")
prices = cs.stock_price_history("600519", start="2025-01-01")
financials = cs.stock_financials("600519", period="quarterly", limit=20)
List endpoints return pandas DataFrame objects by default and single-object
endpoints return dictionaries. Pass raw=True to receive the complete response
envelope.
L2 Analysis
L2-Class1 stock analysis:
current = cs.eps_current_quarter_score("600519")
eps = cs.eps_growth_history("600519", mode="quarter")
stock_score = cs.stock_rps_score("600519") # defaults to rps_240
industry_score = cs.industry_rps_score("600519") # defaults to rps_120
industry = cs.stock_industry("600519")
L2-Class2 industry analysis:
industries = cs.industry_list()
basic = cs.industry_basic_info("340500")
members = cs.industry_constituents("340500")
fundamental = cs.industry_fundamental_analysis(top_n=20)
strength = cs.industry_strength_history("340500")
member_rps = cs.industry_constituent_rps_ranking("340500")
L2-Class3 CANSLIM card analysis:
c = cs.c_card("600519", report_date="2026-03-31")
a = cs.a_card("600519", report_date="2026-03-31")
n = cs.n_card("600519")
s = cs.s_card("600519", report_date="2026-03-31")
l = cs.l_card("600519")
i = cs.i_card("600519", report_date="2026-03-31")
m = cs.m_card()
Atomic indicators are also callable individually and can be registered in
L2-Class4 screening rules. See the contracts under docs/ for stable
parameters and response fields.
Six-Rule Screen
Run the frozen C/A/N/S/L/I rule set after installation:
canslim-screen-six-rules
The default intersection mode requires all six groups. To return stocks that
match at least five groups:
canslim-screen-six-rules --combine at_least --min-matched-rules 5
Dates and output location can be fixed explicitly:
canslim-screen-six-rules `
--report-date 2026-03-31 `
--as-of-date 2026-07-17 `
--output .\results\six_rules.csv
The command writes a CSV and a matching .meta.json file. Because the current
screening API is synchronous, the percentage shown while waiting is an elapsed
time estimate. Final counts and results always come from the cloud response.
Repository Boundaries
- This repository contains the installable SDK and archived backtest CSV data.
- The production backend owns API keys, permissions, quotas, logs, database access, and job execution.
- The offline project owns heavy recomputation, historical backfills, and publishable data generation.
backtest_csv/is not included in the SDK wheel. It is deployed separately as read-only cloud data when required by the backtest service.
See SDK framework and cloud deployment for the complete architecture.
Development Verification
python -m unittest discover -s tests -v
python -m build
python -m twine check dist/*
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file canslim_yanxiang-0.1.0.tar.gz.
File metadata
- Download URL: canslim_yanxiang-0.1.0.tar.gz
- Upload date:
- Size: 26.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e52e0cc2c0ae2e1ae54c8c747674bbedeefbfbfe3c19d248e62cd80305ece96
|
|
| MD5 |
de3432cfd8f1b8b3896e950c1033da8f
|
|
| BLAKE2b-256 |
c6224d2bfd812796ecd6f89aa52f28b5ab841bdfc83f8c5a79f58213cd1500b6
|
Provenance
The following attestation bundles were made for canslim_yanxiang-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on johnhowl/canslim_lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
canslim_yanxiang-0.1.0.tar.gz -
Subject digest:
0e52e0cc2c0ae2e1ae54c8c747674bbedeefbfbfe3c19d248e62cd80305ece96 - Sigstore transparency entry: 2194366887
- Sigstore integration time:
-
Permalink:
johnhowl/canslim_lib@1c548987a6f28bf5e957c7f620ef071a7877f4ee -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/johnhowl
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@1c548987a6f28bf5e957c7f620ef071a7877f4ee -
Trigger Event:
push
-
Statement type:
File details
Details for the file canslim_yanxiang-0.1.0-py3-none-any.whl.
File metadata
- Download URL: canslim_yanxiang-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b03a24315f783504297f0a5e05ed2850730c84e433c817bdc5efb925569f1be8
|
|
| MD5 |
417b1c5b0062c48bc177732e8f514556
|
|
| BLAKE2b-256 |
6d81953f1ba63bd70608c35365c9865a99209e8f2a1e409c588e18974fe4b958
|
Provenance
The following attestation bundles were made for canslim_yanxiang-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on johnhowl/canslim_lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
canslim_yanxiang-0.1.0-py3-none-any.whl -
Subject digest:
b03a24315f783504297f0a5e05ed2850730c84e433c817bdc5efb925569f1be8 - Sigstore transparency entry: 2194367081
- Sigstore integration time:
-
Permalink:
johnhowl/canslim_lib@1c548987a6f28bf5e957c7f620ef071a7877f4ee -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/johnhowl
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@1c548987a6f28bf5e957c7f620ef071a7877f4ee -
Trigger Event:
push
-
Statement type: