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.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pytlx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d8178b984d9bca3194ab230cf65ca972f010cc69ac4136df209322d72d75d341
MD5 ba92a3519744fd3250507c64bcc4347b
BLAKE2b-256 dfbe79d0ba40a1468afc9c8f8b456f05423aae16a26a08564a18766352ba2b07

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pytlx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0fc46429399c067378c74691a14cb82d81ead21f6d7b31a8fafc36196cb9799
MD5 347855eccbd6ab3930a05ff4a1776128
BLAKE2b-256 aaea30ef0f414af8457e34711c3beb9d4da2586c73b004e5d805d28c29cbba02

See more details on using hashes here.

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