Skip to main content

A library to load data from the Trackinsight API

Project description

trackinsight-data-python

Installation

uv init
uv add trackinsight-data-python
uv add dotenv # needed to load environment variables
uv add polars # needed to manipulate dataframes

Setup the environment variables

Some variables are read from the environment. We recommend managing environment variables in a local .env file and loading it via the dotenv library

# .env
TRACK_API_KEY=YOUR_KEY_HERE # your API key
TRACK_API_DL_WORKERS=10 # number of parallel threads when downloading data
TRACK_API_STORAGE=trackinsight_data # local folder to use when storing data on disk
TRACK_API_VERIFY_CERT=True # Set to False if certificate validation is not possible in you environment

Usage

# main.py
import polars as pl
import trackinsight_data_python as API
from dotenv import load_dotenv
load_dotenv(override=True)

ccy='usd'
metadata= API.getMetadata()
stamp = metadata["reportsAsOf"][ccy][-1] # get latest stamp for reports

reports = API.getReports(ccy=ccy,stamp=stamp) # reports is a Polars DataFrame, you can use .to_pandas() to convert it to a Pandas DataFrame

nuclear_etfs = reports.filter(pl.col('class_theme').list.join(';') =='Nuclear Energy')

ids = nuclear_etfs["share_id"].to_list()

usd_timeseries = API.getTimeseries(ids=ids,start='2024-01-01',end=None,ccy=ccy)

holdings = API.getHoldings(ids=ids)
uv run python main.py

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

trackinsight_data_python-0.1.4.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

trackinsight_data_python-0.1.4-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file trackinsight_data_python-0.1.4.tar.gz.

File metadata

File hashes

Hashes for trackinsight_data_python-0.1.4.tar.gz
Algorithm Hash digest
SHA256 de3b70dd59e488057738027c8a22894e8d784de213f4b59ae21fa22fb35d0eb4
MD5 27ec127e341051a971908c6257346910
BLAKE2b-256 73e72e4ed20e35430fec61b77e8383f936001febcd81047e68c9deba651006c1

See more details on using hashes here.

File details

Details for the file trackinsight_data_python-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for trackinsight_data_python-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5413532a074d3de0269a31f305f6dc344fdb798649d8effc229d8bff9eb98e05
MD5 ef45f6b86cfd30b7426c93500bbd972e
BLAKE2b-256 f707d6f87d7f1c469c5a8c8e9a9e069232dd5041b89fb824878b4a19a45d9cd8

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