r/learnpython • • 8d ago

Made a small pandas library for Malaysian stock data, would love feedbacks

It's called bursakit.

It pulls Bursa Malaysia stock prices and dividends, plusBank Negara's interest rate and exchange rates, straight into pandas.

import bursakit as bk

df = bk.prices("MAYBANK", start="2024-01-01")

It caches everything in SQLite, so the second call is instant.

Built it with some AI help, but I've gone through all the code myself.

Mainly wondering:

- Is the structure overkill for something this small?

- Does the cache logic make sense?

Heads up: the stock data comes from yfinance, so it's unofficial and for personal use only.

https://github.com/MaosterM/bursakit

0 Upvotes

5 comments sorted by

2

u/Free-Good9203 7d ago

Nice clean project for a real local niche. On your two questions:

  1. Structure: keeping the public API flat (2-3 top-level functions) is great for a small library. I wouldn't add extra abstraction layers until you actually need a second data provider—splitting fetching, parsing, and caching into separate modules is already the right boundary.
  2. SQLite cache: much better choice than loose CSV or pickle files. Two small things worth adding if you haven't already: store a UTC fetched_at timestamp with separate TTLs per source (daily BNM rates vs stock prices/dividends expire differently), and enable WAL mode plus a busy_timeout so notebooks or parallel scripts don't hit database locked errors.

2

u/MostimaSimp 7d ago

Thanks, this is really useful! Most of it's already in there:

The fetched_at is in UTC epoch time. Each data type has an individual TTL – for spot data it is 15 mins, for FX/OPR it is 6 hours and for dividends 24 hours. The lock timeout is 30 seconds.

FX currently has 2 sources (data.gov.my and BNM as a back-up) hence the need for a router.

WAL mode is the one absent but will be incorporated in forthcoming release.

2

u/Free-Good9203 7d ago

Nice, that's way cleaner than most early libraries! Having data.gov.my with BNM as automatic fallback totally justifies the router. I also took a quick peek at the repo—pairing recorded HTTP replay fixtures with a nightly live-source check is a really solid engineering touch. Looking forward to seeing it grow!