pytlx


Namepytlx JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryDownload leveraged token data from TLX Fi.
upload_time2024-11-27 20:11:30
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords leverage toros crypto
VCS
bugtrack_url
requirements aiohappyeyeballs aiohttp aiosignal annotated-types attrs bitarray certifi charset-normalizer ckzg cytoolz eth-account eth-hash eth-keyfile eth-keys eth-rlp eth-typing eth-utils eth_abi frozenlist hexbytes idna multidict numpy pandas parsimonious propcache pycryptodome pydantic pydantic_core python-dateutil pytz pyunormalize regex requests rlp six toolz types-requests typing_extensions tzdata urllib3 web3 websockets yarl
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyTLX

Download leveraged token data from [TLX Fi](https://tlx.fi)

[![codecov](https://codecov.io/gh/dhruvan2006/pytlx/graph/badge.svg?token=GVWV3STI3C)](https://codecov.io/gh/dhruvan2006/pytlx)
[![PyPI Version](https://img.shields.io/pypi/v/pytlx)](https://github.com/dhruvan2006/pytlx)
[![License](https://img.shields.io/github/license/dhruvan2006/pytlx)](https://github.com/dhruvan2006/pytlx)

## Installation

Install PyTLX using pip:
```bash
pip install pytlx
```

## Quick Start

### Example Usage
```python
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`.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pytlx",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "leverage, toros, crypto",
    "author": null,
    "author_email": "Dhruvan Gnanadhandayuthapani <dhruvan2006@gmail.com>, Mohammed Faheem <mohdfaheem.1205@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/97/a3/deff5be322d383df57d65794f87b94d260c5e709db71306ba3880c55e024/pytlx-0.1.1.tar.gz",
    "platform": null,
    "description": "# PyTLX\n\nDownload leveraged token data from [TLX Fi](https://tlx.fi)\n\n[![codecov](https://codecov.io/gh/dhruvan2006/pytlx/graph/badge.svg?token=GVWV3STI3C)](https://codecov.io/gh/dhruvan2006/pytlx)\n[![PyPI Version](https://img.shields.io/pypi/v/pytlx)](https://github.com/dhruvan2006/pytlx)\n[![License](https://img.shields.io/github/license/dhruvan2006/pytlx)](https://github.com/dhruvan2006/pytlx)\n\n## Installation\n\nInstall PyTLX using pip:\n```bash\npip install pytlx\n```\n\n## Quick Start\n\n### Example Usage\n```python\nimport pytlx as tlx\n\n# Initialize a token by its ticker\ntoken = tlx.Token(\"BTC5L\")\n\n# Fetch historical data for the token\ndata = token.history()\nprint(data)\n```\n\n# API Documentation\n\n## Token Class\n\n### Description\nThe `Token` class provides a Python interface for interacting with the TLX platform, fetching token data, contract information, and historical prices.\n\n---\n\n### Initialization\n\n#### `Token(ticker: str)`\n- **Parameters**:\n  - `ticker` (str): The token's identifier (e.g., `BTC5L`).\n- **Description**:\n  Initializes the `Token` object for fetching leveraged token data.\n\n---\n\n### Methods\n\n#### `get_contract_addresses() -> List[Dict[str, Any]]`\n- **Description**:\n  Fetches all leveraged token contract addresses and related metadata from the smart contract on the Optimism blockchain.\n- **Returns**:\n  A list of dictionaries containing contract address data:\n  - `addr` (str): Contract address.\n  - `symbol` (str): Token symbol.\n  - Other metadata fields as provided by the contract.\n\n---\n\n#### `get_contract_address() -> Optional[str]`\n- **Description**:\n  Retrieves the specific contract address associated with the initialized token's ticker.\n- **Returns**:\n  - `str`: Contract address if the ticker is found.\n  - `None`: If the ticker does not exist in the metadata.\n\n---\n\n#### `history(granularity: str = \"1d\", start: str = \"1900-01-01\") -> pd.DataFrame`\n- **Description**:\n  Fetches historical price data for the token using the TLX API.\n- **Parameters**:\n  - `granularity` (str): Data interval (e.g., `1d`, `6h`).\n  - `start` (str): Start date in `YYYY-MM-DD` format (default: `\"1900-01-01\"`).\n- **Returns**:\n  A `pandas.DataFrame` with the following columns:\n  - `Date`: The timestamp of the data point (index).\n  - `Price`: The historical price of the token.\n\n- **Raises**:\n  - `ValueError`: If the ticker is invalid.\n  - `HTTPError`: If the API call fails.\n\n---\n\n#### `get_contract_addresses() -> List[Dict[str, Any]]`\n- **Description**:\n  Retrieves all contract addresses and metadata for leveraged tokens by interacting with the Optimism smart contract.\n- **Returns**:\n  A list of dictionaries with details:\n  - `addr` (str): Token contract address.\n  - `symbol` (str): Token ticker.\n  - Additional metadata like `totalSupply`, `targetLeverage`, and `isActive`.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Download leveraged token data from TLX Fi.",
    "version": "0.1.1",
    "project_urls": {
        "source": "https://github.com/dhruvan2006/pytlx"
    },
    "split_keywords": [
        "leverage",
        " toros",
        " crypto"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "09d2ab7ae326e8c79089bc955e2b7425d533cf74dbb5dae82621c4583b623838",
                "md5": "403e11cf59c962660fcff037679e61df",
                "sha256": "c0b108b162326bcca03dd488ef1ee884f157f5db3949afcbf04530726a9ee027"
            },
            "downloads": -1,
            "filename": "pytlx-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "403e11cf59c962660fcff037679e61df",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5759,
            "upload_time": "2024-11-27T20:11:29",
            "upload_time_iso_8601": "2024-11-27T20:11:29.211891Z",
            "url": "https://files.pythonhosted.org/packages/09/d2/ab7ae326e8c79089bc955e2b7425d533cf74dbb5dae82621c4583b623838/pytlx-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97a3deff5be322d383df57d65794f87b94d260c5e709db71306ba3880c55e024",
                "md5": "1c22eca4d1a39f95c39320df40a34895",
                "sha256": "1792f5e024042e3f3c9e9c4b8177d4359185f9aada57a11c6bef8ce47ca1856b"
            },
            "downloads": -1,
            "filename": "pytlx-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1c22eca4d1a39f95c39320df40a34895",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6152,
            "upload_time": "2024-11-27T20:11:30",
            "upload_time_iso_8601": "2024-11-27T20:11:30.351880Z",
            "url": "https://files.pythonhosted.org/packages/97/a3/deff5be322d383df57d65794f87b94d260c5e709db71306ba3880c55e024/pytlx-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-27 20:11:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dhruvan2006",
    "github_project": "pytlx",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "aiohappyeyeballs",
            "specs": [
                [
                    "==",
                    "2.4.3"
                ]
            ]
        },
        {
            "name": "aiohttp",
            "specs": [
                [
                    "==",
                    "3.11.7"
                ]
            ]
        },
        {
            "name": "aiosignal",
            "specs": [
                [
                    "==",
                    "1.3.1"
                ]
            ]
        },
        {
            "name": "annotated-types",
            "specs": [
                [
                    "==",
                    "0.7.0"
                ]
            ]
        },
        {
            "name": "attrs",
            "specs": [
                [
                    "==",
                    "24.2.0"
                ]
            ]
        },
        {
            "name": "bitarray",
            "specs": [
                [
                    "==",
                    "3.0.0"
                ]
            ]
        },
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2024.8.30"
                ]
            ]
        },
        {
            "name": "charset-normalizer",
            "specs": [
                [
                    "==",
                    "3.4.0"
                ]
            ]
        },
        {
            "name": "ckzg",
            "specs": [
                [
                    "==",
                    "2.0.1"
                ]
            ]
        },
        {
            "name": "cytoolz",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "eth-account",
            "specs": [
                [
                    "==",
                    "0.13.4"
                ]
            ]
        },
        {
            "name": "eth-hash",
            "specs": [
                [
                    "==",
                    "0.7.0"
                ]
            ]
        },
        {
            "name": "eth-keyfile",
            "specs": [
                [
                    "==",
                    "0.8.1"
                ]
            ]
        },
        {
            "name": "eth-keys",
            "specs": [
                [
                    "==",
                    "0.6.0"
                ]
            ]
        },
        {
            "name": "eth-rlp",
            "specs": [
                [
                    "==",
                    "2.1.0"
                ]
            ]
        },
        {
            "name": "eth-typing",
            "specs": [
                [
                    "==",
                    "5.0.1"
                ]
            ]
        },
        {
            "name": "eth-utils",
            "specs": [
                [
                    "==",
                    "5.1.0"
                ]
            ]
        },
        {
            "name": "eth_abi",
            "specs": [
                [
                    "==",
                    "5.1.0"
                ]
            ]
        },
        {
            "name": "frozenlist",
            "specs": [
                [
                    "==",
                    "1.5.0"
                ]
            ]
        },
        {
            "name": "hexbytes",
            "specs": [
                [
                    "==",
                    "1.2.1"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.10"
                ]
            ]
        },
        {
            "name": "multidict",
            "specs": [
                [
                    "==",
                    "6.1.0"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "2.1.3"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    "==",
                    "2.2.3"
                ]
            ]
        },
        {
            "name": "parsimonious",
            "specs": [
                [
                    "==",
                    "0.10.0"
                ]
            ]
        },
        {
            "name": "propcache",
            "specs": [
                [
                    "==",
                    "0.2.0"
                ]
            ]
        },
        {
            "name": "pycryptodome",
            "specs": [
                [
                    "==",
                    "3.21.0"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    "==",
                    "2.10.2"
                ]
            ]
        },
        {
            "name": "pydantic_core",
            "specs": [
                [
                    "==",
                    "2.27.1"
                ]
            ]
        },
        {
            "name": "python-dateutil",
            "specs": [
                [
                    "==",
                    "2.9.0.post0"
                ]
            ]
        },
        {
            "name": "pytz",
            "specs": [
                [
                    "==",
                    "2024.2"
                ]
            ]
        },
        {
            "name": "pyunormalize",
            "specs": [
                [
                    "==",
                    "16.0.0"
                ]
            ]
        },
        {
            "name": "regex",
            "specs": [
                [
                    "==",
                    "2024.11.6"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.32.3"
                ]
            ]
        },
        {
            "name": "rlp",
            "specs": [
                [
                    "==",
                    "4.0.1"
                ]
            ]
        },
        {
            "name": "six",
            "specs": [
                [
                    "==",
                    "1.16.0"
                ]
            ]
        },
        {
            "name": "toolz",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "types-requests",
            "specs": [
                [
                    "==",
                    "2.32.0.20241016"
                ]
            ]
        },
        {
            "name": "typing_extensions",
            "specs": [
                [
                    "==",
                    "4.12.2"
                ]
            ]
        },
        {
            "name": "tzdata",
            "specs": [
                [
                    "==",
                    "2024.2"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "==",
                    "2.2.3"
                ]
            ]
        },
        {
            "name": "web3",
            "specs": [
                [
                    "==",
                    "7.6.0"
                ]
            ]
        },
        {
            "name": "websockets",
            "specs": [
                [
                    "==",
                    "13.1"
                ]
            ]
        },
        {
            "name": "yarl",
            "specs": [
                [
                    "==",
                    "1.18.0"
                ]
            ]
        }
    ],
    "lcname": "pytlx"
}
        
Elapsed time: 1.05612s