-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Benchmark order matching * Add benchmark to github action * Add benchmark to github action * fix actions setup * fix actions setup * Save histogram * Save histogram
- Loading branch information
Stanislav Khrapov
authored
Feb 7, 2023
1 parent
2584d5f
commit 33fd5f2
Showing
7 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# Run pytest benchmark. Results are saved in .benchmarks | ||
pytest tests/test_matching_engine.py::TestMatchingEngine::test_matching_with_benchmark \ | ||
--dist no \ | ||
--benchmark-enable \ | ||
--benchmark-autosave \ | ||
--benchmark-json=benchmark.json | ||
|
||
# Compare saved results | ||
pytest-benchmark compare --histogram=benchmark_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pandas as pd | ||
import pytest | ||
|
||
from order_matching.order import LimitOrder | ||
from order_matching.orders import Orders | ||
from order_matching.random import get_faker, get_random_generator | ||
from order_matching.side import Side | ||
|
||
|
||
@pytest.fixture | ||
def random_orders() -> Orders: | ||
faker = get_faker() | ||
rng = get_random_generator(seed=42) | ||
orders_per_timestamp, number_of_time_points = 100, 10 | ||
time_intervals = rng.uniform(low=0, high=1, size=number_of_time_points) | ||
random_timestamps = pd.Timestamp(2023, 1, 1) + pd.to_timedelta(time_intervals.cumsum(), unit="D") | ||
orders = list() | ||
for timestamp in random_timestamps: | ||
prices = rng.lognormal(mean=1, size=orders_per_timestamp).round(decimals=1) | ||
sizes = rng.lognormal(mean=1, size=orders_per_timestamp).round(decimals=4) | ||
sides = rng.choice([Side.SELL, Side.BUY], size=orders_per_timestamp) | ||
new_orders = [ | ||
LimitOrder( | ||
side=side, price=price, size=size, timestamp=timestamp, order_id=faker.uuid4(), trader_id=faker.uuid4() | ||
) | ||
for side, price, size in zip(sides, prices, sizes, strict=True) | ||
] | ||
orders.extend(new_orders) | ||
return Orders(orders) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters