transpose-defi-sdk


Nametranspose-defi-sdk JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/TransposeData/transpose-defi-sdk
SummaryThe Transpose DeFi SDK is a simple Python package for performing multi-chain DeFi analysis using the real-time Transpose SQL API.
upload_time2022-12-12 21:53:33
maintainer
docs_urlNone
authorAlex Langshur (alangshur)
requires_python
licenseMIT
keywords web3 defi ethereum transpose prices ohlc data analysis blockchain polygon
VCS
bugtrack_url
requirements pandas pip-chill plotly web3
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # transpose-defi-sdk

The Transpose DeFi SDK is a simple Python package for performing multi-chain DeFi analysis using the real-time Transpose SQL API. At the moment, the only supported functionality is the ability to download or chart OHLC prices for any token on Ethereum, Goerli, and Polygon.

The underlying price data is sourced for every token on the supported networks, regardless of centralized listing status, volume, or liquidity. This data is derived from DEX data across over 24 different DEXs, including Uniswap, Sushiswap, Balancer, and Curve, and nearly 200k DEX pools. The token prices are normalized to accurate USD prices using Chainlink price feeds. The full list of supported DEXs can be found in the [docs](https://docs.transpose.io/sql/tables/protocol-layer/dex-swaps/smoothyswap_dex_swaps/).

## Retrieving an API key

To use the SDK, you will need an API key for Transpose. You can sign up for a free API key by visting the [Transpose App](https://app.transpose.io). If you have any questions on getting started, feature requests, or contributing to the SDK, please reach out to us on [Discord](http://discord.gg/transpose).

## Installation

To install the package, run the following command in your Python environment:

```bash
pip install transpose-defi-sdk
```

The SDK requires Python 3.6 or higher and has only 4 dependencies:

- `pandas`
- `pip-chill`
- `web3`
- `plotly`

## Getting Started

### Charting OHLC prices

OHLC stands for open-high-low-close and is a common way to represent price data over fixed time intervals. To start charting data, simply import and instantiate the `Chart` class from the SDK and call its `ohlc` method.

```python
from transpose.chart import Chart

# initialize Chart with your API key
chart = Chart(api_key='YOUR API KEY')

# chart OHLC data for a token
chart.ohlc(
    chain='ethereum', 
    token_address='0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', # token address for WETH
    from_timestamp='2021-01-01', 
    to_timestamp='2021-02-01', 
    timeframe='hour'
)
```

The above code will generate a chart of hourly OHLC prices for Wrapped Ether (WETH) during the month of January 2021. The address for WETH can be replaced with any token address on the supported chains.

By default, Plotly will automatically render the chart in your browser. If you would like to save the chart as a HTML file, you can pass the `save_as` parameter to the `ohlc` method:

```python
chart.ohlc(
    chain='ethereum', 
    token_address='0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 
    from_timestamp='2021-01-01', 
    to_timestamp='2021-02-01', 
    timeframe='hour',
    save_as='test.html'
)
```

### Downloading OHLC data

To return the data directly as a Pandas DataFrame from the `ohlc` method rather than charting, you may pass the optional `return_df` parameter:

```python
price_df = chart.ohlc(
    chain='ethereum', 
    token_address='0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 
    from_timestamp='2021-01-01', 
    to_timestamp='2021-02-01', 
    timeframe='hour',
    return_df=True
)
```

The `price_df` DataFrame will contain a timestamp index and four columns for the OHLC prices: `open`, `high`, `low`, and `close`.

### Charting Options

The `ohlc` method accepts a number of optional parameters to customize the chart. The following parameters are available:

- `chain`: The blockchain network to query (`ethereum`, `goerli`, or `polygon`).
- `token_address`: The address of the token to chart (must be a valid 42-character hex addres).
- `from_timestamp`: The start date for the chart (supports common string formats and Unix timestamps).
- `to_timestamp`: The end date for the chart (supports common string formats and Unix timestamps).
- `timeframe`: The time interval to chart (`day`, `hour`, or `minute`).
- `save_as`: The path to save the chart as a HTML file.
- `return_df`: Whether to return the data as a Pandas DataFrame rather than charting.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/TransposeData/transpose-defi-sdk",
    "name": "transpose-defi-sdk",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "web3,defi,ethereum,transpose,prices,ohlc,data,analysis,blockchain,polygon",
    "author": "Alex Langshur (alangshur)",
    "author_email": "alex@transpose.io",
    "download_url": "https://files.pythonhosted.org/packages/52/3e/31c0811863208dd1012157245ba163bd0249f358aff249abeb01c6ed88c4/transpose_defi_sdk-1.0.1.tar.gz",
    "platform": null,
    "description": "# transpose-defi-sdk\n\nThe Transpose DeFi SDK is a simple Python package for performing multi-chain DeFi analysis using the real-time Transpose SQL API. At the moment, the only supported functionality is the ability to download or chart OHLC prices for any token on Ethereum, Goerli, and Polygon.\n\nThe underlying price data is sourced for every token on the supported networks, regardless of centralized listing status, volume, or liquidity. This data is derived from DEX data across over 24 different DEXs, including Uniswap, Sushiswap, Balancer, and Curve, and nearly 200k DEX pools. The token prices are normalized to accurate USD prices using Chainlink price feeds. The full list of supported DEXs can be found in the [docs](https://docs.transpose.io/sql/tables/protocol-layer/dex-swaps/smoothyswap_dex_swaps/).\n\n## Retrieving an API key\n\nTo use the SDK, you will need an API key for Transpose. You can sign up for a free API key by visting the [Transpose App](https://app.transpose.io). If you have any questions on getting started, feature requests, or contributing to the SDK, please reach out to us on [Discord](http://discord.gg/transpose).\n\n## Installation\n\nTo install the package, run the following command in your Python environment:\n\n```bash\npip install transpose-defi-sdk\n```\n\nThe SDK requires Python 3.6 or higher and has only 4 dependencies:\n\n- `pandas`\n- `pip-chill`\n- `web3`\n- `plotly`\n\n## Getting Started\n\n### Charting OHLC prices\n\nOHLC stands for open-high-low-close and is a common way to represent price data over fixed time intervals. To start charting data, simply import and instantiate the `Chart` class from the SDK and call its `ohlc` method.\n\n```python\nfrom transpose.chart import Chart\n\n# initialize Chart with your API key\nchart = Chart(api_key='YOUR API KEY')\n\n# chart OHLC data for a token\nchart.ohlc(\n    chain='ethereum', \n    token_address='0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', # token address for WETH\n    from_timestamp='2021-01-01', \n    to_timestamp='2021-02-01', \n    timeframe='hour'\n)\n```\n\nThe above code will generate a chart of hourly OHLC prices for Wrapped Ether (WETH) during the month of January 2021. The address for WETH can be replaced with any token address on the supported chains.\n\nBy default, Plotly will automatically render the chart in your browser. If you would like to save the chart as a HTML file, you can pass the `save_as` parameter to the `ohlc` method:\n\n```python\nchart.ohlc(\n    chain='ethereum', \n    token_address='0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', \n    from_timestamp='2021-01-01', \n    to_timestamp='2021-02-01', \n    timeframe='hour',\n    save_as='test.html'\n)\n```\n\n### Downloading OHLC data\n\nTo return the data directly as a Pandas DataFrame from the `ohlc` method rather than charting, you may pass the optional `return_df` parameter:\n\n```python\nprice_df = chart.ohlc(\n    chain='ethereum', \n    token_address='0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', \n    from_timestamp='2021-01-01', \n    to_timestamp='2021-02-01', \n    timeframe='hour',\n    return_df=True\n)\n```\n\nThe `price_df` DataFrame will contain a timestamp index and four columns for the OHLC prices: `open`, `high`, `low`, and `close`.\n\n### Charting Options\n\nThe `ohlc` method accepts a number of optional parameters to customize the chart. The following parameters are available:\n\n- `chain`: The blockchain network to query (`ethereum`, `goerli`, or `polygon`).\n- `token_address`: The address of the token to chart (must be a valid 42-character hex addres).\n- `from_timestamp`: The start date for the chart (supports common string formats and Unix timestamps).\n- `to_timestamp`: The end date for the chart (supports common string formats and Unix timestamps).\n- `timeframe`: The time interval to chart (`day`, `hour`, or `minute`).\n- `save_as`: The path to save the chart as a HTML file.\n- `return_df`: Whether to return the data as a Pandas DataFrame rather than charting.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "The Transpose DeFi SDK is a simple Python package for performing multi-chain DeFi analysis using the real-time Transpose SQL API.",
    "version": "1.0.1",
    "split_keywords": [
        "web3",
        "defi",
        "ethereum",
        "transpose",
        "prices",
        "ohlc",
        "data",
        "analysis",
        "blockchain",
        "polygon"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "9875a9d8f6278ccb2dccd6e005c2d04a",
                "sha256": "beb4625bdb1e2ea45a1c860b91dc02d07ae21a115f8a50fd1e949d847be25d3e"
            },
            "downloads": -1,
            "filename": "transpose_defi_sdk-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9875a9d8f6278ccb2dccd6e005c2d04a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9021,
            "upload_time": "2022-12-12T21:53:33",
            "upload_time_iso_8601": "2022-12-12T21:53:33.126205Z",
            "url": "https://files.pythonhosted.org/packages/52/3e/31c0811863208dd1012157245ba163bd0249f358aff249abeb01c6ed88c4/transpose_defi_sdk-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-12 21:53:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "TransposeData",
    "github_project": "transpose-defi-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "pandas",
            "specs": []
        },
        {
            "name": "pip-chill",
            "specs": []
        },
        {
            "name": "plotly",
            "specs": []
        },
        {
            "name": "web3",
            "specs": []
        }
    ],
    "lcname": "transpose-defi-sdk"
}
        
Elapsed time: 0.02495s