Skip to content

Commit e0fc34b

Browse files
committed
Add Rust docs
1 parent 509392b commit e0fc34b

File tree

12 files changed

+24
-7
lines changed

12 files changed

+24
-7
lines changed

nautilus_core/core/src/datetime.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub fn floor_to_nearest_microsecond(unix_nanos: u64) -> u64 {
100100
(unix_nanos / NANOSECONDS_IN_MICROSECOND) * NANOSECONDS_IN_MICROSECOND
101101
}
102102

103+
/// Calculates the last weekday (Mon-Fri) from the given `year`, `month` and `day`.
103104
pub fn last_weekday_nanos(year: i32, month: u32, day: u32) -> anyhow::Result<UnixNanos> {
104105
let date =
105106
NaiveDate::from_ymd_opt(year, month, day).ok_or_else(|| anyhow::anyhow!("Invalid date"))?;
@@ -128,6 +129,7 @@ pub fn last_weekday_nanos(year: i32, month: u32, day: u32) -> anyhow::Result<Uni
128129
))
129130
}
130131

132+
/// Check whether the given UNIX nanoseconds timestamp is within the last 24 hours.
131133
pub fn is_within_last_24_hours(timestamp_ns: UnixNanos) -> anyhow::Result<bool> {
132134
let timestamp_ns = timestamp_ns.as_u64();
133135
let seconds = timestamp_ns / NANOSECONDS_IN_SECOND;

nautilus_core/core/src/parsing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn precision_from_str(s: &str) -> u8 {
2929
return lower_s.split('.').last().unwrap().len() as u8;
3030
}
3131

32-
/// Returns a usize from the given bytes.
32+
/// Returns a `usize` from the given bytes.
3333
pub fn bytes_to_usize(bytes: &[u8]) -> anyhow::Result<usize> {
3434
// Check bytes width
3535
if bytes.len() >= std::mem::size_of::<usize>() {

nautilus_core/model/src/currencies.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,7 @@ impl Currency {
988988
}
989989
}
990990

991+
/// Provides a map of built-in `Currency` constants.
991992
pub static CURRENCY_MAP: Lazy<Mutex<HashMap<String, Currency>>> = Lazy::new(|| {
992993
let mut map = HashMap::new();
993994
///////////////////////////////////////////////////////////////////////////

nautilus_core/model/src/data/bar.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// limitations under the License.
1414
// -------------------------------------------------------------------------------------------------
1515

16+
//! Bar aggregate structures, data types and functionality.
17+
1618
use std::{
1719
collections::HashMap,
1820
fmt::{Debug, Display, Formatter},

nautilus_core/model/src/data/delta.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// limitations under the License.
1414
// -------------------------------------------------------------------------------------------------
1515

16+
//! An `OrderBookDelta` data type intended to carry book state information.
17+
1618
use std::{
1719
collections::HashMap,
1820
fmt::{Display, Formatter},

nautilus_core/model/src/data/deltas.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// limitations under the License.
1414
// -------------------------------------------------------------------------------------------------
1515

16+
//! An `OrderBookDeltas` container type to carry a bulk of `OrderBookDelta` records.
17+
1618
use std::{
1719
fmt::{Display, Formatter},
1820
hash::{Hash, Hasher},

nautilus_core/model/src/data/depth.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// limitations under the License.
1414
// -------------------------------------------------------------------------------------------------
1515

16+
//! An `OrderBookDepth10` aggregated top-of-book data type with a fixed depth of 10 levels per side.
17+
1618
use std::{
1719
collections::HashMap,
1820
fmt::{Display, Formatter},
@@ -27,9 +29,9 @@ use crate::identifiers::instrument_id::InstrumentId;
2729

2830
pub const DEPTH10_LEN: usize = 10;
2931

30-
/// Represents a self-contained order book update with a fixed depth of 10 levels per side.
32+
/// Represents a aggregated order book update with a fixed depth of 10 levels per side.
3133
///
32-
/// This struct is specifically designed for scenarios where a snapshot of the top 10 bid and
34+
/// This structure is specifically designed for scenarios where a snapshot of the top 10 bid and
3335
/// ask levels in an order book is needed. It differs from `OrderBookDelta` or `OrderBookDeltas`
3436
/// in its fixed-depth nature and is optimized for cases where a full depth representation is not
3537
/// required or practical.

nautilus_core/model/src/data/order.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// limitations under the License.
1414
// -------------------------------------------------------------------------------------------------
1515

16+
//! A `BookOrder` for use with the `OrderBookDelta` data type.
17+
1618
use std::{
1719
fmt::{Display, Formatter},
1820
hash::{Hash, Hasher},

nautilus_core/model/src/data/quote.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// limitations under the License.
1414
// -------------------------------------------------------------------------------------------------
1515

16+
//! A `QuoteTick` data type representing a top-of-book quote state.
17+
1618
use std::{
1719
cmp,
1820
collections::HashMap,

nautilus_core/model/src/data/trade.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// limitations under the License.
1414
// -------------------------------------------------------------------------------------------------
1515

16+
//! A `TradeTick` data type representing a single trade in a market.
17+
1618
use std::{
1719
collections::HashMap,
1820
fmt::{Display, Formatter},

nautilus_trader/core/includes/model.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,9 @@ typedef struct OrderBookDeltas_API {
838838
} OrderBookDeltas_API;
839839

840840
/**
841-
* Represents a self-contained order book update with a fixed depth of 10 levels per side.
841+
* Represents a aggregated order book update with a fixed depth of 10 levels per side.
842842
*
843-
* This struct is specifically designed for scenarios where a snapshot of the top 10 bid and
843+
* This structure is specifically designed for scenarios where a snapshot of the top 10 bid and
844844
* ask levels in an order book is needed. It differs from `OrderBookDelta` or `OrderBookDeltas`
845845
* in its fixed-depth nature and is optimized for cases where a full depth representation is not
846846
* required or practical.

nautilus_trader/core/rust/model.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,9 @@ cdef extern from "../includes/model.h":
462462
cdef struct OrderBookDeltas_API:
463463
OrderBookDeltas_t *_0;
464464

465-
# Represents a self-contained order book update with a fixed depth of 10 levels per side.
465+
# Represents a aggregated order book update with a fixed depth of 10 levels per side.
466466
#
467-
# This struct is specifically designed for scenarios where a snapshot of the top 10 bid and
467+
# This structure is specifically designed for scenarios where a snapshot of the top 10 bid and
468468
# ask levels in an order book is needed. It differs from `OrderBookDelta` or `OrderBookDeltas`
469469
# in its fixed-depth nature and is optimized for cases where a full depth representation is not
470470
# required or practical.

0 commit comments

Comments
 (0)