Skip to main content

A lightweight package for managing local finlab data cache with versioning and time-context features

Project description

finlab-guard

A lightweight package for managing a local finlab data cache with versioning and time-context features.

Python versions Windows Linux macOS License: MIT Tests

Installation

pip install finlab-guard

Usage examples

Two short examples showing the most common flows.

1) Monkey-patch finlab.data.get (installing FinlabGuard)

This project can monkey-patch finlab.data.get so reads go through the guarded cache. Example:

import finlab
from finlab_guard import FinlabGuard

# Create a FinlabGuard instance and install the monkey-patch
guard = FinlabGuard()
guard.install_patch()

# Use finlab.data.get as normal; FinlabGuard will intercept and use cache
result = finlab.data.get('price:收盤價')

# When done, remove the monkey-patch
guard.remove_patch()

2) Set a time context and get historical data

FinlabGuard supports a time context so you can query data "as-of" a past time.

import finlab
from finlab_guard import FinlabGuard
from datetime import datetime, timedelta
guard = FinlabGuard()
guard.install_patch()

# Set time context to 7 days ago
query_time = datetime.now() - timedelta(days=7)
guard.set_time_context(query_time)

# Now call finlab.data.get normally; the guard will return historical data
result = finlab.data.get('price:收盤價')

# Clear the time context and remove the monkey-patch when done
guard.clear_time_context()
guard.remove_patch()

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

finlab_guard-0.1.0.tar.gz (164.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

finlab_guard-0.1.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file finlab_guard-0.1.0.tar.gz.

File metadata

  • Download URL: finlab_guard-0.1.0.tar.gz
  • Upload date:
  • Size: 164.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for finlab_guard-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a5ce52d64c079b43c3d298235b9bb5886c73c61242320a382605e9c96dc0d9f6
MD5 e61a40102df2a4304112e5e4c9964b12
BLAKE2b-256 d499f2663b26cae15fce1f4c91682bbbb28389dae7e5d6d7faeb1e9515dc0581

See more details on using hashes here.

File details

Details for the file finlab_guard-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: finlab_guard-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for finlab_guard-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f97795648b1e9fabd04a8eb0dd352262ad7a6c1ed73134d587dba1852576f28
MD5 ce2205ddeaf7e668014abf1bb3096923
BLAKE2b-256 ef2ed3905a90e6602cc89a220ec3666a577f2e1ec161984a49064ec868baa95a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page