Skip to main content

jing

jing downloads and organizes stock market data. The examples below use China A-share stocks with BaoStock.

Install

pip install jing

Download CN data

BaoStock is the default data source for CN. Stock codes must include an exchange prefix, such as sh. or sz..

import jing

d = jing.D("cn")
d.download("sz.000807")  # Download one stock
d.download()             # Download the stocks in the default list

Batch downloads use ~/data/jing/list/cn_baostock.txt by default. On first use, jing copies the bundled list there; edit this copy to maintain your stock list.

File locations

The default data directory is ~/data/jing:

~/data/jing/
├── list/cn_baostock.txt
└── raw/baostock/cn/sz.000807.csv

Set JING_DATA to use another directory:

export JING_DATA=/data/stocks

Or set the data directory from Python:

from jing.data_paths import set_data_root

set_data_root("/data/stocks")

The stock list and CSV files will then be stored under /data/stocks/list/ and /data/stocks/raw/baostock/cn/.

Run daily on a server

deploy/ holds the cron entry point. It is a deployment script, not part of the jing package: jing only downloads and uploads, deploy/daily.py schedules that.

sudo mkdir -p /opt/jing /data/jing /var/log/jing
sudo git clone <this repo> /opt/jing
cd /opt/jing && python3 -m venv .venv && .venv/bin/pip install -e .

sudo install -m 600 deploy/env.example /etc/jing/env
sudo $EDITOR /etc/jing/env          # fill in JING_COS_SECRET_ID / _KEY

.venv/bin/python deploy/daily.py us   # smoke test on one market
crontab deploy/jing.cron              # weekdays 20:00 Asia/Shanghai

run_daily.sh loads /etc/jing/env (cron has no login shell), takes a flock so a slow run cannot overlap the next one, and writes /var/log/jing/<date>.log (kept 14 days).

Notes:

  • Interrupted runs resume. Each stock's CSV is the ledger, so the next run only downloads what is missing. Running out of the time budget is a normal outcome, not a failure.
  • Concurrency: JING_MAX_WORKERS overrides the built-in worker count (3 for BaoStock, 10 otherwise). The server sets it to 1 — one request at a time from one IP is the cheapest insurance against being rate limited. D.download(max_workers=N) overrides it per call.
  • akshare timeouts: akshare's requests carry no timeout, so jing patches requests.sessions.Session.request to inject one (JING_HTTP_TIMEOUT, default 30s, 0 disables). socket.setdefaulttimeout() cannot do this — urllib3 passes its own None down to sock.settimeout(), overriding it.
  • cn uses BaoStock only. cn_ak (AKShare) covers the same A-shares; running both every day doubles the request load for no new data.

Metadata

Release files for jing 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jing 0.4.0
File Size Uploaded
jing-0.4.0.tar.gz 79.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jing 0.4.0
File Interpreter ABI Platform
jing-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 161.1 kB

Release files / jing-0.4.0.tar.gz

Download URL jing-0.4.0.tar.gz
Size 79.9 kB
Tags Source
SHA-256 checksum
How to use checksums
11bb42c6b5b8fe7fc430d1e7bae26cb113ea74a05c31fa3f0697babac58e9dd5
BLAKE2b-256 checksum
How to use checksums
361d5276972c51985ed85f34c15c2d543d53fe8d3d70938bccf97f961e7c8944
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.8

Release files / jing-0.4.0-py3-none-any.whl

Download URL jing-0.4.0-py3-none-any.whl
Size 81.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d80baac564a3d34d0743375c878ce1c41500b6f7426d9a5085abb543253a0e0
BLAKE2b-256 checksum
How to use checksums
9503975d3e62b8981718314e712e3afd37f66b5ccd3c3ab1c9278deb74ba42ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.8

Release history Release notifications | RSS feed

0.6.1

2 release files

0.6.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

This release

0.4.0 This release

2 release files

0.3.15

2 release files

0.3.14

2 release files

0.3.13

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page