Skip to content

Commit

Permalink
HitBTC: Remove unused code in order book
Browse files Browse the repository at this point in the history
  • Loading branch information
TheHolyRoger committed Mar 25, 2021
1 parent 001378c commit e419bd8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ cdef class HitbtcActiveOrderTracker:

cdef tuple c_convert_diff_message_to_np_arrays(self, object message)
cdef tuple c_convert_snapshot_message_to_np_arrays(self, object message)
cdef np.ndarray[np.float64_t, ndim=1] c_convert_trade_message_to_np_array(self, object message)
# This method doesn't seem to be used anywhere at all
# cdef np.ndarray[np.float64_t, ndim=1] c_convert_trade_message_to_np_array(self, object message)
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,15 @@ cdef class HitbtcActiveOrderTracker:

return bids, asks

cdef np.ndarray[np.float64_t, ndim=1] c_convert_trade_message_to_np_array(self, object message):
cdef:
double trade_type_value = 1.0 if message.content["side"] == "buy" else 2.0

timestamp = message.timestamp
content = message.content

return np.array(
[timestamp, trade_type_value, float(content["price"]), float(content["quantity"])],
dtype="float64"
)
# This method doesn't seem to be used anywhere at all
# cdef np.ndarray[np.float64_t, ndim=1] c_convert_trade_message_to_np_array(self, object message):
# cdef:
# double trade_type_value = 1.0 if message.content["side"] == "buy" else 2.0
# list content = message.content
# return np.array(
# [message.timestamp, trade_type_value, float(content["price"]), float(content["quantity"])],
# dtype="float64"
# )

def convert_diff_message_to_order_book_row(self, message):
np_bids, np_asks = self.c_convert_diff_message_to_np_arrays(message)
Expand Down
18 changes: 8 additions & 10 deletions hummingbot/connector/exchange/hitbtc/hitbtc_order_book_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
OrderBookMessage,
OrderBookMessageType,
)
from .hitbtc_constants import Constants
from .hitbtc_utils import (
convert_from_exchange_trading_pair,
)
Expand Down Expand Up @@ -54,21 +55,18 @@ def trading_pair(self) -> str:
elif "symbol" in self.content:
return convert_from_exchange_trading_pair(self.content["symbol"])

# The `asks` and `bids` properties are only used in the methods below.
# They are all replaced or unused in this connector:
# OrderBook.restore_from_snapshot_and_diffs
# OrderBookTracker._track_single_book
# MockAPIOrderBookDataSource.get_tracking_pairs
@property
def asks(self) -> List[OrderBookRow]:
asks = map(self.content["ask"], lambda ask: {"price": ask["price"], "size": ask["size"]})

return [
OrderBookRow(float(price), float(amount), self.update_id) for price, amount in asks
]
raise NotImplementedError(Constants.EXCHANGE_NAME + " order book uses active_order_tracker.")

@property
def bids(self) -> List[OrderBookRow]:
bids = map(self.content["bid"], lambda bid: {"price": bid["price"], "size": bid["size"]})

return [
OrderBookRow(float(price), float(amount), self.update_id) for price, amount in bids
]
raise NotImplementedError(Constants.EXCHANGE_NAME + " order book uses active_order_tracker.")

def __eq__(self, other) -> bool:
return self.type == other.type and self.timestamp == other.timestamp
Expand Down

0 comments on commit e419bd8

Please sign in to comment.