Report single-sided traded shares and taker notional by event and market
This commit is contained in:
@@ -237,6 +237,10 @@ pub(crate) enum Query {
|
||||
Estimate(crate::estimate::Request),
|
||||
PricesHistory(crate::prices_history::Request),
|
||||
QuoteHistory(crate::quotes::Filter),
|
||||
Volume {
|
||||
event: Option<String>,
|
||||
market: Option<String>,
|
||||
},
|
||||
Resolution {
|
||||
market: String,
|
||||
},
|
||||
@@ -277,6 +281,12 @@ pub(crate) enum Query {
|
||||
impl Query {
|
||||
pub fn read(self, db: &Transaction, books: &mut crate::resident::Books) -> Result<Value> {
|
||||
match self {
|
||||
Self::Volume { event, market } => {
|
||||
Ok(
|
||||
crate::volume::Report::read(db, event.as_deref(), market.as_deref())?
|
||||
.response(),
|
||||
)
|
||||
}
|
||||
Self::QuoteHistory(request) => request.read(db),
|
||||
Self::PricesHistory(request) => request.read(db),
|
||||
Self::Estimate(request) => request.read(db, books),
|
||||
@@ -357,7 +367,7 @@ impl Query {
|
||||
_ => anyhow::bail!("specify either event or slug"),
|
||||
};
|
||||
identifier(&key)?;
|
||||
let (id, detail) = db.query_row(sql, [key], |r| {
|
||||
let (id, mut detail) = db.query_row(sql, [key], |r| {
|
||||
let id: String = r.get("id")?;
|
||||
let mut event = json!({
|
||||
"id": id, "slug": r.get::<_, String>("slug")?,
|
||||
@@ -381,6 +391,8 @@ impl Query {
|
||||
LEFT JOIN augmented_outcomes a ON a.market=s.market
|
||||
WHERE event=? AND (a.role IS NULL OR a.role<>'placeholder') ORDER BY group_order,s.market"
|
||||
)?;
|
||||
let volume = crate::volume::Report::read(db, Some(&id), None)?;
|
||||
detail["volume"] = json!(volume.total);
|
||||
let mut rows = stmt.query([id])?;
|
||||
let mut markets = Vec::new();
|
||||
while let Some(r) = rows.next()? {
|
||||
@@ -388,7 +400,7 @@ impl Query {
|
||||
let yes: String = r.get(2)?;
|
||||
let no: String = r.get(3)?;
|
||||
markets.push(
|
||||
json!({"market":market, "outcomes":assets::outcomes(&market,&yes,&no),
|
||||
json!({"market":market, "volume":volume.markets.get(&market), "outcomes":assets::outcomes(&market,&yes,&no),
|
||||
"question":r.get::<_,String>(1)?,
|
||||
"yes_label":yes,
|
||||
"no_label":no,
|
||||
|
||||
Reference in New Issue
Block a user