Skip to main content

PyTLX

Download leveraged token data from TLX Fi

codecov PyPI Version License

Installation

Install PyTLX using pip:

pip install pytlx

Quick Start

Example Usage

import pytlx as tlx

# Initialize a token by its ticker
token = tlx.Token("BTC5L")

# Fetch historical data for the token
data = token.history()
print(data)

API Documentation

Token Class

Description

The Token class provides a Python interface for interacting with the TLX platform, fetching token data, contract information, and historical prices.


Initialization

Token(ticker: str)

  • Parameters:
    • ticker (str): The token's identifier (e.g., BTC5L).
  • Description: Initializes the Token object for fetching leveraged token data.

Methods

get_contract_addresses() -> List[Dict[str, Any]]

  • Description: Fetches all leveraged token contract addresses and related metadata from the smart contract on the Optimism blockchain.
  • Returns: A list of dictionaries containing contract address data:
    • addr (str): Contract address.
    • symbol (str): Token symbol.
    • Other metadata fields as provided by the contract.

get_contract_address() -> Optional[str]

  • Description: Retrieves the specific contract address associated with the initialized token's ticker.
  • Returns:
    • str: Contract address if the ticker is found.
    • None: If the ticker does not exist in the metadata.

history(granularity: str = "1d", start: str = "1900-01-01") -> pd.DataFrame

  • Description: Fetches historical price data for the token using the TLX API.

  • Parameters:

    • granularity (str): Data interval (e.g., 1d, 6h).
    • start (str): Start date in YYYY-MM-DD format (default: "1900-01-01").
  • Returns: A pandas.DataFrame with the following columns:

    • Date: The timestamp of the data point (index).
    • Price: The historical price of the token.
  • Raises:

    • ValueError: If the ticker is invalid.
    • HTTPError: If the API call fails.

get_contract_addresses() -> List[Dict[str, Any]]

  • Description: Retrieves all contract addresses and metadata for leveraged tokens by interacting with the Optimism smart contract.
  • Returns: A list of dictionaries with details:
    • addr (str): Token contract address.
    • symbol (str): Token ticker.
    • Additional metadata like totalSupply, targetLeverage, and isActive.

Metadata

Release files for pytlx 0.1.1

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

Source distribution (sdist)

Source distribution for pytlx 0.1.1
File Size Uploaded
pytlx-0.1.1.tar.gz 6.2 kB Details

Built distribution (wheel)

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

Total release size: 11.9 kB

Release files / pytlx-0.1.1.tar.gz

Download URL pytlx-0.1.1.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1792f5e024042e3f3c9e9c4b8177d4359185f9aada57a11c6bef8ce47ca1856b
BLAKE2b-256 checksum
How to use checksums
97a3deff5be322d383df57d65794f87b94d260c5e709db71306ba3880c55e024
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2024.

Transparency log

Release files / pytlx-0.1.1-py3-none-any.whl

Download URL pytlx-0.1.1-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0b108b162326bcca03dd488ef1ee884f157f5db3949afcbf04530726a9ee027
BLAKE2b-256 checksum
How to use checksums
09d2ab7ae326e8c79089bc955e2b7425d533cf74dbb5dae82621c4583b623838
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

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