Skip to main content

Download leveraged token data from TLX Fi.

Project description

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.

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

pytlx-0.1.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

pytlx-0.1.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file pytlx-0.1.1.tar.gz.

File metadata

  • Download URL: pytlx-0.1.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pytlx-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1792f5e024042e3f3c9e9c4b8177d4359185f9aada57a11c6bef8ce47ca1856b
MD5 1c22eca4d1a39f95c39320df40a34895
BLAKE2b-256 97a3deff5be322d383df57d65794f87b94d260c5e709db71306ba3880c55e024

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytlx-0.1.1.tar.gz:

Publisher: python-publish.yml on dhruvan2006/pytlx

Attestations:

File details

Details for the file pytlx-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pytlx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pytlx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c0b108b162326bcca03dd488ef1ee884f157f5db3949afcbf04530726a9ee027
MD5 403e11cf59c962660fcff037679e61df
BLAKE2b-256 09d2ab7ae326e8c79089bc955e2b7425d533cf74dbb5dae82621c4583b623838

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytlx-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on dhruvan2006/pytlx

Attestations:

Supported by

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