Download stock data and perform data analisys
Project description
jing
This is a python library, used for download stock data and perform data analysis.
Installation
pip install jing
All required dependencies (requests, pandas, baostock, yfinance, akshare, pyarrow) will be installed automatically.
Usage
Only 2 classes are exported.
downloader D
- Function: download the data from internet to local file system
- Parameter:
_market(str): us, cn, hk, default is us
- Return Value: No return value
sample code
import jing
# US stock via Yahoo Finance
d = jing.D('us')
d.download('AAPL')
# CN stock via BaoStock (default source for CN)
d = jing.D('cn')
d.download('sz.000807')
# HK stock via AkShare
d = jing.D('hk')
d.download('00700')
Data layout
The project now uses a source-first layout under data/:
data/
raw/
yahoo/us/
baostock/cn/
akshare/cn/
akshare/hk/
binance/bn/
list/
parquet/
duckdb/
Examples:
- US Yahoo CSV:
data/raw/yahoo/us/AAPL.csv - CN BaoStock CSV:
data/raw/baostock/cn/sh.601088.csv - HK AkShare CSV:
data/raw/akshare/hk/00700.csv - list files:
data/raw/list/us.txt
Configuration
Data directory
Priority (highest first):
-
Function call — programmatic override
from jing.data_paths import set_data_root set_data_root('/custom/data/path')
-
Environment variable
export JING_DATA=/custom/data/path
-
Default —
~/data/jing
Cache
jing caches fetched stock data as Parquet files to speed up repeated analysis.
- Cache dir:
~/.cache/jing/data(override withJING_CACHEenv var) - Cache key:
market_source_code_date.parquet
The date in the cache key is the analysis date you pass (e.g. _date='2024-01-01'). If no date is passed, today's date is used. This ensures cached data is scoped to the specific date filter you requested.
Why Parquet?
- Fast reads — columnar format, much faster than CSV for large DataFrames
- Small size — binary + compression (~45% smaller than CSV in our tests)
- Preserves schema — dates, floats, and dtypes survive round-trip without re-parsing
- Pandas-native —
pd.read_parquet()/df.to_parquet()with no extra code
Trade-off: requires pyarrow dependency. For repeated stock data reads the speedup is worth it.
Skip cache
y = jing.Y('sh.600519', _date='2024-01-01', _market='cn', skip_cache=True)
Clear cache
from jing.data_center import DataCenter
dc = DataCenter('cn', 'baostock')
dc.clear_cache() # clear all
dc.clear_cache(code='sh.600519') # clear specific stock
dc.clear_cache(code='sh.600519', date='2024-01-01') # clear specific entry
Release to PyPI
-
Bump the version in
pyproject.toml:version = "0.3.1"
-
Build the distribution packages:
python -m build
-
Upload to PyPI:
python -m twine upload dist/*
You will need a PyPI account and API token. Configure twine once with
python -m twine upload --repository testpypi dist/*to test first if desired.
Project details
Release history Release notifications | RSS feed
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 jing-0.3.2.tar.gz.
File metadata
- Download URL: jing-0.3.2.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7fb550c77670cdd6be69e352c34ce6afd58dab91037ccc6a4fbb7e3db0de2d3
|
|
| MD5 |
a123b81a8103dc25d69b48ffeba31dcb
|
|
| BLAKE2b-256 |
a7e65a0c9a7cd24298ac83a1a641350437df4fc5a033f85d4b0c862d494de374
|
File details
Details for the file jing-0.3.2-py3-none-any.whl.
File metadata
- Download URL: jing-0.3.2-py3-none-any.whl
- Upload date:
- Size: 29.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
113dfeb688b8420c9dcb4a8b00fd96b1360853a7516bd0c37e4425dca43d758e
|
|
| MD5 |
fbc4ae93d817c54385dba2c5c0933551
|
|
| BLAKE2b-256 |
f34c1358f7eb6d0a8eeb86e6d2b714b3a76fd69cba6d58da484eca16265074a0
|