Skip to content

Commit 9f36b6d

Browse files
committed
Remove unnecessary 'global' statements
They are only needed for global variables that get overwriten (with =).
1 parent cb8a95d commit 9f36b6d

2 files changed

Lines changed: 0 additions & 20 deletions

File tree

examples/liquidity_tracker.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212

1313
def handle_instrument_info(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier):
1414
global req_id
15-
global alias_to_order_book
16-
global alias_to_instrument
17-
global liquidity_sizes
18-
global DEFAULT_LIQUIDITY_SIZE
1915

2016
instrument = {
2117
"alias": alias,
@@ -44,26 +40,17 @@ def handle_instrument_info(addon, alias, full_name, is_crypto, pips, size_multip
4440

4541

4642
def handle_instrument_detached(addon, alias):
47-
global alias_to_order_book
48-
global alias_to_instrument
4943
del alias_to_order_book[alias]
5044
del alias_to_instrument[alias]
5145

5246

5347
def handle_depth_info(addon, alias, is_bid, price, size):
54-
global alias_to_order_book
5548
order_book = alias_to_order_book[alias]
5649
bm.on_depth(order_book, is_bid, price, size)
5750

5851

5952
# callback triggered with periodic interval, right not it is not configurable and used
6053
def on_interval_draw_liquidity_info(addon):
61-
global alias_to_order_book
62-
global alias_to_ask_liquidity_indicator
63-
global alias_to_bid_liquidity_indicator
64-
global alias_to_instrument
65-
global liquidity_sizes
66-
6754
for alias, order_book in alias_to_order_book.items():
6855
if alias in alias_to_ask_liquidity_indicator and alias in alias_to_bid_liquidity_indicator:
6956
ask_liquidity_indicator = alias_to_ask_liquidity_indicator[alias]
@@ -81,10 +68,6 @@ def on_interval_draw_liquidity_info(addon):
8168

8269

8370
def handle_register_indicator_response(addon, request_id, indicator_id):
84-
global alias_to_ask_liquidity_indicator
85-
global alias_to_bid_liquidity_indicator
86-
global request_id_to_related_indicator_alias
87-
8871
alias, is_bid = request_id_to_related_indicator_alias[request_id]
8972
if is_bid:
9073
alias_to_bid_liquidity_indicator[alias] = indicator_id
@@ -95,7 +78,6 @@ def handle_register_indicator_response(addon, request_id, indicator_id):
9578
# handler called each time respective UI settings are changed. Value type depends on initial registered type,
9679
# might be floated, boolean, str, or tuple representing color
9780
def on_settings_change_handler(addon, alias: str, setting_name: str, field_type: str, new_value):
98-
global liquidity_sizes
9981
print("Received settings changed " + str(alias) + " " + str(setting_name) +
10082
" " + str(field_type) + " " + str(new_value), flush=True)
10183

examples/order_book_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
def handle_instrument_info(addon, alias, full_name, is_crypto, pips, size_multiplier, instrument_multiplier):
7-
global alias_to_order_book
87
print("Instrument received " + alias, flush=True)
98
# create order book for each subscribed instrument
109
alias_to_order_book[alias] = bm.create_order_book()
@@ -20,7 +19,6 @@ def handle_detach(addon, alias):
2019

2120
# handler for depth. it receives information about side, price and size.
2221
def handle_depth_info(addon, alias, is_bid, price, size):
23-
global alias_to_order_book
2422
order_book = alias_to_order_book[alias]
2523
# on_depth method updates internal order book
2624
bm.on_depth(order_book, is_bid, price, size)

0 commit comments

Comments
 (0)