Skip to content

Commit fa15779

Browse files
committed
Add supported_features argument to sample scripts
1 parent 72a6893 commit fa15779

12 files changed

Lines changed: 23 additions & 21 deletions

developer-addon/src/main/resources/cvd_addon.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414

1515
# mandatory callback used to register instrument info inside the python
16-
def handle_instrument_info(addon, alias: str, full_name: str, is_crypto: bool, pips: float, size_granularity: float,
17-
instrument_multiplier: float):
16+
def handle_subscribe_instrument(addon, alias: str, full_name: str, is_crypto: bool, pips: float, size_granularity: float,
17+
instrument_multiplier: float, supported_features: dict[str, object]):
1818
global cvd_accumulator
1919
global alias_to_size_granularity
2020
global req_id
@@ -80,7 +80,7 @@ def handle_trades(addon, alias: str, price: float, size: int, is_otc: bool, is_b
8080

8181

8282
# callback notifying that unsubscription appeared
83-
def handle_detach_instrument(addon, alias):
83+
def handle_unsubscribe_instrument(addon, alias):
8484
global cvd_accumulator
8585
del cvd_accumulator[alias]
8686
print("Detached " + alias, flush=True)
@@ -91,7 +91,7 @@ def handle_detach_instrument(addon, alias):
9191
bm.add_trades_handler(addon, handle_trades) # register callback for trades
9292
# register indicator response callback
9393
bm.add_indicator_response_handler(addon, handle_indicator_response)
94-
bm.start_addon(addon, handle_instrument_info,
95-
handle_detach_instrument) # starting an addon
94+
bm.start_addon(addon, handle_subscribe_instrument,
95+
handle_unsubscribe_instrument) # starting an addon
9696
# give control over python scrip to Bookmap, so it won't be finished until it is turned off from Bookmap
9797
bm.wait_until_addon_is_turned_off(addon)

developer-addon/src/main/resources/hello_world.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import bookmap as bm
22

33

4-
def handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier):
4+
def handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier, supported_features):
55
print("Hello world from " + alias, flush=True)
6+
print("Features: " + str(supported_features), flush=True)
67

78

89
def handle_unsubscribe_instrument(addon, alias):

developer-addon/src/main/resources/liquidity_tracker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
DEFAULT_LIQUIDITY_SIZE = 10
1111

1212

13-
def handle_instrument_info(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier):
13+
def handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier, supported_features):
1414
global req_id
1515

1616
instrument = {
@@ -39,7 +39,7 @@ def handle_instrument_info(addon, alias, full_name, is_crypto, pips, size_multip
3939
print("Registered...", flush=True)
4040

4141

42-
def handle_instrument_detached(addon, alias):
42+
def handle_unsubscribe_instrument(addon, alias):
4343
del alias_to_order_book[alias]
4444
del alias_to_instrument[alias]
4545

@@ -92,5 +92,5 @@ def on_settings_change_handler(addon, alias: str, setting_name: str, field_type:
9292
bm.add_indicator_response_handler(
9393
addon, handle_register_indicator_response)
9494
bm.add_on_setting_change_handler(addon, on_settings_change_handler)
95-
bm.start_addon(addon, handle_instrument_info, handle_instrument_detached)
95+
bm.start_addon(addon, handle_subscribe_instrument, handle_unsubscribe_instrument)
9696
bm.wait_until_addon_is_turned_off(addon)

developer-addon/src/main/resources/mbo_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
alias_to_mbo_book = {}
44

55

6-
def handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier):
6+
def handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier, supported_features):
77
global alias_to_mbo_book
88
alias_to_mbo_book[alias] = bm.create_mbo_book()
99
bm.subscribe_to_mbo(addon, alias, 1)

developer-addon/src/main/resources/order_book_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
alias_to_order_book = {}
44

55

6-
def handle_instrument_info(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier):
6+
def handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier, supported_features):
77
print("Instrument received " + alias, flush=True)
88
# create order book for each subscribed instrument
99
alias_to_order_book[alias] = bm.create_order_book()
@@ -13,8 +13,8 @@ def handle_instrument_info(addon, alias, full_name, is_crypto, pips, size_multip
1313
print("Data subscribed", flush=True)
1414

1515

16-
def handle_detach(addon, alias):
17-
print("Detached " + alias, flush=True)
16+
def handle_unsubscribe_instrument(addon, alias):
17+
print("The instrument " + alias + " has been removed", flush=True)
1818

1919

2020
# handler for depth. it receives information about side, price and size.
@@ -33,5 +33,5 @@ def handle_depth_info(addon, alias, is_bid, price, size):
3333
addon = bm.create_addon()
3434
print("Addon created", flush=True)
3535
bm.add_depth_handler(addon, handle_depth_info)
36-
bm.start_addon(addon, handle_instrument_info, handle_detach)
36+
bm.start_addon(addon, handle_subscribe_instrument, handle_unsubscribe_instrument)
3737
bm.wait_until_addon_is_turned_off(addon)

developer-addon/src/main/resources/simple_market_maker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def all_settings_set():
4848
alias_to_interval_count = {}
4949

5050

51-
def handle_instrument_info(addon, alias, full_name, _is_crypto, pips, size_multiplier, _instrument_multiplier):
51+
def handle_instrument_info(addon, alias, full_name, _is_crypto, pips, size_multiplier, _instrument_multiplier, _supported_features):
5252
global req_id
5353

5454
alias_to_instrument[alias] = {

examples/cvd_addon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# mandatory callback used to register instrument info inside the python
1616
def handle_subscribe_instrument(addon, alias: str, full_name: str, is_crypto: bool, pips: float, size_granularity: float,
17-
instrument_multiplier: float):
17+
instrument_multiplier: float, supported_features: dict[str, object]):
1818
global cvd_accumulator
1919
global alias_to_size_granularity
2020
global req_id

examples/hello_world.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import bookmap as bm
22

33

4-
def handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier):
4+
def handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier, supported_features):
55
print("Hello world from " + alias, flush=True)
6+
print("Features: " + str(supported_features), flush=True)
67

78

89
def handle_unsubscribe_instrument(addon, alias):

examples/liquidity_tracker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
DEFAULT_LIQUIDITY_SIZE = 10
1111

1212

13-
def handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier):
13+
def handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier, supported_features):
1414
global req_id
1515

1616
instrument = {

examples/mbo_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
alias_to_mbo_book = {}
44

55

6-
def handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier):
6+
def handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier, supported_features):
77
global alias_to_mbo_book
88
alias_to_mbo_book[alias] = bm.create_mbo_book()
99
bm.subscribe_to_mbo(addon, alias, 1)

0 commit comments

Comments
 (0)