2023-05-05 18:41:17 -07:00
|
|
|
use serde::Serialize;
|
2023-05-14 01:09:12 -07:00
|
|
|
use tokio_postgres::Row;
|
2023-05-05 18:41:17 -07:00
|
|
|
|
2023-05-07 14:43:55 -07:00
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
|
|
pub struct CoinGeckoOrderBook {
|
|
|
|
pub ticker_id: String,
|
|
|
|
pub timestamp: String, //as milliseconds
|
|
|
|
pub bids: Vec<(String, String)>,
|
|
|
|
pub asks: Vec<(String, String)>,
|
|
|
|
}
|
|
|
|
|
2023-05-05 18:41:17 -07:00
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
|
|
pub struct CoinGeckoPair {
|
|
|
|
pub ticker_id: String,
|
|
|
|
pub base: String,
|
|
|
|
pub target: String,
|
|
|
|
pub pool_id: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
|
|
pub struct CoinGeckoTicker {
|
|
|
|
pub ticker_id: String,
|
2023-12-21 14:28:12 -08:00
|
|
|
pub address: String,
|
2023-05-05 18:41:17 -07:00
|
|
|
pub base_currency: String,
|
|
|
|
pub target_currency: String,
|
2023-05-07 14:43:55 -07:00
|
|
|
pub last_price: String,
|
|
|
|
pub base_volume: String,
|
|
|
|
pub target_volume: String,
|
2023-05-07 14:59:00 -07:00
|
|
|
// pub bid: String,
|
|
|
|
// pub ask: String,
|
2023-05-07 14:43:55 -07:00
|
|
|
pub high: String,
|
|
|
|
pub low: String,
|
2023-05-05 18:41:17 -07:00
|
|
|
}
|
|
|
|
|
2023-12-21 14:28:12 -08:00
|
|
|
#[derive(Debug, Default)]
|
2023-05-05 18:41:17 -07:00
|
|
|
pub struct PgCoinGecko24HourVolume {
|
|
|
|
pub address: String,
|
2023-06-14 23:50:24 -07:00
|
|
|
pub base_size: f64,
|
|
|
|
pub quote_size: f64,
|
2023-05-05 18:41:17 -07:00
|
|
|
}
|
|
|
|
impl PgCoinGecko24HourVolume {
|
2023-05-14 01:09:12 -07:00
|
|
|
pub fn from_row(row: Row) -> Self {
|
|
|
|
PgCoinGecko24HourVolume {
|
|
|
|
address: row.get(0),
|
2023-06-14 23:50:24 -07:00
|
|
|
base_size: row.get(1),
|
|
|
|
quote_size: row.get(2),
|
2023-05-14 01:09:12 -07:00
|
|
|
}
|
|
|
|
}
|
2023-05-05 18:41:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Default)]
|
|
|
|
pub struct PgCoinGecko24HighLow {
|
2023-12-21 14:28:12 -08:00
|
|
|
pub address: String,
|
2023-05-14 00:15:10 -07:00
|
|
|
pub high: f64,
|
|
|
|
pub low: f64,
|
|
|
|
pub close: f64,
|
2023-05-05 18:41:17 -07:00
|
|
|
}
|
2023-05-14 01:09:12 -07:00
|
|
|
|
|
|
|
impl PgCoinGecko24HighLow {
|
|
|
|
pub fn from_row(row: Row) -> Self {
|
|
|
|
PgCoinGecko24HighLow {
|
2023-12-21 14:28:12 -08:00
|
|
|
address: row.get(0),
|
2023-05-14 01:09:12 -07:00
|
|
|
high: row.get(1),
|
|
|
|
low: row.get(2),
|
|
|
|
close: row.get(3),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|