Skip to content

Commit

Permalink
Record new feed messages and update feed handler replay tests; add CI (
Browse files Browse the repository at this point in the history
…#26)

* Record new messages and update feed handler test for current protos

* Update broken order unit tests

* Add CI on push / PR to main
  • Loading branch information
matthewdowney authored Dec 19, 2024
1 parent b44fb8f commit a873010
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 11 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Unit Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3

# Set up Python
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: '3.x'

# Install dependencies
- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Run the unit tests
- name: Run unit tests
run: |
source venv/bin/activate
python -m unittest discover -s test
Binary file modified test/assets/feed_from_t0.log
Binary file not shown.
Binary file modified test/assets/feed_from_t1.log
Binary file not shown.
10 changes: 5 additions & 5 deletions test/test_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def o(addr, subacc, cid, is_bid, quantums, subticks):
return Order(OrderId(addr, subacc, cid), is_bid, quantums, quantums, subticks)
return Order(OrderId(addr, subacc, cid, 0), is_bid, quantums, quantums, subticks)


class TestLimitOrderBook(unittest.TestCase):
Expand Down Expand Up @@ -53,11 +53,11 @@ def test_order_removal(self):
self.lob.add_order(order)

# Remove an order and check the state
self.lob.remove_order(OrderId("address1", 1, 101))
self.assertTrue(OrderId("address1", 1, 101) not in self.lob._bids[50])
self.lob.remove_order(OrderId("address1", 1, 101, 0))
self.assertTrue(OrderId("address1", 1, 101, 0) not in self.lob._bids[50])

self.lob.remove_order(OrderId("address3", 1, 103))
self.assertTrue(OrderId("address3", 1, 103) not in self.lob._asks[51])
self.lob.remove_order(OrderId("address3", 1, 103, 0))
self.assertTrue(OrderId("address3", 1, 103, 0) not in self.lob._asks[51])

# Verify remaining orders maintain the correct order
remaining_bid = self.lob._bids[50].head.data
Expand Down
12 changes: 6 additions & 6 deletions test/test_feed_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ def test_replay_state(self):

# Check best bid and ask prices and sizes
best_bid: lob.Order = next(self.snapshot_state.books[0].bids())
self.assertEqual(130932877, best_bid.order_id.client_id)
self.assertEqual(500000000, best_bid.quantums)
self.assertEqual(6037200000, best_bid.subticks)
self.assertEqual(900722659, best_bid.order_id.client_id)
self.assertEqual(839000000, best_bid.quantums)
self.assertEqual(10033200000, best_bid.subticks)

best_ask: lob.Order = next(self.snapshot_state.books[0].asks())
self.assertEqual(130932874, best_ask.order_id.client_id)
self.assertEqual(30000000, best_ask.quantums)
self.assertEqual(6037300000, best_ask.subticks)
self.assertEqual(1393832, best_ask.order_id.client_id)
self.assertEqual(896000000, best_ask.quantums)
self.assertEqual(10033300000, best_ask.subticks)


def asks_bids_from_feed(
Expand Down

0 comments on commit a873010

Please sign in to comment.