use std::num::NonZeroUsize;
use nautilus_core::{Params, UUID4, UnixNanos};
use nautilus_model::{
data::{BarType, DataType},
identifiers::{ClientId, InstrumentId, OptionSeriesId, Venue},
};
use serde::{Deserialize, Serialize};
use super::{
IntoBarTypes, IntoInstrumentIds, check_client_id_or_venue,
identifiers::{
deserialize_bar_types, deserialize_instrument_ids, single_bar_type, single_instrument_id,
},
};
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeCustomData {
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub data_type: DataType,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeCustomData {
pub fn new(
client_id: Option<ClientId>,
venue: Option<Venue>,
data_type: DataType,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
check_client_id_or_venue(&client_id, &venue);
Self {
client_id,
venue,
data_type,
command_id,
ts_init,
correlation_id,
params,
}
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeInstrument {
#[serde(deserialize_with = "deserialize_instrument_ids")]
pub instrument_ids: Vec<InstrumentId>,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeInstrument {
pub fn new(
instrument_ids: impl IntoInstrumentIds,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
check_client_id_or_venue(&client_id, &venue);
Self {
instrument_ids,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_instrument_ids(&self, instrument_ids: impl IntoInstrumentIds) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
Self {
instrument_ids,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_instrument_id(&self) -> anyhow::Result<InstrumentId> {
single_instrument_id(&self.instrument_ids, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeInstruments {
pub client_id: Option<ClientId>,
pub venue: Venue,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeInstruments {
pub fn new(
client_id: Option<ClientId>,
venue: Venue,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
Self {
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeBookDeltas {
#[serde(deserialize_with = "deserialize_instrument_ids")]
pub instrument_ids: Vec<InstrumentId>,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeBookDeltas {
pub fn new(
instrument_ids: impl IntoInstrumentIds,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
check_client_id_or_venue(&client_id, &venue);
Self {
instrument_ids,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_instrument_ids(&self, instrument_ids: impl IntoInstrumentIds) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
Self {
instrument_ids,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_instrument_id(&self) -> anyhow::Result<InstrumentId> {
single_instrument_id(&self.instrument_ids, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeBookDepth {
#[serde(deserialize_with = "deserialize_instrument_ids")]
pub instrument_ids: Vec<InstrumentId>,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeBookDepth {
pub fn new(
instrument_ids: impl IntoInstrumentIds,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
check_client_id_or_venue(&client_id, &venue);
Self {
instrument_ids,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_instrument_ids(&self, instrument_ids: impl IntoInstrumentIds) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
Self {
instrument_ids,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_instrument_id(&self) -> anyhow::Result<InstrumentId> {
single_instrument_id(&self.instrument_ids, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct UnsubscribeBookSnapshots {
#[serde(deserialize_with = "deserialize_instrument_ids")]
pub instrument_ids: Vec<InstrumentId>,
pub interval_ms: NonZeroUsize,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeBookSnapshots {
#[expect(clippy::too_many_arguments)]
pub fn new(
instrument_ids: impl IntoInstrumentIds,
interval_ms: NonZeroUsize,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
check_client_id_or_venue(&client_id, &venue);
Self {
instrument_ids,
interval_ms,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_instrument_ids(&self, instrument_ids: impl IntoInstrumentIds) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
Self {
instrument_ids,
interval_ms: self.interval_ms,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_instrument_id(&self) -> anyhow::Result<InstrumentId> {
single_instrument_id(&self.instrument_ids, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeQuotes {
#[serde(deserialize_with = "deserialize_instrument_ids")]
pub instrument_ids: Vec<InstrumentId>,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeQuotes {
pub fn new(
instrument_ids: impl IntoInstrumentIds,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
check_client_id_or_venue(&client_id, &venue);
Self {
instrument_ids,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_instrument_ids(&self, instrument_ids: impl IntoInstrumentIds) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
Self {
instrument_ids,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_instrument_id(&self) -> anyhow::Result<InstrumentId> {
single_instrument_id(&self.instrument_ids, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeTrades {
#[serde(deserialize_with = "deserialize_instrument_ids")]
pub instrument_ids: Vec<InstrumentId>,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeTrades {
pub fn new(
instrument_ids: impl IntoInstrumentIds,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
check_client_id_or_venue(&client_id, &venue);
Self {
instrument_ids,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_instrument_ids(&self, instrument_ids: impl IntoInstrumentIds) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
Self {
instrument_ids,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_instrument_id(&self) -> anyhow::Result<InstrumentId> {
single_instrument_id(&self.instrument_ids, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeBars {
#[serde(deserialize_with = "deserialize_bar_types")]
pub bar_types: Vec<BarType>,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeBars {
pub fn new(
bar_types: impl IntoBarTypes,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let bar_types = bar_types.into_bar_types().expect("invalid bar type list");
check_client_id_or_venue(&client_id, &venue);
Self {
bar_types,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_bar_types(&self, bar_types: impl IntoBarTypes) -> Self {
let bar_types = bar_types.into_bar_types().expect("invalid bar type list");
Self {
bar_types,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_bar_type(&self) -> anyhow::Result<BarType> {
single_bar_type(&self.bar_types, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeMarkPrices {
#[serde(deserialize_with = "deserialize_instrument_ids")]
pub instrument_ids: Vec<InstrumentId>,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeMarkPrices {
pub fn new(
instrument_ids: impl IntoInstrumentIds,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
check_client_id_or_venue(&client_id, &venue);
Self {
instrument_ids,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_instrument_ids(&self, instrument_ids: impl IntoInstrumentIds) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
Self {
instrument_ids,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_instrument_id(&self) -> anyhow::Result<InstrumentId> {
single_instrument_id(&self.instrument_ids, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeIndexPrices {
#[serde(deserialize_with = "deserialize_instrument_ids")]
pub instrument_ids: Vec<InstrumentId>,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeIndexPrices {
pub fn new(
instrument_ids: impl IntoInstrumentIds,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
check_client_id_or_venue(&client_id, &venue);
Self {
instrument_ids,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_instrument_ids(&self, instrument_ids: impl IntoInstrumentIds) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
Self {
instrument_ids,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_instrument_id(&self) -> anyhow::Result<InstrumentId> {
single_instrument_id(&self.instrument_ids, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeFundingRates {
#[serde(deserialize_with = "deserialize_instrument_ids")]
pub instrument_ids: Vec<InstrumentId>,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeFundingRates {
pub fn new(
instrument_ids: impl IntoInstrumentIds,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
check_client_id_or_venue(&client_id, &venue);
Self {
instrument_ids,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_instrument_ids(&self, instrument_ids: impl IntoInstrumentIds) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
Self {
instrument_ids,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_instrument_id(&self) -> anyhow::Result<InstrumentId> {
single_instrument_id(&self.instrument_ids, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeInstrumentStatus {
#[serde(deserialize_with = "deserialize_instrument_ids")]
pub instrument_ids: Vec<InstrumentId>,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeInstrumentStatus {
pub fn new(
instrument_ids: impl IntoInstrumentIds,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
check_client_id_or_venue(&client_id, &venue);
Self {
instrument_ids,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_instrument_ids(&self, instrument_ids: impl IntoInstrumentIds) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
Self {
instrument_ids,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_instrument_id(&self) -> anyhow::Result<InstrumentId> {
single_instrument_id(&self.instrument_ids, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeOptionGreeks {
#[serde(deserialize_with = "deserialize_instrument_ids")]
pub instrument_ids: Vec<InstrumentId>,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeOptionGreeks {
pub fn new(
instrument_ids: impl IntoInstrumentIds,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
check_client_id_or_venue(&client_id, &venue);
Self {
instrument_ids,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_instrument_ids(&self, instrument_ids: impl IntoInstrumentIds) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
Self {
instrument_ids,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_instrument_id(&self) -> anyhow::Result<InstrumentId> {
single_instrument_id(&self.instrument_ids, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.live", frozen)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.live")
)]
pub struct UnsubscribeInstrumentClose {
#[serde(deserialize_with = "deserialize_instrument_ids")]
pub instrument_ids: Vec<InstrumentId>,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub correlation_id: Option<UUID4>,
pub params: Option<Params>,
}
impl UnsubscribeInstrumentClose {
pub fn new(
instrument_ids: impl IntoInstrumentIds,
client_id: Option<ClientId>,
venue: Option<Venue>,
command_id: UUID4,
ts_init: UnixNanos,
correlation_id: Option<UUID4>,
params: Option<Params>,
) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
check_client_id_or_venue(&client_id, &venue);
Self {
instrument_ids,
client_id,
venue,
command_id,
ts_init,
correlation_id,
params,
}
}
#[must_use]
pub fn with_instrument_ids(&self, instrument_ids: impl IntoInstrumentIds) -> Self {
let instrument_ids = instrument_ids
.into_instrument_ids()
.expect("invalid instrument identifier list");
Self {
instrument_ids,
client_id: self.client_id,
venue: self.venue,
command_id: self.command_id,
ts_init: self.ts_init,
correlation_id: self.correlation_id,
params: self.params.clone(),
}
}
pub fn single_instrument_id(&self) -> anyhow::Result<InstrumentId> {
single_instrument_id(&self.instrument_ids, "subscription")
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct UnsubscribeOptionChain {
pub series_id: OptionSeriesId,
pub command_id: UUID4,
pub ts_init: UnixNanos,
pub client_id: Option<ClientId>,
pub venue: Option<Venue>,
#[serde(default)]
pub params: Option<Params>,
}
impl UnsubscribeOptionChain {
pub fn new(
series_id: OptionSeriesId,
command_id: UUID4,
ts_init: UnixNanos,
client_id: Option<ClientId>,
venue: Option<Venue>,
) -> Self {
check_client_id_or_venue(&client_id, &venue);
Self {
series_id,
command_id,
ts_init,
client_id,
venue,
params: None,
}
}
}