@@ -28,17 +28,32 @@ def __init__(
2828 trader_id : UUID ,
2929 contract_id : str ,
3030 base_url : str ,
31- number_of_orders : int = 2 ,
3231 sample_interval_in_ms : Decimal = Decimal (1000.0 ),
3332 base_drift_in_ms : Decimal = Decimal (1100.0 ),
3433 ):
34+ """
35+ Args:
36+ trader_id: The trader ID.
37+ contract_id: The contract ID.
38+ base_url: The base URL of the exchange.
39+ sample_interval_in_ms: The interval between samples.
40+ base_drift_in_ms: The base drift in milliseconds.
41+
42+ The sample interval is a fixed time interval used to filter the orders when querying.
43+ Each query issued fetches orders placed within the sample interval. This is effectively
44+ used to calculate the value for the `placed_before` filter from the value of the
45+ `placed_at_or_after` filter.
46+
47+ The base drift is the difference between the real time at which an orders query is issued and
48+ the time used to filter orders (i.e. the value used for the `placed_at_or_after` filter).
49+ """
50+
3551 # Configuration
3652 self .base_url = base_url
3753 self .trader_id = trader_id
3854 self .contract_id = contract_id
3955 self .sample_interval_in_ms = sample_interval_in_ms
4056 self .base_drift_in_ms = base_drift_in_ms
41- self .number_of_orders = number_of_orders
4257 self .last_processed_order_timestamp : datetime = datetime .now (timezone .utc )
4358
4459 # Dependencies
@@ -54,6 +69,15 @@ async def get_orders(
5469 start_time : datetime | None = None ,
5570 end_time : datetime | None = None ,
5671 ) -> list [OrderGetResponse ]:
72+ """
73+ Get the orders for the given contract.
74+
75+ Args:
76+ contract_id: The contract ID.
77+ start_time: The start time of the interval.
78+ end_time: The end time of the interval.
79+ """
80+
5781 query_parameters = {
5882 "contract_id" : contract_id ,
5983 "sort_by" : "placed_at" ,
@@ -72,6 +96,13 @@ async def get_orders(
7296 return [OrderGetResponse (** order ) for order in response .json ()]
7397
7498 async def place_order (self , order : OrderAddRequest ) -> OrderAddResponse :
99+ """
100+ Place an order on the exchange.
101+
102+ Args:
103+ order: The order to place.
104+ """
105+
75106 response = await self .exchange_client .post (
76107 url = "/v1/stateless/orders" , json = order .model_dump (mode = "json" )
77108 )
@@ -85,8 +116,13 @@ async def process_orders(
85116 session_stream : AsyncSessionStream ,
86117 ) -> ProcessingResult :
87118 """
88- Orders should be sorted by placed_at in ascending order.
119+ Process the orders for the given contract.
120+
121+ Args:
122+ orders: The orders to process (sorted by `placed_at` in ascending order).
123+ session_stream: A session stream to persist the state changes.
89124 """
125+
90126 processing_result = ProcessingResult (
91127 number_of_orders_processed = 0 ,
92128 last_processed_order_timestamp = None ,
@@ -242,6 +278,10 @@ async def close(self) -> None:
242278def min_and_max_price_for_limit_orders (
243279 orders : list [OrderGetResponse ],
244280) -> tuple [Decimal , Decimal ]:
281+ """
282+ Calculate the minimum and maximum price from the limit orders.
283+ """
284+
245285 limit_bids = [
246286 order .price
247287 for order in orders
0 commit comments