research.sparkline
Documentation for eth_defi.research.sparkline Python module.
Render sparkline charts for ERC-4626 vault data.
Sparkline is a mini price chart, popularised by CoinMarketCap
Charts contain share price and TVL
Functions
Render a sparkline chart and return as PNG bytes. |
|
Render a sparkline chart and return as SVG bytes. |
|
|
Extract price data for a specific vault from a DataFrame. |
|
Render a sparkline chart with green-to-black gradient fill. |
|
Render a sparkline chart for a single vault. |
|
Uploads a the vault sparklines payload to a Cloudflare R2 bucket. |
- extract_vault_price_data(spec, prices_df)
Extract price data for a specific vault from a DataFrame.
- Parameters
spec (eth_defi.vault.base.VaultSpec) – chain-vault address identifier
prices_df (pandas.core.frame.DataFrame) – DataFrame containing price data
- Returns
Filtered DataFrame for the specified vault
- Return type
pandas.core.frame.DataFrame
- render_sparkline_simple(vault_prices_df, width=256, height=64, ffill=True)
Render a sparkline chart for a single vault.
- Parameters
- Return type
- render_sparkline_gradient(vault_prices_df, width=300, height=300, ffill=True, line_color='#22B452', bg_color='#282827', line_width=2, margin_ratio=50)
Render a sparkline chart with green-to-black gradient fill.
- Parameters
- Return type
- export_sparkline_as_png(fig)
Render a sparkline chart and return as PNG bytes.
- Parameters
fig (matplotlib.figure.Figure) –
- Return type
- export_sparkline_as_svg(fig)
Render a sparkline chart and return as SVG bytes.
- Parameters
fig (matplotlib.figure.Figure) –
- Return type
- upload_to_r2_compressed(payload, bucket_name, object_name, endpoint_url, access_key_id, secret_access_key, content_type)
Uploads a the vault sparklines payload to a Cloudflare R2 bucket.
Exported to the frontend listings
Compress SVGs with gzip
- Parameters
payload (bytes) – The bytes data to upload.
bucket_name (str) – The name of the R2 bucket.
object_name (str) – The destination object name (e.g., “my-image.png”).
account_id – Your Cloudflare R2 account ID.
access_key_id (str) – Your R2 access key ID.
secret_access_key (str) – Your R2 secret access key.
content_type (str) – The MIME type of the file.
endpoint_url (str) –