Skip to content

Commit

Permalink
Refine docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Oct 22, 2023
1 parent 80f9345 commit d2c84ce
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
23 changes: 20 additions & 3 deletions nautilus_trader/persistence/catalog/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def _objects_to_table(self, data: list[Data], data_cls: type) -> pa.Table:
for original, sorted_version in zip(data, sorted_data):
if original.ts_init != sorted_version.ts_init:
raise ValueError(
"Data should be sorted in ascending order or remain constant based on `ts_init`: "
"Data should be monotonically increasing (or non-decreasing) based on `ts_init`: "
f"found {original.ts_init} followed by {sorted_version.ts_init}. "
"Consider sorting your data with something like "
"`data.sort(key=lambda x: x.ts_init)` prior to writing to the catalog.",
Expand Down Expand Up @@ -266,12 +266,29 @@ def write_data(self, data: list[Data | Event], **kwargs: Any) -> None:
"""
Write the given `data` to the catalog.
The function categorizes the data based on their class name and, when applicable, their
associated instrument ID. It then delegates the actual writing process to the
`write_chunk` method.
Parameters
----------
data : list[Data | Event]
The data to write.
The data or event objects to be written to the catalog.
kwargs : Any
The key-word arguments.
Additional keyword arguments to be passed to the `write_chunk` method.
Notes
-----
- All data of the same type is expected to be monotonically increasing, or non-decreasing
- The data is sorted and grouped based on its class name and instrument ID (if applicable) before writing
- Instrument-specific data should have either an `instrument_id` attribute or be an instance of `Instrument`
- The `Bar` class is treated as a special case, being grouped based on its `bar_type` attribute
- The input data list must be non-empty, and all data items must be of the appropriate class type
Raises
------
ValueError
If data of the same type is not monotonically increasing (or non-decreasing) based on `ts_init`.
"""

Expand Down
12 changes: 6 additions & 6 deletions nautilus_trader/trading/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def start_actor(self, actor: Actor) -> None:
Raises
------
ValueError:
ValueError
If `actor` is not already registered with the trader.
"""
Expand All @@ -120,7 +120,7 @@ def start_strategy(self, strategy: Strategy) -> None:
Raises
------
ValueError:
ValueError
If `strategy` is not already registered with the trader.
"""
Expand All @@ -139,7 +139,7 @@ def stop_actor(self, actor: Actor) -> None:
Raises
------
ValueError:
ValueError
If `actor` is not already registered with the trader.
"""
Expand All @@ -158,7 +158,7 @@ def stop_strategy(self, strategy: Strategy) -> None:
Raises
------
ValueError:
ValueError
If `strategy` is not already registered with the trader.
"""
Expand All @@ -177,7 +177,7 @@ def remove_actor(self, actor: Actor) -> None:
Raises
------
ValueError:
ValueError
If `actor` is not already registered with the trader.
"""
Expand All @@ -196,7 +196,7 @@ def remove_strategy(self, strategy: Strategy) -> None:
Raises
------
ValueError:
ValueError
If `strategy` is not already registered with the trader.
"""
Expand Down
12 changes: 6 additions & 6 deletions nautilus_trader/trading/trader.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def start_actor(self, actor_id: ComponentId) -> None:
Raises
------
ValueError:
ValueError
If an actor with the given `actor_id` is not found.
"""
Expand All @@ -546,7 +546,7 @@ def start_strategy(self, strategy_id: StrategyId) -> None:
Raises
------
ValueError:
ValueError
If a strategy with the given `strategy_id` is not found.
"""
Expand All @@ -573,7 +573,7 @@ def stop_actor(self, actor_id: ComponentId) -> None:
Raises
------
ValueError:
ValueError
If an actor with the given `actor_id` is not found.
"""
Expand All @@ -600,7 +600,7 @@ def stop_strategy(self, strategy_id: StrategyId) -> None:
Raises
------
ValueError:
ValueError
If a strategy with the given `strategy_id` is not found.
"""
Expand Down Expand Up @@ -629,7 +629,7 @@ def remove_actor(self, actor_id: ComponentId) -> None:
Raises
------
ValueError:
ValueError
If an actor with the given `actor_id` is not found.
"""
Expand Down Expand Up @@ -657,7 +657,7 @@ def remove_strategy(self, strategy_id: StrategyId) -> None:
Raises
------
ValueError:
ValueError
If a strategy with the given `strategy_id` is not found.
"""
Expand Down

0 comments on commit d2c84ce

Please sign in to comment.