Skip to content

Commit 3ad3b50

Browse files
committed
Refine DataActor and Component trait ergonomics
1 parent 726db6b commit 3ad3b50

File tree

10 files changed

+283
-262
lines changed

10 files changed

+283
-262
lines changed

crates/adapters/databento/src/actor.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::ops::{Deref, DerefMut};
2020
use nautilus_common::actor::{DataActor, DataActorCore, data_actor::DataActorConfig};
2121
use nautilus_model::{
2222
data::{QuoteTick, TradeTick},
23-
identifiers::{ActorId, ClientId, InstrumentId},
23+
identifiers::{ClientId, InstrumentId},
2424
};
2525

2626
/// Configuration for the Databento subscriber actor.
@@ -74,18 +74,6 @@ impl DerefMut for DatabentoSubscriberActor {
7474
}
7575

7676
impl DataActor for DatabentoSubscriberActor {
77-
fn actor_id(&self) -> ActorId {
78-
self.core.actor_id()
79-
}
80-
81-
fn core(&self) -> &DataActorCore {
82-
&self.core
83-
}
84-
85-
fn core_mut(&mut self) -> &mut DataActorCore {
86-
&mut self.core
87-
}
88-
8977
fn on_start(&mut self) -> anyhow::Result<()> {
9078
log::info!(
9179
"Starting Databento subscriber actor for {} instruments",

crates/common/examples/greeks_actor_example.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use nautilus_common::{
3131
use nautilus_model::{
3232
data::greeks::GreeksData,
3333
enums::PositionSide,
34-
identifiers::{ActorId, InstrumentId, TraderId},
34+
identifiers::{InstrumentId, TraderId},
3535
};
3636

3737
/// A custom actor that uses the `GreeksCalculator`.
@@ -73,7 +73,7 @@ impl GreeksActor {
7373
let use_cached_greeks = false;
7474
let cache_greeks = true;
7575
let publish_greeks = true;
76-
let ts_event = self.core.generate_timestamp_ns();
76+
let ts_event = self.core.timestamp_ns();
7777
let position = None;
7878
let percent_greeks = false;
7979
let index_instrument_id = None;
@@ -149,8 +149,6 @@ impl GreeksActor {
149149
}
150150
}
151151

152-
// We need to explicitly implement `Deref` for actors to improve API ergonomics.
153-
// In the future we can probably create a macro to do this.
154152
impl Deref for GreeksActor {
155153
type Target = DataActorCore;
156154

@@ -159,27 +157,13 @@ impl Deref for GreeksActor {
159157
}
160158
}
161159

162-
// We need to explicitly implement `DerefMut` for actors to improve API ergonomics.
163-
// In the future we can probably create a macro to do this.
164160
impl DerefMut for GreeksActor {
165161
fn deref_mut(&mut self) -> &mut Self::Target {
166162
&mut self.core
167163
}
168164
}
169165

170166
impl DataActor for GreeksActor {
171-
fn actor_id(&self) -> ActorId {
172-
self.core.actor_id()
173-
}
174-
175-
fn core(&self) -> &DataActorCore {
176-
&self.core
177-
}
178-
179-
fn core_mut(&mut self) -> &mut DataActorCore {
180-
&mut self.core
181-
}
182-
183167
fn on_start(&mut self) -> anyhow::Result<()> {
184168
// Subscribe to greeks data for SPY
185169
self.subscribe_to_greeks("SPY");

0 commit comments

Comments
 (0)