Skip to main content

Module trade

Module trade 

Source
Expand description

Orders on every market: place, cancel, modify, TWAP, TP/SL, leverage and margin, builder fees, outcome splits and fees, and the ticket that turns an intent into the exact action.

Re-exports§

pub use crate::utils::sign::L1Action;
pub use crate::utils::Asset;
pub use crate::utils::AssetKind;
pub use action::TradeAction;
pub use answer::CancelAnswer;
pub use answer::OrderAnswer;
pub use answer::TwapAnswer;
pub use builder::Approval;
pub use builder::ApprovalRefused;
pub use builder::Approved;
pub use builder::Builder;
pub use builder::BuilderFee;
pub use builder::BuilderSetting;
pub use builder::FeeRule;
pub use builder::OUTCOME_BUILDER_CAP;
pub use builder::OverCap;
pub use builder::PERP_BUILDER_CAP;
pub use builder::SPOT_BUILDER_CAP;
pub use error::TradeError;
pub use manage::BatchModify;
pub use manage::Cancel;
pub use manage::CancelByCloid;
pub use manage::Change;
pub use manage::Modify;
pub use manage::Noop;
pub use manage::OrderRef;
pub use manage::ScheduleCancel;
pub use manage::TooSoon;
pub use margin::FLAT_TABLES_BELOW;
pub use margin::LeverageError;
pub use margin::MarginMode;
pub use margin::MarginTable;
pub use margin::MarginTier;
pub use margin::UpdateIsolatedMargin;
pub use margin::UpdateLeverage;
pub use margin::add_margin;
pub use margin::checked_leverage;
pub use margin::remove_margin;
pub use orders::Cloid;
pub use orders::Close;
pub use orders::Covers;
pub use orders::Exit;
pub use orders::ExitPrice;
pub use orders::Grouping;
pub use orders::Order;
pub use orders::OrderIntent;
pub use orders::OrderType;
pub use orders::PlaceOrder;
pub use orders::Price;
pub use orders::Scale;
pub use orders::Side;
pub use orders::Tif;
pub use orders::Tpsl;
pub use orders::TriggerIntent;
pub use orders::Twap;
pub use orders::TwapCancel;
pub use orders::TwapIntent;
pub use ticket::Amount;
pub use ticket::Market;
pub use ticket::Refusal;

Modules§

action
Every trading action as one value, so what a confirmation shows and what is signed are the same value.
answer
What /exchange answers to a trading action, read per item. A count of statuses that does not match what was sent is unreadable, never a partial success, except an error decided by the payload alone, which comes back once and stands for every item.
builder
Builder fees: what an order pays the builder that routed it, the cap on each market kind, and the setting orders are routed through with what an order needs approved first.
error
manage
Orders already resting: modify, cancel, and what stops orders without naming them.
margin
Leverage and margin on a perp: the leverage and mode a position takes, isolated margin in and out, and the margin tables that cap leverage by size. The account-wide mode is crate::account::settings::mode.
orders
Orders: the wire every order type ends in (Order, PlaceOrder), what an order’s t says, its client id, and one module per type. Keys go in the order the venue hashes: a b p s r t c for an order, then grouping, then builder last.
outcomes
Outcome-specific trading: splitting into sides and merging back, and what an outcome fill is billed.
ticket
What every order ticket shares: the market’s rules (Market), how much (Amount), why nothing is sent (Refusal), and the checks each order type runs. A price never rounds against the trader and a size rounds toward zero.