Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Oct 14, 2023
1 parent 5ebf6f8 commit 4043da7
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 103 deletions.
7 changes: 7 additions & 0 deletions docs/concepts/advanced/actors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Actors

The `Strategy` class actually inherits from `Actor`, and additionally provides order management
methods on top. This means everything discussed in the [Strategies](../../concepts/strategies.md) guide
also applies to actors.

This doc is an evolving work in progress and will continue to describe actors more fully…
2 changes: 2 additions & 0 deletions docs/concepts/advanced/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ highest to lowest level (although they are self-contained and can be read in any
:titlesonly:
:hidden:
actors.md
custom_data.md
advanced_orders.md
emulated_orders.md
Expand All @@ -26,6 +27,7 @@ highest to lowest level (although they are self-contained and can be read in any

Explore more advanced concepts of NautilusTrader through these guides:

- [Actors](actors.md)
- [Custom/Generic data](custom_data.md)
- [Advanced Orders](advanced_orders.md)
- [Emulated Orders](emulated_orders.md)
Expand Down
1 change: 1 addition & 0 deletions docs/concepts/architecture.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Architecture

Welcome to the architectural overview of NautilusTrader.

This guide dives deep into the foundational principles, structures, and designs that underpin
the platform. Whether you're a developer, system architect, or just curious about the inner workings
of NautilusTrader, this exposition covers:
Expand Down
31 changes: 30 additions & 1 deletion docs/concepts/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,42 @@ Conceretely, this would involve for example:
- `BinanceOrderBookDeltaDataLoader.load(...)` which reads CSV files provided by Binance from disk, and returns a `pd.DataFrame`
- `OrderBookDeltaDataWrangler.process(...)` which takes the `pd.DataFrame` and returns `list[OrderBookDelta]`

The following example shows how to accomplish the above in Python:
```python
import os

from nautilus_trader import PACKAGE_ROOT
from nautilus_trader.persistence.loaders import BinanceOrderBookDeltaDataLoader
from nautilus_trader.persistence.wranglers import OrderBookDeltaDataWrangler
from nautilus_trader.test_kit.providers import TestInstrumentProvider


# Load raw data
data_path = os.path.join(PACKAGE_ROOT, "tests/test_data/binance-btcusdt-depth-snap.csv")
df = BinanceOrderBookDeltaDataLoader.load(data_path)

# Setup a wrangler
instrument = TestInstrumentProvider.btcusdt_binance()
wrangler = OrderBookDeltaDataWrangler(instrument)

# Process to a list `OrderBookDelta` Nautilus objects
deltas = wrangler.process(df)
```

## Data catalog

The data catalog is a central store for Nautilus data, persisted in the [Parquet](https://parquet.apache.org) file format.

We have chosen parquet as the storage format for the following reasons:
We have chosen Parquet as the storage format for the following reasons:
- It performs much better than CSV/JSON/HDF5/etc in terms of compression ratio (storage size) and read performance
- It does not require any separate running components (for example a database)
- It is quick and simple to get up and running with

The Arrow schemas used for the Parquet format are either single sourced in the core `persistence` Rust library, or available
from the `/serialization/arrow/schema.py` module.

```{note}
2023-10-14: The current plan is to eventually phase out the Python schemas module, so that all schemas are single sourced in the Rust core.
```

**This doc is an evolving work in progress and will continue to describe the data catalog more fully...**
176 changes: 89 additions & 87 deletions docs/concepts/orders.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ For clarity, any optional parameters will be clearly marked with a comment which

## Order Types

The following order types are available for the platform.

### Market
A _Market_ order is an instruction by the trader to immediately trade
the given quantity at the best price available. You can also specify several
Expand All @@ -132,12 +134,12 @@ to BUY 100,000 AUD using USD:

```python
order: MarketOrder = self.order_factory.market(
instrument_id=InstrumentId.from_str("AUD/USD.IDEALPRO"),
order_side=OrderSide.BUY,
quantity=Quantity.from_int(100_000),
time_in_force=TimeInForce.IOC, # <-- optional (default GTC)
reduce_only=False, # <-- optional (default False)
tags="ENTRY", # <-- optional (default None)
instrument_id=InstrumentId.from_str("AUD/USD.IDEALPRO"),
order_side=OrderSide.BUY,
quantity=Quantity.from_int(100_000),
time_in_force=TimeInForce.IOC, # <-- optional (default GTC)
reduce_only=False, # <-- optional (default False)
tags="ENTRY", # <-- optional (default None)
)
```
[API Reference](https://docs.nautilustrader.io/api_reference/model/orders.html#module-nautilus_trader.model.orders.market)
Expand All @@ -151,16 +153,16 @@ contracts at a limit price of 5000 USDT, as a market maker.

```python
order: LimitOrder = self.order_factory.limit(
instrument_id=InstrumentId.from_str("ETHUSDT-PERP.BINANCE"),
order_side=OrderSide.SELL,
quantity=Quantity.from_int(20),
price=Price.from_str("5000.00"),
time_in_force=TimeInForce.GTC, # <-- optional (default GTC)
expire_time=None, # <-- optional (default None)
post_only=True, # <-- optional (default False)
reduce_only=False, # <-- optional (default False)
display_qty=None, # <-- optional (default None which indicates full display)
tags=None, # <-- optional (default None)
instrument_id=InstrumentId.from_str("ETHUSDT-PERP.BINANCE"),
order_side=OrderSide.SELL,
quantity=Quantity.from_int(20),
price=Price.from_str("5000.00"),
time_in_force=TimeInForce.GTC, # <-- optional (default GTC)
expire_time=None, # <-- optional (default None)
post_only=True, # <-- optional (default False)
reduce_only=False, # <-- optional (default False)
display_qty=None, # <-- optional (default None which indicates full display)
tags=None, # <-- optional (default None)
)
```
[API Reference](https://docs.nautilustrader.io/api_reference/model/orders.html#module-nautilus_trader.model.orders.limit)
Expand All @@ -175,15 +177,15 @@ to SELL 1 BTC at a trigger price of 100,000 USDT, active until further notice:

```python
order: StopMarketOrder = self.order_factory.stop_market(
instrument_id=InstrumentId.from_str("BTCUSDT.BINANCE"),
order_side=OrderSide.SELL,
quantity=Quantity.from_int(1),
trigger_price=Price.from_int(100_000),
trigger_type=TriggerType.LAST_TRADE, # <-- optional (default DEFAULT)
time_in_force=TimeInForce.GTC, # <-- optional (default GTC)
expire_time=None, # <-- optional (default None)
reduce_only=False, # <-- optional (default False)
tags=None, # <-- optional (default None)
instrument_id=InstrumentId.from_str("BTCUSDT.BINANCE"),
order_side=OrderSide.SELL,
quantity=Quantity.from_int(1),
trigger_price=Price.from_int(100_000),
trigger_type=TriggerType.LAST_TRADE, # <-- optional (default DEFAULT)
time_in_force=TimeInForce.GTC, # <-- optional (default GTC)
expire_time=None, # <-- optional (default None)
reduce_only=False, # <-- optional (default False)
tags=None, # <-- optional (default None)
)
```
[API Reference](https://docs.nautilustrader.io/api_reference/model/orders.html#module-nautilus_trader.model.orders.stop_market)
Expand All @@ -197,17 +199,17 @@ once the market hits the trigger price of 1.30010 USD, active until midday 6th J

```python
order: StopLimitOrder = self.order_factory.stop_limit(
instrument_id=InstrumentId.from_str("GBP/USD.CURRENEX"),
order_side=OrderSide.BUY,
quantity=Quantity.from_int(50_000),
price=Price.from_str("1.30000"),
trigger_price=Price.from_str("1.30010"),
trigger_type=TriggerType.BID, # <-- optional (default DEFAULT)
time_in_force=TimeInForce.GTD, # <-- optional (default GTC)
expire_time=pd.Timestamp("2022-06-06T12:00"),
post_only=True, # <-- optional (default False)
reduce_only=False, # <-- optional (default False)
tags=None, # <-- optional (default None)
instrument_id=InstrumentId.from_str("GBP/USD.CURRENEX"),
order_side=OrderSide.BUY,
quantity=Quantity.from_int(50_000),
price=Price.from_str("1.30000"),
trigger_price=Price.from_str("1.30010"),
trigger_type=TriggerType.BID, # <-- optional (default DEFAULT)
time_in_force=TimeInForce.GTD, # <-- optional (default GTC)
expire_time=pd.Timestamp("2022-06-06T12:00"),
post_only=True, # <-- optional (default False)
reduce_only=False, # <-- optional (default False)
tags=None, # <-- optional (default None)
)
```
[API Reference](https://docs.nautilustrader.io/api_reference/model/orders.html#module-nautilus_trader.model.orders.stop_limit)
Expand All @@ -222,13 +224,13 @@ to BUY 200,000 USD using JPY:

```python
order: MarketToLimitOrder = self.order_factory.market_to_limit(
instrument_id=InstrumentId.from_str("USD/JPY.IDEALPRO"),
order_side=OrderSide.BUY,
quantity=Quantity.from_int(200_000),
time_in_force=TimeInForce.GTC, # <-- optional (default GTC)
reduce_only=False, # <-- optional (default False)
display_qty=None, # <-- optional (default None which indicates full display)
tags=None, # <-- optional (default None)
instrument_id=InstrumentId.from_str("USD/JPY.IDEALPRO"),
order_side=OrderSide.BUY,
quantity=Quantity.from_int(200_000),
time_in_force=TimeInForce.GTC, # <-- optional (default GTC)
reduce_only=False, # <-- optional (default False)
display_qty=None, # <-- optional (default None which indicates full display)
tags=None, # <-- optional (default None)
)
```

Expand All @@ -245,15 +247,15 @@ to SELL 10 ETHUSDT-PERP Perpetual Futures contracts at a trigger price of 10,000

```python
order: MarketIfTouchedOrder = self.order_factory.market_if_touched(
instrument_id=InstrumentId.from_str("ETHUSDT-PERP.BINANCE"),
order_side=OrderSide.SELL,
quantity=Quantity.from_int(10),
trigger_price=Price.from_int("10000.00"),
trigger_type=TriggerType.LAST_TRADE, # <-- optional (default DEFAULT)
time_in_force=TimeInForce.GTC, # <-- optional (default GTC)
expire_time=None, # <-- optional (default None)
reduce_only=False, # <-- optional (default False)
tags="ENTRY", # <-- optional (default None)
instrument_id=InstrumentId.from_str("ETHUSDT-PERP.BINANCE"),
order_side=OrderSide.SELL,
quantity=Quantity.from_int(10),
trigger_price=Price.from_int("10000.00"),
trigger_type=TriggerType.LAST_TRADE, # <-- optional (default DEFAULT)
time_in_force=TimeInForce.GTC, # <-- optional (default GTC)
expire_time=None, # <-- optional (default None)
reduce_only=False, # <-- optional (default False)
tags="ENTRY", # <-- optional (default None)
)
```

Expand All @@ -269,17 +271,17 @@ active until midday 6th June, 2022 (UTC):

```python
order: StopLimitOrder = self.order_factory.limit_if_touched(
instrument_id=InstrumentId.from_str("BTCUSDT-PERP.BINANCE"),
order_side=OrderSide.BUY,
quantity=Quantity.from_int(5),
price=Price.from_str("30100"),
trigger_price=Price.from_str("30150"),
trigger_type=TriggerType.LAST_TRADE, # <-- optional (default DEFAULT)
time_in_force=TimeInForce.GTD, # <-- optional (default GTC)
expire_time=pd.Timestamp("2022-06-06T12:00"),
post_only=True, # <-- optional (default False)
reduce_only=False, # <-- optional (default False)
tags="TAKE_PROFIT", # <-- optional (default None)
instrument_id=InstrumentId.from_str("BTCUSDT-PERP.BINANCE"),
order_side=OrderSide.BUY,
quantity=Quantity.from_int(5),
price=Price.from_str("30100"),
trigger_price=Price.from_str("30150"),
trigger_type=TriggerType.LAST_TRADE, # <-- optional (default DEFAULT)
time_in_force=TimeInForce.GTD, # <-- optional (default GTC)
expire_time=pd.Timestamp("2022-06-06T12:00"),
post_only=True, # <-- optional (default False)
reduce_only=False, # <-- optional (default False)
tags="TAKE_PROFIT", # <-- optional (default None)
)
```

Expand All @@ -295,17 +297,17 @@ Perpetual Futures Contracts activating at a trigger price of 5000 USD, then trai

```python
order: TrailingStopMarketOrder = self.order_factory.trailing_stop_market(
instrument_id=InstrumentId.from_str("ETHUSD-PERP.BINANCE"),
order_side=OrderSide.SELL,
quantity=Quantity.from_int(10),
trigger_price=Price.from_str("5000"),
trigger_type=TriggerType.LAST_TRADE, # <-- optional (default DEFAULT)
trailing_offset=Decimal(100),
trailing_offset_type=TrailingOffsetType.BASIS_POINTS,
time_in_force=TimeInForce.GTC, # <-- optional (default GTC)
expire_time=None, # <-- optional (default None)
reduce_only=True, # <-- optional (default False)
tags="TRAILING_STOP-1", # <-- optional (default None)
instrument_id=InstrumentId.from_str("ETHUSD-PERP.BINANCE"),
order_side=OrderSide.SELL,
quantity=Quantity.from_int(10),
trigger_price=Price.from_str("5000"),
trigger_type=TriggerType.LAST_TRADE, # <-- optional (default DEFAULT)
trailing_offset=Decimal(100),
trailing_offset_type=TrailingOffsetType.BASIS_POINTS,
time_in_force=TimeInForce.GTC, # <-- optional (default GTC)
expire_time=None, # <-- optional (default None)
reduce_only=True, # <-- optional (default False)
tags="TRAILING_STOP-1", # <-- optional (default None)
)
```

Expand All @@ -322,19 +324,19 @@ away from the current ask price, active until further notice:

```python
order: TrailingStopLimitOrder = self.order_factory.trailing_stop_limit(
instrument_id=InstrumentId.from_str("AUD/USD.CURRENEX"),
order_side=OrderSide.BUY,
quantity=Quantity.from_int(1_250_000),
price=Price.from_str("0.71000"),
trigger_price=Price.from_str("0.72000"),
trigger_type=TriggerType.BID_ASK, # <-- optional (default DEFAULT)
limit_offset=Decimal("0.00050"),
trailing_offset=Decimal("0.00100"),
trailing_offset_type=TrailingOffsetType.PRICE,
time_in_force=TimeInForce.GTC, # <-- optional (default GTC)
expire_time=None, # <-- optional (default None)
reduce_only=True, # <-- optional (default False)
tags="TRAILING_STOP", # <-- optional (default None)
instrument_id=InstrumentId.from_str("AUD/USD.CURRENEX"),
order_side=OrderSide.BUY,
quantity=Quantity.from_int(1_250_000),
price=Price.from_str("0.71000"),
trigger_price=Price.from_str("0.72000"),
trigger_type=TriggerType.BID_ASK, # <-- optional (default DEFAULT)
limit_offset=Decimal("0.00050"),
trailing_offset=Decimal("0.00100"),
trailing_offset_type=TrailingOffsetType.PRICE,
time_in_force=TimeInForce.GTC, # <-- optional (default GTC)
expire_time=None, # <-- optional (default None)
reduce_only=True, # <-- optional (default False)
tags="TRAILING_STOP", # <-- optional (default None)
)
```

Expand Down
Loading

0 comments on commit 4043da7

Please sign in to comment.