pub trait ShortabilityClient: ExecutionClient {
// Required method
fn fetch_shortability(
&self,
instrument: &InstrumentNameExchange,
) -> impl Future<Output = Result<Shortability, UnindexedClientError>> + Send;
}Expand description
Extension trait for clients that can say what the venue would lend for a short sale.
Answers, before an order is sent, the question a short sale otherwise learns only from its
rejection: whether the instrument may be sold short, whether it is easy to borrow, how much the
venue has to lend and at what fee. Each venue reports a different subset, so each field of the
Shortability it returns is optional; the implementations say which fields they fill.
§Type-Level Capability
A supertrait of ExecutionClient, for the reason BracketOrderClient is one: a client
whose venue has nothing to lend, or that does not report it, does not implement it. A simulated
venue reads the same Shortability from a
ShortabilityProvider instead.
Required Methods§
Sourcefn fetch_shortability(
&self,
instrument: &InstrumentNameExchange,
) -> impl Future<Output = Result<Shortability, UnindexedClientError>> + Send
fn fetch_shortability( &self, instrument: &InstrumentNameExchange, ) -> impl Future<Output = Result<Shortability, UnindexedClientError>> + Send
What the venue says about lending instrument for a short sale.
§Contract
- Advisory.
Okdescribes the venue’s lending as it reported it, not a promise to lend: a short sale must still handleApiError::BorrowRejected. - Not this account’s capacity.
Shortability::availableis what the venue has to lend, not what is left of it for this account; that isBorrowCapacityClient::fetch_borrow_capacity, where a venue reports it. - May be expensive. An implementation may make several requests, some of them heavy against the venue’s rate limit, or hold a scarce resource such as a market data line; each says what it costs. Fetch it when deciding on a short, not on every tick.
- May be slow. Where the venue streams its answer rather than replying to a request, the call waits for it, up to a timeout the implementation documents: seconds, not milliseconds.
- May outlive its future. An implementation that reads on a blocking thread finishes that read, and releases what it holds, even when the returned future is dropped first; each says so.
§Errors
ApiError::InstrumentInvalidfor an instrument the venue does not know, or one of a kind that is not sold short by borrowing it, such as an option.- An error, rather than a
Shortabilitywith nothing known, when the venue does not answer, including when the account is not entitled to the answer, such as one without the market data subscription a venue sends it through.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".