Skip to main content

Market Data Exploration and TradingView Charts

The Defi Market Feed API is a robust data analytics tool for Cardano DeFi market analysis and algorithmic trading. We will demonstrate how to leverage this data by:

TradingView - Lightweight Charts™

TradingView is a popular web-based platform renowned for its comprehensive and user-friendly charting tools. Users can access a variety of charts for different financial instruments, like stocks, cryptocurrencies, forex, and futures. These charts can be customized with numerous technical indicators and drawing tools to analyze market trends and patterns.

TradingView's Lightweight Charts is a compact, interactive library designed to create financial charts that are both fast and easy to integrate. Here's a basic guide on how to use it with Maestro Defi Market Feed API's endpoint DEX and Pair OHLC:

import pandas as pd
import requests
import numpy as np
from lightweight_charts import Chart
import time
import asyncio
import nest_asyncio

nest_asyncio.apply()

def main():
api_key = 'API-Key'

resolution="1d"
from_time="2023-09-01"
# to_time="2023-12-11"

dex = "minswap"
pair = "ADA-SNEK" # ADA-GENS, ADA-MIN

query = f'https://mainnet.gomaestro-api.org/v1/markets/dexs/ohlc/{dex}/{pair}?resolution={resolution}&api-key={api_key}&from={from_time}'
ohlc_json = requests.get(query).json()

ohlc_df = pd.DataFrame(ohlc_json)
ohlc_df.timestamp = pd.to_datetime(ohlc_df.timestamp)

ohlc_df_coin_a = ohlc_df[['timestamp', 'coin_a_open', 'coin_a_high', 'coin_a_low', 'coin_a_close', 'coin_a_volume']]
ohlc_df_coin_a.columns = ['time', 'open', 'high', 'low', 'close', 'volume']

print(query)
print(ohlc_df_coin_a.tail())

chart = Chart()
chart.set(ohlc_df_coin_a)
chart.show(block = True)

if __name__ == '__main__':
main()

Run and tweak this code locally using something like Anaconda's IDEs or your preferred tools.

Price Candle Stick Data

Here is a sample of the returned OHLC data used to construct the Candlestick price chart.

TimeOpenHighLowCloseVolume
2023-12-090.0016330.0019010.0013820.0015067.427439e+06
2023-12-100.0015060.0016770.0014820.0016452.319258e+06
2023-12-110.0016340.0017430.0014660.0017062.576409e+06
2023-12-120.0017150.0019620.0016820.0017724.100397e+06
2023-12-130.0017600.0020260.0016370.0019302.366375e+06

Trading View Price Chart

Create beautiful and professional crypto analytics dashboards with TradingView and Maestro. Get access to real-time price and trade data feeds from your favorite token and DEX:

  1. Explore the DeFi space
  2. Visualize financial indicators
  3. Discover new trends in DeFi markets.
tip

Can you recognize what famous Cardano token this is?


Data exploration with Google Colab Notebook

Token statistics, OHLC price candles and historical token trades are just a few of the data insights you can get from the Maestro Defi Market API.

We encourage you to checkout the examples in the Google Colab Notebook Maestro DeFi Market data.ipynb. To run the demo yourself make sure to fill in your API Key.

Supported DEXs and Trading Pairs

Maestro currently supports hundreds of tokens on minswap and genius-yield. Checkout these endpoints to get an up-to-date list of supported DEXs and DEX pairs.

Example 1: DEX and Pair Stats

Get Token statistics with:

query = f'https://mainnet.gomaestro-api.org/v1/markets/dexs/stats/{dex}/{pair}?&api-key={api_key}'
stats_json = requests.get(query).json()
print(json.dumps(stats_json, indent=2))
{
"1m": {
"coin_a_previous_price": 0.002975,
"coin_a_latest_price": 0.002956,
"coin_a_price_change_pct": -0.6306,
"coin_a_volume": 1352.922856,
"coin_b_previous_price": 336.136667,
"coin_b_latest_price": 338.269795,
"coin_b_price_change_pct": 0.634602,
"coin_b_volume": 457481
},
"5m": {
"coin_a_previous_price": 0.002933,
"coin_a_latest_price": 0.002956,
"coin_a_price_change_pct": 0.795813,
"coin_a_volume": 13619.982329,
"coin_b_previous_price": 340.961789,
"coin_b_latest_price": 338.269795,
"coin_b_price_change_pct": -0.789529,
"coin_b_volume": 4599806
},
"15m": {
"coin_a_previous_price": 0.002935,
"coin_a_latest_price": 0.002956,
"coin_a_price_change_pct": 0.720491,
"coin_a_volume": 37166.026069,
"coin_b_previous_price": 340.707,
"coin_b_latest_price": 338.269795,
"coin_b_price_change_pct": -0.715337,
"coin_b_volume": 12600984
},

[...]
}

Example 2: Historical DEX Trades

Get DEX and Pair Trades with:

query = f'https://mainnet.gomaestro-api.org/v1/markets/dexs/trades/{dex}/{pair}?&api-key={api_key}&from={from_time}'
trades_json = requests.get(query).json()
trades_df = pd.DataFrame(trades_json)
trades_df.timestamp = pd.to_datetime(trades_df.timestamp)
trades_df
timestampdexpaircoin_a_sizecoin_a_pricecoin_b_sizecoin_b_pricetransaction_hasha_to_breceiver_address
2024-03-04 20:03:24+00:00minswapADA-SNEK2095.9028690.002399873721416.87094045c03fd2cd05e79ac24ccd712cb37a464867dd84e7ea22...0013707dd9d2ced44ce5f3907a6c88403a808c505dacfaa...
2024-03-04 20:06:17+00:00minswapADA-SNEK10.0000000.0024124146414.60000035ae45bc488393fc6a3334a4e8ffc541817453198a5357...1016813f5374670f65d890a412c1023d66e93e9fe95fb57...
2024-03-04 20:07:54+00:00minswapADA-SNEK30.0000000.00241212439414.6333338dfe1587377a3e085c3d1d76102ec0c5ca6b3eef6b3e72...101b3d984e3abcd8a7b11c4c0b7e5eadcc2238a402e829c...
2024-03-04 20:09:12+00:00minswapADA-SNEK2572.0756520.0023981072466416.96518585a5e442516cff9e6e79d7d7380ce8fce056cc04b5e36f...0015247dd3bdf2d2f838a2f0c91b38f127523772d243939...
2024-03-04 20:09:12+00:00minswapADA-SNEK1930.5208710.002413799980414.3855748d850052b787a7435782696cbf96af09d715a84dafc6db...101511eea0e8f358e2fb7bc388bdc27a5aeda1943f6b1d9...

Checkout the Demo Notebook to convert the dataframe to interactive tables and enable advanced ordering and filtering.

Also, for applicable data, "View recommended plots" will be available.

info

Market Price API is available in Conductor tier and up