Calculate priced gross open interest from outstanding outcome positions
This commit is contained in:
@@ -20,3 +20,29 @@ pub(crate) fn phase(tx: &Transaction, market: &str, allowed: &[&str]) -> Result<
|
||||
ensure!(allowed.contains(&p.as_str()), "wrong market phase");
|
||||
Ok(p)
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, PartialEq)]
|
||||
#[serde(untagged)]
|
||||
pub(crate) enum IdSelector {
|
||||
One(String),
|
||||
Many(Vec<String>),
|
||||
}
|
||||
|
||||
impl IdSelector {
|
||||
pub(crate) fn ids(&self) -> Result<Vec<String>> {
|
||||
let mut ids = match self {
|
||||
Self::One(id) => vec![id.clone()],
|
||||
Self::Many(ids) => ids.clone(),
|
||||
};
|
||||
ids.sort();
|
||||
ids.dedup();
|
||||
ensure!(
|
||||
(1..=20).contains(&ids.len()),
|
||||
"expected 1 to 20 distinct IDs"
|
||||
);
|
||||
for id in &ids {
|
||||
identifier(id)?;
|
||||
}
|
||||
Ok(ids)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user