Skip to main content

Crate exchange_interactions

Crate exchange_interactions 

Source

Modules§

adapters
binance
bitmex
bybit
core
error
orders
prelude
yahoo

Macros§

bail
Return early with an error.
debug
Constructs an event at the debug level.
define_provider_timeframe
error
Constructs an event at the error level.
eyre
Construct an ad-hoc error from a string.
info
Constructs an event at the info level.
json
Construct a serde_json::Value from a JSON literal.
trace
Constructs an event at the trace level.
warn
Constructs an event at the warn level.

Structs§

Aggregate
A fold over many wire messages: one span per actor, first resetting on every resync.
ApiKeyInfo
Arc
A thread-safe reference-counting pointer. ‘Arc’ stands for ‘Atomically Reference Counted’.
Arrival
Weaver ordering key. Monotonic by construction, not by measurement: when events arrive faster than the clock resolves, it is the previous key plus one. So it is deliberately not subtractable — the gap between two arrivals is not an elapsed duration.
Asset
AssetBalance
BTreeMap
An ordered map based on a B-Tree.
BTreeSet
An ordered set based on a B-Tree.
Balances
BatchTrades
Batched trade stream event. All trades share prec.
Binance
Bitmex
Book
The book fold. Domain-only — it knows nothing of Cell/Node; the graph node wraps this through Book::step, and ShadowBook wraps the same instance, so the persisted stream and the replayed one cannot drift.
BookAnchors
Anchors are Book’s input, not the graph’s — nothing else should name this.
BookChunk
The net effect of one period’s deltas.
BookDelta
One level of our own recollection — see ShadowBook: the persisted delta lane is gapless and self-consistent, so kind (not the venue’s gapped flag) is what a consumer reads. This is the stored row; unlike every other lane holder it carries its own precision, because a Series hands out bare items and a raw price no consumer can scale is not a reading. The persistence tier fills it from the file’s schema.
BookDeltas
BookShape
(price, qty) levels for both sides of an orderbook, keyed by raw price. The wire/persist shape. Both BTreeMaps are ascending; Book holds the same levels best-first.
Bounded
A cross-actor quantity: two clocks, so the true value is only known to lie in [lo, hi].
Bybit
Close
Unlike Kline, timestamp signifies the end of the period, not the start. As another difference - Vec<Close> can have uneven spacing between measured points.
Empty
An empty field.
Exact
Same-actor difference: one clock read twice, so no skew term.
ExchangeInfo
ExchangeOrder
An order bound to a specific exchange and ticker, ready to be placed.
HashMap
A hash map implemented with quadratic probing and SIMD lookup.
HashSet
A hash set implemented as a HashMap where the value is ().
InnerTrade
One trade in raw (scaled-int) form; price/qty are meaningless without the batch’s prec.
InvalidPairError
Kline
Standard candlestick data unit. Can only ever be full, - if an exchange returns partial data for an ongoing candle, or if trading/exchange is down leading to the associated data being cut, the Kline object is NOT created.
Klines
Does not have any gaps in the data, (as klines are meant to be indexed naively when used). TODO: enforce this.
Leg
The origin acts, then sends; the destination receives. Relay plus an attested origin.
LimitOrder
Exchange-agnostic limit order.
Local
Our own process.
Lsr
Lsrs
MarketOrder
Exchange-agnostic market order.
Mutex
A mutual exclusion primitive useful for protecting shared data
Offset
How far a remote clock runs ahead of ours, and how well we know it.
Ohlc
OpenInterest
most exchanges default to returning OI value in asset quantity, not quote. Exception would be Inverse on Bybit. Which actually makes sense, as same endpoints accept things like “BTCETH”, where quote value would be irrelevant.
OrderId
OrderPlaced
Unified response from placing any order.
OutOfRangeError
Pair
PairInfo
PersonalInfo
Pin
A pointer which pins its pointee in place.
Precision
Decimal exponent: raw = value × 10^precision. Signed, so a million-dollar index tick and a satoshi tick both fit the same 32-bit raw column.
PrecisionPriceQty
Per-batch precision shared across all levels / trades in a book / trade batch.
Price
Fixed-point price. Signed to support options and index ticks below zero.
Qty
Fixed-point quantity. Non-negative.
ReadClock
How coarsely a backtest batches, so that it runs faster than the market it replays. That is the whole of it. Arrival time is cut into cells of this length and everything landing in one cell is handed to the graph as a single step, so a replay does a day’s work in as many steps as the cell size buys rather than one per message.
Relay
Transmitted it, and may attest to being its origin. Covers a relaying vendor and a venue that reports only an envelope time.
RelayCols
Relay’s columnar twin: per element where the element attests, on the holder where the run does. Both shapes stay — Relay for a single event, this for a run.
Report
The core error reporting type of the library, a wrapper around a dynamic error reporting type.
RetryConfig
Configuration for retry behavior.
RoundTrip
RwLock
A reader-writer lock
ShadowBook
We persist our own recollection, not the venue’s story. A gap or a resync is a fact about our connection; stored raw, every replay would re-derive the reconciliation from whatever venue snapshots happened to land. Reconciled once here, replay is exact and free.
Span
A handle representing a span, with the capability to enter the span if it exists.
StopLimitOrder
Stop-limit order: a limit order that activates when the trigger price is hit.
StopMarketOrder
Stop-market order: a market order that activates when the trigger price is hit.
Symbol
Ticker
Timeframe
Implemented over the number of milliseconds
TradeBuf
Owned twin of TradeCols: lane buffer, Nudge scratch and ingest accumulator in one.
TradeCols
Trades
TrailingStopOrder
Trailing stop-market order.
Trigger
Trigger configuration for conditional orders (stop-limit, stop-market, take-profit, etc.)
Ts
Nanoseconds since the Unix epoch, tagged with the actor whose clock produced it.
UnsupportedTimeframeError
Usd
A struct representing USD (in future, inflation-adjusted) value. That’s it. Just a newtype. But extremely powerful.
VecDeque
A double-ended queue implemented with a growable ring buffer.
Vendor
A party that relays facts it did not originate.
Venue
The exchange a fact originates from.
YahooTimeframe
pi32
pu32

Enums§

BookUpdate
Distinguishes full snapshots from incremental deltas. For deltas: qty=0 means remove that price level.
Contingency
Contingency linkage between orders.
Direction
A position’s sign. Flat is a decision — that there is nothing here — where None upstream is the absence of one.
Error
ExchangeError
ExchangeName
FrameKind
Whether a level is market activity or our own reconciliation — a UInt8 column exactly parallel to the side byte. Per row, not per run: what a run of levels is, is what its rows say it is, and the one consumer that discriminates (a flow derivation, which a correction would feed fabricated signal) filters on it.
Instrument
KeyPermission
MethodError
OrderStatus
RequestRange
RequestRangeError
SelfTradePreventionMode
Binance: EXPIRE_MAKER/EXPIRE_TAKER/EXPIRE_BOTH; OKX: cancel_maker/cancel_taker/cancel_both
Side
TimeInForce
TimeframeDesignator
Timestamps
Boundary view for serialisation, logging and inspection. Objects keep their concrete shape; this is what they flatten to when something generic has to look at them.
TrailingCallback
Trailing stop callback specification.
TriggerPriceType
What price feed triggers the conditional order.
Value
Represents any valid JSON value.

Traits§

Account
Everything behind an api key.
Deserialize
A data structure that can be deserialized from any data format supported by Serde.
DeserializeOwned
A data structure that can be deserialized without borrowing any data from the deserializer.
Deserializer
A data format that can deserialize any data structure supported by Serde.
Exchange
A venue, with whatever it happens to be able to do.
ExchangeInit
Feature-gated exchange construction. Local extension trait over the foreign ExchangeName (defined in trading_data_core) — the only piece of exchange behavior that cannot leave this crate.
ExchangeStream
Concerns itself with exact types.
History
Bulk historical data, read from the venue’s archive rather than its request API.
Market
Reference data and the venue’s request API. Every venue has one, so it is the base every other capability is stated against.
Sequence
Per-exchange book-event ordering token. Used internally by the WS connection to detect gaps in the per-pair delta chain. Not persisted; the result (gapped: bool) is.
Serialize
A data structure that can be serialized into any data format supported by Serde.
Serializer
A data format that can serialize any data structure supported by Serde.
Stream
Live event feeds. Not every venue has one — a venue that doesn’t simply doesn’t implement this, and Exchange::stream answers None rather than a runtime “not supported”.
SubscribeOrder
Timestamped
Wire
The weaker bound: it crossed a wire. Generic code bounds on this and accepts either shape; code that needs origin attestation takes Leg concretely and a Relay will not compile.
_
A trait for writing or formatting into Unicode-accepting buffers or streams.

Functions§

join_all
Creates a future which represents a collection of the outputs of the futures given.
mock_p_to_ohlc
take a price-series, and imagine that entries are constantly spaced
offset
NTP’s estimator. The two recv - send terms straddle actors, which is exactly why this is the one place that touches raw nanos and the only thing that can mint an Offset.
p_to_ohlc
to_local
Project a venue reading onto our clock. The result is Bounded, never a Ts<Local>: the skew is estimated, and collapsing the interval would re-hide exactly what the estimate cost.
vix
vix_change

Type Aliases§

ExchangeResult
External
Outbound
Result
type alias for Result<T, Report>

Attribute Macros§

instrument
Instruments a function to create and enter a tracing span every time the function is called.

Derive Macros§

Deserialize
Derive macro available if serde is built with features = ["derive"].
Error
Serialize
Derive macro available if serde is built with features = ["derive"].