Skip to main content

ShortabilityProvider

Trait ShortabilityProvider 

Source
pub trait ShortabilityProvider:
    Debug
    + Send
    + Sync {
    // Required method
    fn shortability(
        &self,
        instrument: &InstrumentNameExchange,
        time: DateTime<Utc>,
    ) -> Shortability;

    // Provided method
    fn short_sale_restricted(
        &self,
        _instrument: &InstrumentNameExchange,
        _time: DateTime<Utc>,
    ) -> bool { ... }
}
Expand description

Says what a simulated venue may lend for a short sale, at any instant of a run.

The venue asks when an order arrives that would open or increase a short. Both methods must be pure functions of their arguments, so a replay asks the same question and gets the same answer.

Send + Sync because a venue holds its provider behind an Arc, so that one provider, and the history it carries, can be shared by every run of a backtest sweep without being copied.

Required Methods§

Source

fn shortability( &self, instrument: &InstrumentNameExchange, time: DateTime<Utc>, ) -> Shortability

What the venue says about lending instrument at time.

Provided Methods§

Source

fn short_sale_restricted( &self, _instrument: &InstrumentNameExchange, _time: DateTime<Utc>, ) -> bool

Whether a short-sale restriction is in effect on instrument at time, such as the SEC’s Rule 201 circuit breaker after a 10% fall, under which a short sale may not be priced at or below the best bid.

Separate from shortability because it is a rule of the market, not a term of the loan. false unless implemented.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§