Skip to content

Commit

Permalink
Add and update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaz001 committed Jul 9, 2023
1 parent 11f028f commit 01cadc3
Show file tree
Hide file tree
Showing 3 changed files with 386 additions and 11 deletions.
22 changes: 11 additions & 11 deletions examples/Making Multiple Markets - Part 2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "4222dd9d",
"id": "da409a5f",
"metadata": {},
"source": [
"# Making Multiple Markets and GLFT Market Making Model Part 2\n",
Expand Down Expand Up @@ -187,9 +187,9 @@
" bid_price = min(mid_price_tick - bid_depth, hbt.best_bid_tick) * hbt.tick_size\n",
" ask_price = max(mid_price_tick + ask_depth, hbt.best_ask_tick) * hbt.tick_size\n",
" \n",
" order_interval = max(round(half_spread) * hbt.tick_size, hbt.tick_size)\n",
" bid_price = np.floor(bid_price / order_interval) * order_interval\n",
" ask_price = np.ceil(ask_price / order_interval) * order_interval\n",
" grid_interval = max(round(half_spread) * hbt.tick_size, hbt.tick_size)\n",
" bid_price = np.floor(bid_price / grid_interval) * grid_interval\n",
" ask_price = np.ceil(ask_price / grid_interval) * grid_interval\n",
" \n",
" #--------------------------------------------------------\n",
" # Updates quotes.\n",
Expand All @@ -200,7 +200,7 @@
" new_bid_orders = Dict.empty(np.int64, np.float64)\n",
" if hbt.position < max_position:\n",
" for i in range(grid_num):\n",
" bid_price -= i * order_interval\n",
" bid_price -= i * grid_interval\n",
" bid_price_tick = round(bid_price / hbt.tick_size)\n",
" \n",
" # order price in tick is used as order id.\n",
Expand All @@ -218,7 +218,7 @@
" new_ask_orders = Dict.empty(np.int64, np.float64)\n",
" if hbt.position > -max_position:\n",
" for i in range(grid_num):\n",
" ask_price += i * order_interval\n",
" ask_price += i * grid_interval\n",
" ask_price_tick = round(ask_price / hbt.tick_size)\n",
" \n",
" # order price in tick is used as order id.\n",
Expand Down Expand Up @@ -328,9 +328,9 @@
" bid_price = min(hbt.best_bid_tick - bid_depth, hbt.best_bid_tick) * hbt.tick_size\n",
" ask_price = max(hbt.best_ask_tick + ask_depth, hbt.best_ask_tick) * hbt.tick_size\n",
" \n",
" order_interval = max(round(half_spread) * hbt.tick_size, hbt.tick_size)\n",
" bid_price = np.floor(bid_price / order_interval) * order_interval\n",
" ask_price = np.ceil(ask_price / order_interval) * order_interval\n",
" grid_interval = max(round(half_spread) * hbt.tick_size, hbt.tick_size)\n",
" bid_price = np.floor(bid_price / grid_interval) * grid_interval\n",
" ask_price = np.ceil(ask_price / grid_interval) * grid_interval\n",
" \n",
" #--------------------------------------------------------\n",
" # Updates quotes.\n",
Expand All @@ -341,7 +341,7 @@
" new_bid_orders = Dict.empty(np.int64, np.float64)\n",
" if hbt.position < max_position:\n",
" for i in range(grid_num):\n",
" bid_price -= i * order_interval\n",
" bid_price -= i * grid_interval\n",
" bid_price_tick = round(bid_price / hbt.tick_size)\n",
" \n",
" # order price in tick is used as order id.\n",
Expand All @@ -359,7 +359,7 @@
" new_ask_orders = Dict.empty(np.int64, np.float64)\n",
" if hbt.position > -max_position:\n",
" for i in range(grid_num):\n",
" ask_price += i * order_interval\n",
" ask_price += i * grid_interval\n",
" ask_price_tick = round(ask_price / hbt.tick_size)\n",
" \n",
" # order price in tick is used as order id.\n",
Expand Down
368 changes: 368 additions & 0 deletions examples/Market Making with Alpha - Order Book Imbalance.ipynb

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions hftbacktest/backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ def tick_size(self):
"""
return self.local.depth.tick_size

@property
def lot_size(self):
"""
Lot size
"""
return self.local.depth.lot_size

@property
def high_ask_tick(self):
"""
Expand Down

0 comments on commit 01cadc3

Please sign in to comment.