nautechsystems/nautilus_trader · error · anyhow::Error
Order size not set
Error message
Order size not set
What it means
Builder guard in the dYdX order builder's build: no order size was set on the builder before build was called, so a zero-unknown-size order cannot be constructed and the builder reports the missing required field.
Source
Thrown at crates/adapters/dydx/src/grpc/order.rs:423
/// Set order's expiration.
#[must_use]
pub fn until(mut self, gtof: OrderGoodUntil) -> Self {
self.until = Some(gtof);
self
}
/// Build the order.
///
/// # Errors
///
/// Returns an error if the order parameters are invalid.
pub fn build(self) -> Result<Order, anyhow::Error> {
let side = self
.side
.ok_or_else(|| anyhow::anyhow!("Order side not set"))?;
let size = self
.size
.ok_or_else(|| anyhow::anyhow!("Order size not set"))?;
// Quantize size
let quantums = self.market_params.quantize_quantity(size)?;
// Build order ID
let order_id = Some(OrderId {
subaccount_id: Some(SubaccountId {
owner: self.subaccount_owner.clone(),
number: self.subaccount_number,
}),
client_id: self.client_id,
order_flags: match self.flags {
OrderFlags::ShortTerm => 0,
OrderFlags::LongTerm => 64,
OrderFlags::Conditional => 32,
},
clob_pair_id: self.market_params.clob_pair_id,
});View on GitHub (pinned to 18893faf8b)
Solutions
- Always call .size(...) with a positive Decimal before .build()
- Guard the caller: skip order submission entirely when the computed size is None or zero
- Log the computed size path so silent None sizing is visible
Example fix
// before
let size = self.position.map(|p| p.size); // may be None
let order = builder.size(size).build()?;
// after
let size = self.position.map(|p| p.size)
.filter(|s| *s > Decimal::ZERO)
.ok_or_else(|| anyhow::anyhow!("no position to size order from"))?;
let order = builder.size(size).build()?; Defensive patterns
Strategy: validation
Validate before calling
anyhow::ensure!(size.map(|s| s > Decimal::ZERO).unwrap_or(false), "size must be set and positive");
Prevention
- Skip submission when computed size is None or zero instead of building anyway
- Test the sizing-to-order pipeline with empty-position cases
- Make size a constructor argument rather than an optional setter
When it happens
Trigger: Calling build() (e.g. via build_conditional_order) without calling the size setter, or a branch that only sets size for certain order types.
Common situations: Sizing logic that computes size lazily and can return None (e.g. zero remaining position); refactor that dropped the .size() call; order-sized-from-position code where position lookup returned nothing.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Order side not set
- Order expiration (until) not set
- slots lock poisoned
- AX whoami account {} supplied no fee rates
- DEX {} does not have initialize event set.
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/5590e1e86e077e47.
Report an issue: GitHub.