Skip to content

Commit

Permalink
Remove redundant VenueStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Jul 21, 2024
1 parent 1a2d122 commit 65022c1
Show file tree
Hide file tree
Showing 28 changed files with 13 additions and 479 deletions.
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Released on TBD (UTC).
- Upgraded `datafusion` crate to 40.0.0

### Breaking Changes
- Removed `VenueStatus` and all associated methods and schemas (redundant with `InstrumentStatus`)
- Changed `OrderBook` FFI API to take data by reference instead of by value

### Fixes
Expand Down
1 change: 0 additions & 1 deletion docs/concepts/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ a trading domain:
- `TradeTick`: A single trade/match event between counterparties
- `Bar`: OHLCV bar data, aggregated using a specific *aggregation method*
- `Instrument`: General base class for a tradable instrument
- `VenueStatus`: A venue level status event
- `InstrumentStatus`: An instrument level status event
- `InstrumentClose`: An instrument closing price

Expand Down
1 change: 0 additions & 1 deletion docs/concepts/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ The following market data types can be requested historically, and also subscrib
- `Instrument`
- `InstrumentStatus`
- `InstrumentClose`
- `VenueStatus`

The following `PriceType` options can be used for bar aggregations:

Expand Down
2 changes: 0 additions & 2 deletions docs/concepts/strategies.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,13 @@ from nautilus_trader.model.data import TradeTick
from nautilus_trader.model.data import OrderBookDeltas
from nautilus_trader.model.data import InstrumentClose
from nautilus_trader.model.data import InstrumentStatus
from nautilus_trader.model.data import VenueStatus
from nautilus_trader.model.instruments import Instrument

def on_order_book_deltas(self, deltas: OrderBookDeltas) -> None:
def on_order_book(self, order_book: OrderBook) -> None:
def on_quote_tick(self, tick: QuoteTick) -> None:
def on_trade_tick(self, tick: TradeTick) -> None:
def on_bar(self, bar: Bar) -> None:
def on_venue_status(self, data: VenueStatus) -> None:
def on_instrument(self, instrument: Instrument) -> None:
def on_instrument_status(self, data: InstrumentStatus) -> None:
def on_instrument_close(self, data: InstrumentClose) -> None:
Expand Down
31 changes: 0 additions & 31 deletions nautilus_core/data/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ pub trait DataClient {
fn subscribed_quote_ticks(&self) -> &HashSet<InstrumentId>;
fn subscribed_trade_ticks(&self) -> &HashSet<InstrumentId>;
fn subscribed_bars(&self) -> &HashSet<BarType>;
fn subscribed_venue_status(&self) -> &HashSet<Venue>;
fn subscribed_instrument_status(&self) -> &HashSet<InstrumentId>;
fn subscribed_instrument_close(&self) -> &HashSet<InstrumentId>;
fn subscribe(&mut self, data_type: DataType) -> anyhow::Result<()>;
Expand All @@ -76,7 +75,6 @@ pub trait DataClient {
fn subscribe_quote_ticks(&mut self, instrument_id: InstrumentId) -> anyhow::Result<()>;
fn subscribe_trade_ticks(&mut self, instrument_id: InstrumentId) -> anyhow::Result<()>;
fn subscribe_bars(&mut self, bar_type: BarType) -> anyhow::Result<()>;
fn subscribe_venue_status(&mut self, venue: Venue) -> anyhow::Result<()>;
fn subscribe_instrument_status(&mut self, instrument_id: InstrumentId) -> anyhow::Result<()>;
fn subscribe_instrument_close(&mut self, instrument_id: InstrumentId) -> anyhow::Result<()>;
fn unsubscribe(&mut self, data_type: DataType) -> anyhow::Result<()>;
Expand All @@ -90,7 +88,6 @@ pub trait DataClient {
fn unsubscribe_quote_ticks(&mut self, instrument_id: InstrumentId) -> anyhow::Result<()>;
fn unsubscribe_trade_ticks(&mut self, instrument_id: InstrumentId) -> anyhow::Result<()>;
fn unsubscribe_bars(&mut self, bar_type: BarType) -> anyhow::Result<()>;
fn unsubscribe_venue_status(&mut self, venue: Venue) -> anyhow::Result<()>;
fn unsubscribe_instrument_status(&mut self, instrument_id: InstrumentId) -> anyhow::Result<()>;
fn unsubscribe_instrument_close(&mut self, instrument_id: InstrumentId) -> anyhow::Result<()>;
fn request(&mut self, correlation_id: UUID4, data_type: DataType);
Expand Down Expand Up @@ -153,7 +150,6 @@ pub struct DataClientCore {
subscriptions_quote_tick: HashSet<InstrumentId>,
subscriptions_trade_tick: HashSet<InstrumentId>,
subscriptions_bar: HashSet<BarType>,
subscriptions_venue_status: HashSet<Venue>,
subscriptions_instrument_status: HashSet<InstrumentId>,
subscriptions_instrument_close: HashSet<InstrumentId>,
subscriptions_instrument: HashSet<InstrumentId>,
Expand Down Expand Up @@ -201,11 +197,6 @@ impl DataClientCore {
&self.subscriptions_bar
}

#[must_use]
pub const fn subscribed_venue_status(&self) -> &HashSet<Venue> {
&self.subscriptions_venue_status
}

#[must_use]
pub const fn subscribed_instrument_status(&self) -> &HashSet<InstrumentId> {
&self.subscriptions_instrument_status
Expand Down Expand Up @@ -319,17 +310,6 @@ impl DataClientCore {
Ok(())
}

pub fn add_subscription_venue_status(&mut self, venue: Venue) -> anyhow::Result<()> {
correctness::check_member_not_in_set(
&venue,
&self.subscriptions_venue_status,
"venue",
"subscriptions_venue_status",
)?;
self.subscriptions_venue_status.insert(venue);
Ok(())
}

pub fn add_subscription_instrument_status(
&mut self,
instrument_id: InstrumentId,
Expand Down Expand Up @@ -461,17 +441,6 @@ impl DataClientCore {
Ok(())
}

pub fn remove_subscription_venue_status(&mut self, venue: &Venue) -> anyhow::Result<()> {
correctness::check_member_in_set(
venue,
&self.subscriptions_venue_status,
"venue",
"subscriptions_venue_status",
)?;
self.subscriptions_venue_status.remove(venue);
Ok(())
}

pub fn remove_subscription_instrument_status(
&mut self,
instrument_id: &InstrumentId,
Expand Down
5 changes: 0 additions & 5 deletions nautilus_core/data/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,6 @@ impl<S: State> DataEngine<S> {
self.collect_subscriptions(|client| client.subscribed_bars())
}

#[must_use]
pub fn subscribed_venue_status(&self) -> Vec<Venue> {
self.collect_subscriptions(|client| client.subscribed_venue_status())
}

#[must_use]
pub fn subscribed_instrument_status(&self) -> Vec<InstrumentId> {
self.collect_subscriptions(|client| client.subscribed_instrument_status())
Expand Down
11 changes: 0 additions & 11 deletions nautilus_trader/adapters/betfair/parsing/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from betfair_parser.spec.streaming import RunnerStatus
from betfair_parser.spec.streaming.type_definitions import PV

from nautilus_trader.adapters.betfair.constants import BETFAIR_VENUE
from nautilus_trader.adapters.betfair.constants import CLOSE_PRICE_LOSER
from nautilus_trader.adapters.betfair.constants import CLOSE_PRICE_WINNER
from nautilus_trader.adapters.betfair.constants import MARKET_STATUS_MAPPING
Expand All @@ -48,7 +47,6 @@
from nautilus_trader.model.data import OrderBookDelta
from nautilus_trader.model.data import OrderBookDeltas
from nautilus_trader.model.data import TradeTick
from nautilus_trader.model.data import VenueStatus
from nautilus_trader.model.enums import AggressorSide
from nautilus_trader.model.enums import BookAction
from nautilus_trader.model.enums import InstrumentCloseType
Expand Down Expand Up @@ -179,15 +177,6 @@ def market_definition_to_instrument_status(
) -> list[InstrumentStatus]:
updates = []

if market_definition.in_play:
venue_status = VenueStatus(
venue=BETFAIR_VENUE,
status=MarketStatus.OPEN,
ts_event=ts_event,
ts_init=ts_init,
)
updates.append(venue_status)

for runner in market_definition.runners:
instrument_id = betfair_instrument_id(
market_id=market_id,
Expand Down
11 changes: 0 additions & 11 deletions nautilus_trader/backtest/data_client.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,6 @@ cdef class BacktestMarketDataClient(MarketDataClient):
self._add_subscription_bars(bar_type)
# Do nothing else for backtest

cpdef void subscribe_venue_status(self, Venue venue):
Condition.not_none(venue, "venue")

self._add_subscription_venue_status(venue)
# Do nothing else for backtest

cpdef void subscribe_instrument_status(self, InstrumentId instrument_id):
Condition.not_none(instrument_id, "instrument_id")

Expand Down Expand Up @@ -309,11 +303,6 @@ cdef class BacktestMarketDataClient(MarketDataClient):
self._remove_subscription_instrument_status(instrument_id)
# Do nothing else for backtest

cpdef void unsubscribe_venue_status(self, Venue venue):
Condition.not_none(venue, "venue")

self._remove_subscription_venue_status(venue)

cpdef void unsubscribe_instrument_close(self, InstrumentId instrument_id):
Condition.not_none(instrument_id, "instrument_id")

Expand Down
4 changes: 0 additions & 4 deletions nautilus_trader/backtest/engine.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ from nautilus_trader.model.data cimport OrderBookDelta
from nautilus_trader.model.data cimport OrderBookDeltas
from nautilus_trader.model.data cimport QuoteTick
from nautilus_trader.model.data cimport TradeTick
from nautilus_trader.model.data cimport VenueStatus
from nautilus_trader.model.identifiers cimport ClientId
from nautilus_trader.model.identifiers cimport InstrumentId
from nautilus_trader.model.identifiers cimport TraderId
Expand Down Expand Up @@ -1105,9 +1104,6 @@ cdef class BacktestEngine:
elif isinstance(data, Bar):
venue = self._venues[data.bar_type.instrument_id.venue]
venue.process_bar(data)
elif isinstance(data, VenueStatus):
venue = self._venues[data.venue]
venue.process_venue_status(data)
elif isinstance(data, InstrumentStatus):
venue = self._venues[data.instrument_id.venue]
venue.process_instrument_status(data)
Expand Down
2 changes: 0 additions & 2 deletions nautilus_trader/backtest/exchange.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ from nautilus_trader.model.data cimport OrderBookDelta
from nautilus_trader.model.data cimport OrderBookDeltas
from nautilus_trader.model.data cimport QuoteTick
from nautilus_trader.model.data cimport TradeTick
from nautilus_trader.model.data cimport VenueStatus
from nautilus_trader.model.identifiers cimport InstrumentId
from nautilus_trader.model.identifiers cimport Venue
from nautilus_trader.model.instruments.base cimport Instrument
Expand Down Expand Up @@ -138,7 +137,6 @@ cdef class SimulatedExchange:
cpdef void process_quote_tick(self, QuoteTick tick)
cpdef void process_trade_tick(self, TradeTick tick)
cpdef void process_bar(self, Bar bar)
cpdef void process_venue_status(self, VenueStatus data)
cpdef void process_instrument_status(self, InstrumentStatus data)
cpdef void process(self, uint64_t ts_now)
cpdef void reset(self)
Expand Down
25 changes: 2 additions & 23 deletions nautilus_trader/backtest/exchange.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ from nautilus_trader.model.book cimport OrderBook
from nautilus_trader.model.data cimport InstrumentStatus
from nautilus_trader.model.data cimport QuoteTick
from nautilus_trader.model.data cimport TradeTick
from nautilus_trader.model.data cimport VenueStatus
from nautilus_trader.model.functions cimport account_type_to_str
from nautilus_trader.model.functions cimport oms_type_to_str
from nautilus_trader.model.identifiers cimport InstrumentId
Expand Down Expand Up @@ -783,34 +782,14 @@ cdef class SimulatedExchange:

matching_engine.process_bar(bar)

cpdef void process_venue_status(self, VenueStatus data):
"""
Process the exchange for the given status.
Parameters
----------
data : VenueStatus
The status update to process.
"""
Condition.not_none(data, "data")

cdef SimulationModule module
for module in self.modules:
module.pre_process(data)

cdef OrderMatchingEngine matching_engine
for matching_engine in self._matching_engines.values():
matching_engine.process_status(data.status)

cpdef void process_instrument_status(self, InstrumentStatus data):
"""
Process a specific instrument status.
Parameters
----------
data : VenueStatus
The status update to process.
data : InstrumentStatus
The instrument status update to process.
"""
Condition.not_none(data, "data")
Expand Down
5 changes: 0 additions & 5 deletions nautilus_trader/common/actor.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ from nautilus_trader.model.data cimport InstrumentStatus
from nautilus_trader.model.data cimport OrderBookDeltas
from nautilus_trader.model.data cimport QuoteTick
from nautilus_trader.model.data cimport TradeTick
from nautilus_trader.model.data cimport VenueStatus
from nautilus_trader.model.identifiers cimport ClientId
from nautilus_trader.model.identifiers cimport InstrumentId
from nautilus_trader.model.identifiers cimport Venue
Expand Down Expand Up @@ -86,7 +85,6 @@ cdef class Actor(Component):
cpdef void on_dispose(self)
cpdef void on_degrade(self)
cpdef void on_fault(self)
cpdef void on_venue_status(self, VenueStatus data)
cpdef void on_instrument_status(self, InstrumentStatus data)
cpdef void on_instrument_close(self, InstrumentClose data)
cpdef void on_instrument(self, Instrument instrument)
Expand Down Expand Up @@ -160,7 +158,6 @@ cdef class Actor(Component):
cpdef void subscribe_quote_ticks(self, InstrumentId instrument_id, ClientId client_id=*)
cpdef void subscribe_trade_ticks(self, InstrumentId instrument_id, ClientId client_id=*)
cpdef void subscribe_bars(self, BarType bar_type, ClientId client_id=*, bint await_partial=*)
cpdef void subscribe_venue_status(self, Venue venue, ClientId client_id=*)
cpdef void subscribe_instrument_status(self, InstrumentId instrument_id, ClientId client_id=*)
cpdef void subscribe_instrument_close(self, InstrumentId instrument_id, ClientId client_id=*)
cpdef void unsubscribe_data(self, DataType data_type, ClientId client_id=*)
Expand All @@ -171,7 +168,6 @@ cdef class Actor(Component):
cpdef void unsubscribe_quote_ticks(self, InstrumentId instrument_id, ClientId client_id=*)
cpdef void unsubscribe_trade_ticks(self, InstrumentId instrument_id, ClientId client_id=*)
cpdef void unsubscribe_bars(self, BarType bar_type, ClientId client_id=*)
cpdef void unsubscribe_venue_status(self, Venue venue, ClientId client_id=*)
cpdef void unsubscribe_instrument_status(self, InstrumentId instrument_id, ClientId client_id=*)
cpdef void publish_data(self, DataType data_type, Data data)
cpdef void publish_signal(self, str name, value, uint64_t ts_event=*)
Expand Down Expand Up @@ -248,7 +244,6 @@ cdef class Actor(Component):
cpdef void handle_bar(self, Bar bar)
cpdef void handle_bars(self, list bars)
cpdef void handle_data(self, Data data)
cpdef void handle_venue_status(self, VenueStatus data)
cpdef void handle_instrument_status(self, InstrumentStatus data)
cpdef void handle_instrument_close(self, InstrumentClose data)
cpdef void handle_historical_data(self, data)
Expand Down
Loading

0 comments on commit 65022c1

Please sign in to comment.