Skip to content

Commit

Permalink
Rename TradeReport to FillReport
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Dec 30, 2023
1 parent bccf3e0 commit d46b231
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 120 deletions.
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Released on TBD (UTC).
- Changed `ComponentStateChanged` Arrow schema for `config` from `string` to `binary`
- Changed `OrderInitialized` Arrow schema for `options` from `string` to `binary`
- Changed `OrderBookDeltas` dictionary representation of `deltas` field from JSON `bytes` to a list of `dict` (standardize with all other data types)
- Renamed `TradeReport` to `FillReport` (more conventional terminology, and more clearly separates market data from user execution reports)
- Renamed `AssetType` enum to `InstrumentClass` (more conventional terminology)
- Renamed `asset_type` to `instrument_class` across the codebase (more conventional terminology)
- Renamed `AssetClass.BOND` to `AssetClass.DEBT` (more conventional terminology)
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/ib.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ data_client_config = InteractiveBrokersDataClientConfig(

### Execution Client

The `InteractiveBrokersExecutionClient` facilitates executing trades, accessing account information, and processing order and trade-related details. It encompasses a range of methods for order management, including reporting order statuses, placing new orders, and modifying or canceling existing ones. Additionally, it generates position reports, although trade reports are not yet implemented.
The `InteractiveBrokersExecutionClient` facilitates executing trades, accessing account information, and processing order and trade-related details. It encompasses a range of methods for order management, including reporting order statuses, placing new orders, and modifying or canceling existing ones. Additionally, it generates position reports, although fill reports are not yet implemented.

```python
from nautilus_trader.adapters.interactive_brokers.config import InteractiveBrokersExecClientConfig
Expand Down
10 changes: 5 additions & 5 deletions nautilus_trader/adapters/_template/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
from nautilus_trader.execution.messages import QueryOrder
from nautilus_trader.execution.messages import SubmitOrder
from nautilus_trader.execution.messages import SubmitOrderList
from nautilus_trader.execution.reports import FillReport
from nautilus_trader.execution.reports import OrderStatusReport
from nautilus_trader.execution.reports import PositionStatusReport
from nautilus_trader.execution.reports import TradeReport
from nautilus_trader.live.execution_client import LiveExecutionClient
from nautilus_trader.model.identifiers import ClientOrderId
from nautilus_trader.model.identifiers import InstrumentId
Expand Down Expand Up @@ -60,7 +60,7 @@ class TemplateLiveExecutionClient(LiveExecutionClient):
| _cancel_all_orders | required |
| generate_order_status_report | required |
| generate_order_status_reports | required |
| generate_trade_reports | required |
| generate_fill_reports | required |
| generate_position_status_reports | required |
+--------------------------------------------+-------------+
Expand Down Expand Up @@ -109,15 +109,15 @@ async def generate_order_status_reports(
"method `generate_order_status_reports` must be implemented in the subclass",
) # pragma: no cover

async def generate_trade_reports(
async def generate_fill_reports(
self,
instrument_id: InstrumentId | None = None,
venue_order_id: VenueOrderId | None = None,
start: pd.Timestamp | None = None,
end: pd.Timestamp | None = None,
) -> list[TradeReport]:
) -> list[FillReport]:
raise NotImplementedError(
"method `generate_trade_reports` must be implemented in the subclass",
"method `generate_fill_reports` must be implemented in the subclass",
) # pragma: no cover

async def generate_position_status_reports(
Expand Down
8 changes: 4 additions & 4 deletions nautilus_trader/adapters/betfair/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
from nautilus_trader.execution.messages import CancelOrder
from nautilus_trader.execution.messages import ModifyOrder
from nautilus_trader.execution.messages import SubmitOrder
from nautilus_trader.execution.reports import FillReport
from nautilus_trader.execution.reports import OrderStatusReport
from nautilus_trader.execution.reports import PositionStatusReport
from nautilus_trader.execution.reports import TradeReport
from nautilus_trader.live.execution_client import LiveExecutionClient
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import LiquiditySide
Expand Down Expand Up @@ -248,14 +248,14 @@ async def generate_order_status_reports(

return []

async def generate_trade_reports(
async def generate_fill_reports(
self,
instrument_id: InstrumentId | None = None,
venue_order_id: VenueOrderId | None = None,
start: pd.Timestamp | None = None,
end: pd.Timestamp | None = None,
) -> list[TradeReport]:
self._log.warning("Cannot generate `TradeReports`: not yet implemented.")
) -> list[FillReport]:
self._log.warning("Cannot generate `FillReports`: not yet implemented.")

return []

Expand Down
6 changes: 3 additions & 3 deletions nautilus_trader/adapters/betfair/parsing/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
from nautilus_trader.execution.messages import CancelOrder
from nautilus_trader.execution.messages import ModifyOrder
from nautilus_trader.execution.messages import SubmitOrder
from nautilus_trader.execution.reports import FillReport
from nautilus_trader.execution.reports import OrderStatusReport
from nautilus_trader.execution.reports import TradeReport
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import ContingencyType
from nautilus_trader.model.enums import LiquiditySide
Expand Down Expand Up @@ -321,7 +321,7 @@ async def generate_trades_list(
venue_order_id: VenueOrderId,
symbol: Symbol,
since: datetime | None = None,
) -> list[TradeReport]:
) -> list[FillReport]:
filled = self.client().betting.list_cleared_orders(
bet_ids=[venue_order_id],
)
Expand All @@ -331,7 +331,7 @@ async def generate_trades_list(
fill = filled["clearedOrders"][0]
ts_event = pd.Timestamp(fill["lastMatchedDate"]).value
return [
TradeReport(
FillReport(
client_order_id=self.venue_order_id_to_client_order_id[venue_order_id],
instrument_id=None, # TODO: Needs this
account_id=None, # TODO: Needs this
Expand Down
6 changes: 3 additions & 3 deletions nautilus_trader/adapters/betfair/parsing/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from nautilus_trader.adapters.betfair.parsing.common import betfair_instrument_id
from nautilus_trader.adapters.betfair.parsing.common import hash_market_trade
from nautilus_trader.core.uuid import UUID4
from nautilus_trader.execution.reports import TradeReport
from nautilus_trader.execution.reports import FillReport
from nautilus_trader.model.data import NULL_ORDER
from nautilus_trader.model.data import BookOrder
from nautilus_trader.model.data import InstrumentClose
Expand Down Expand Up @@ -539,7 +539,7 @@ async def generate_trades_list(
venue_order_id: VenueOrderId,
symbol: Symbol,
since: datetime | None = None,
) -> list[TradeReport]:
) -> list[FillReport]:
filled: list[ClearedOrderSummary] = self.client().betting.list_cleared_orders(
bet_ids=[venue_order_id],
)
Expand All @@ -549,7 +549,7 @@ async def generate_trades_list(
fill = filled[0]
ts_event = pd.Timestamp(fill.last_matched_date).value
return [
TradeReport(
FillReport(
account_id=AccountId("BETFAIR"),
instrument_id=betfair_instrument_id(
fill.market_id,
Expand Down
16 changes: 8 additions & 8 deletions nautilus_trader/adapters/binance/common/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
from nautilus_trader.execution.messages import ModifyOrder
from nautilus_trader.execution.messages import SubmitOrder
from nautilus_trader.execution.messages import SubmitOrderList
from nautilus_trader.execution.reports import FillReport
from nautilus_trader.execution.reports import OrderStatusReport
from nautilus_trader.execution.reports import PositionStatusReport
from nautilus_trader.execution.reports import TradeReport
from nautilus_trader.live.execution_client import LiveExecutionClient
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
Expand Down Expand Up @@ -479,14 +479,14 @@ async def generate_order_status_reports(

return reports

async def generate_trade_reports(
async def generate_fill_reports(
self,
instrument_id: InstrumentId | None = None,
venue_order_id: VenueOrderId | None = None,
start: pd.Timestamp | None = None,
end: pd.Timestamp | None = None,
) -> list[TradeReport]:
self._log.info("Requesting TradeReports...")
) -> list[FillReport]:
self._log.info("Requesting FillReports...")

try:
# Check Binance for all trades on active symbols
Expand All @@ -502,16 +502,16 @@ async def generate_trade_reports(
)
binance_trades.extend(response)
except BinanceError as e:
self._log.exception(f"Cannot generate TradeReport: {e.message}", e)
self._log.exception(f"Cannot generate FillReport: {e.message}", e)
return []

# Parse all Binance trades
reports: list[TradeReport] = []
reports: list[FillReport] = []
for trade in binance_trades:
if trade.symbol is None:
self._log.warning(f"No symbol for trade {trade}.")
continue
report = trade.parse_to_trade_report(
report = trade.parse_to_fill_report(
account_id=self.account_id,
instrument_id=self._get_cached_instrument_id(trade.symbol),
report_id=UUID4(),
Expand All @@ -526,7 +526,7 @@ async def generate_trade_reports(

len_reports = len(reports)
plural = "" if len_reports == 1 else "s"
self._log.info(f"Received {len(reports)} TradeReport{plural}.")
self._log.info(f"Received {len(reports)} FillReport{plural}.")

return reports

Expand Down
8 changes: 4 additions & 4 deletions nautilus_trader/adapters/binance/common/schemas/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from nautilus_trader.adapters.binance.common.enums import BinanceTimeInForce
from nautilus_trader.core.datetime import millis_to_nanos
from nautilus_trader.core.uuid import UUID4
from nautilus_trader.execution.reports import FillReport
from nautilus_trader.execution.reports import OrderStatusReport
from nautilus_trader.execution.reports import TradeReport
from nautilus_trader.model.enums import ContingencyType
from nautilus_trader.model.enums import LiquiditySide
from nautilus_trader.model.enums import OrderSide
Expand Down Expand Up @@ -85,22 +85,22 @@ class BinanceUserTrade(msgspec.Struct, frozen=True):
baseQty: str | None = None # COIN-M FUTURES only
pair: str | None = None # COIN-M FUTURES only

def parse_to_trade_report(
def parse_to_fill_report(
self,
account_id: AccountId,
instrument_id: InstrumentId,
report_id: UUID4,
ts_init: int,
use_position_ids: bool = True,
) -> TradeReport:
) -> FillReport:
venue_position_id: PositionId | None = None
if self.positionSide is not None and use_position_ids:
venue_position_id = PositionId(f"{instrument_id}-{self.positionSide}")

order_side = OrderSide.BUY if self.isBuyer or self.buyer else OrderSide.SELL
liquidity_side = LiquiditySide.MAKER if self.isMaker or self.maker else LiquiditySide.TAKER

return TradeReport(
return FillReport(
account_id=account_id,
instrument_id=instrument_id,
venue_order_id=VenueOrderId(str(self.orderId)),
Expand Down
8 changes: 4 additions & 4 deletions nautilus_trader/adapters/bybit/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
from nautilus_trader.core.uuid import UUID4
from nautilus_trader.execution.messages import CancelAllOrders
from nautilus_trader.execution.messages import SubmitOrder
from nautilus_trader.execution.reports import FillReport
from nautilus_trader.execution.reports import OrderStatusReport
from nautilus_trader.execution.reports import PositionStatusReport
from nautilus_trader.execution.reports import TradeReport
from nautilus_trader.live.execution_client import LiveExecutionClient
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
Expand Down Expand Up @@ -240,14 +240,14 @@ async def generate_order_status_report(
self._log.error(f"Failed to generate OrderStatusReport: {e}")
return None

async def generate_trade_reports(
async def generate_fill_reports(
self,
instrument_id: InstrumentId | None = None,
venue_order_id: VenueOrderId | None = None,
start: pd.Timestamp | None = None,
end: pd.Timestamp | None = None,
) -> list[TradeReport]:
self._log.info("Requesting TradeReports...")
) -> list[FillReport]:
self._log.info("Requesting FillReports...")
return []

async def generate_position_status_reports(
Expand Down
12 changes: 6 additions & 6 deletions nautilus_trader/adapters/interactive_brokers/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
from nautilus_trader.execution.messages import ModifyOrder
from nautilus_trader.execution.messages import SubmitOrder
from nautilus_trader.execution.messages import SubmitOrderList
from nautilus_trader.execution.reports import FillReport
from nautilus_trader.execution.reports import OrderStatusReport
from nautilus_trader.execution.reports import PositionStatusReport
from nautilus_trader.execution.reports import TradeReport
from nautilus_trader.live.execution_client import LiveExecutionClient
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import LiquiditySide
Expand Down Expand Up @@ -400,15 +400,15 @@ async def generate_order_status_reports(
report.append(order_status)
return report

async def generate_trade_reports(
async def generate_fill_reports(
self,
instrument_id: InstrumentId | None = None,
venue_order_id: VenueOrderId | None = None,
start: pd.Timestamp | None = None,
end: pd.Timestamp | None = None,
) -> list[TradeReport]:
) -> list[FillReport]:
"""
Generate a list of `TradeReport`s with optional query filters. The returned list
Generate a list of `FillReport`s with optional query filters. The returned list
may be empty if no trades match the given parameters.
Parameters
Expand All @@ -424,10 +424,10 @@ async def generate_trade_reports(
Returns
-------
list[TradeReport]
list[FillReport]
"""
self._log.warning("Cannot generate `list[TradeReport]`: not yet implemented.")
self._log.warning("Cannot generate `list[FillReport]`: not yet implemented.")

return [] # TODO: Implement

Expand Down
6 changes: 3 additions & 3 deletions nautilus_trader/adapters/sandbox/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
from nautilus_trader.common.logging import Logger
from nautilus_trader.common.providers import InstrumentProvider
from nautilus_trader.core.data import Data
from nautilus_trader.execution.reports import FillReport
from nautilus_trader.execution.reports import OrderStatusReport
from nautilus_trader.execution.reports import PositionStatusReport
from nautilus_trader.execution.reports import TradeReport
from nautilus_trader.live.execution_client import LiveExecutionClient
from nautilus_trader.model.data import Bar
from nautilus_trader.model.data import OrderBookDelta
Expand Down Expand Up @@ -173,13 +173,13 @@ async def generate_order_status_reports(
) -> list[OrderStatusReport]:
return []

async def generate_trade_reports(
async def generate_fill_reports(
self,
instrument_id: InstrumentId | None = None,
venue_order_id: VenueOrderId | None = None,
start: pd.Timestamp | None = None,
end: pd.Timestamp | None = None,
) -> list[TradeReport]:
) -> list[FillReport]:
return []

async def generate_position_status_reports(
Expand Down
2 changes: 1 addition & 1 deletion nautilus_trader/execution/client.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,4 @@ cdef class ExecutionClient(Component):
cpdef void _send_order_event(self, OrderEvent event)
cpdef void _send_mass_status_report(self, report)
cpdef void _send_order_status_report(self, report)
cpdef void _send_trade_report(self, report)
cpdef void _send_fill_report(self, report)
4 changes: 2 additions & 2 deletions nautilus_trader/execution/client.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

from nautilus_trader.config.common import NautilusConfig
from nautilus_trader.execution.reports import ExecutionMassStatus
from nautilus_trader.execution.reports import FillReport
from nautilus_trader.execution.reports import OrderStatusReport
from nautilus_trader.execution.reports import TradeReport

from libc.stdint cimport uint64_t

Expand Down Expand Up @@ -816,7 +816,7 @@ cdef class ExecutionClient(Component):
msg=report,
)

cpdef void _send_trade_report(self, report: TradeReport):
cpdef void _send_fill_report(self, report: FillReport):
self._msgbus.send(
endpoint="ExecEngine.reconcile_report",
msg=report,
Expand Down
Loading

0 comments on commit d46b231

Please sign in to comment.