Skip to content

Commit

Permalink
collect total asks and bids
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoon committed Nov 19, 2023
1 parent c2e417f commit 2443f84
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions datacollector/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class AssetDataEntry:
mid_price: Decimal
best_bid: Decimal
best_ask: Decimal
total_ask: float
total_bid: float
total_ask_1: float
total_ask_4: float
total_bid_1: float
Expand Down
2 changes: 2 additions & 0 deletions datacollector/services/data_process_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def compute_data_entry(self, ob: DepthCache, current_time: datetime) -> AssetDat
mid_price=mid_price,
best_bid=best_bid,
best_ask=best_ask,
total_ask=len(asks),
total_bid=len(bids),
total_ask_1=ask_d1,
total_ask_4=ask_d4,
total_bid_1=bid_d1,
Expand Down
2 changes: 1 addition & 1 deletion tests/datacollector/services/data_process_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_compute_data_entry(self):

result = self.service.compute_data_entry(mock_depth_cache, self.dt_service.get_datetime())
correct_result = AssetDataEntry(mid_price=Decimal(99.5), best_ask=Decimal(100), best_bid=Decimal(99),
book_bias_1=0.0, book_bias_4=0.0,
book_bias_1=0.0, book_bias_4=0.0, total_ask=2, total_bid=2,
total_ask_1=1, total_bid_1=1, total_ask_4=3, total_bid_4=3,
current_time=self.dt_service.get_datetime(), last_book_update=self.dt_service.get_datetime())

Expand Down

0 comments on commit 2443f84

Please sign in to comment.