Skip to content

Commit

Permalink
Fix CacheDatabaseAdapter index loading
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Dec 4, 2023
1 parent e80193d commit 71260c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions examples/live/binance_spot_ema_cross.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from nautilus_trader.adapters.binance.config import BinanceExecClientConfig
from nautilus_trader.adapters.binance.factories import BinanceLiveDataClientFactory
from nautilus_trader.adapters.binance.factories import BinanceLiveExecClientFactory
from nautilus_trader.config import CacheDatabaseConfig
from nautilus_trader.config import InstrumentProviderConfig
from nautilus_trader.config import LiveExecEngineConfig
from nautilus_trader.config import LoggingConfig
Expand All @@ -45,7 +44,10 @@
reconciliation=True,
reconciliation_lookback_mins=1440,
),
cache_database=CacheDatabaseConfig(type="redis"),
# cache_database=CacheDatabaseConfig(
# type="redis",
# buffer_interval_ms=100,
# ),
# message_bus=MessageBusConfig(
# database=DatabaseConfig(), # No yet for operational use
# encoding="json",
Expand Down
4 changes: 2 additions & 2 deletions nautilus_trader/cache/database.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ cdef class CacheDatabaseAdapter(CacheDatabaseFacade):
return {}

cdef dict raw_index = msgspec.json.decode(result[0])
return {ClientOrderId(k.decode("utf-8")): PositionId(v.decode("utf-8")) for k, v in raw_index.items()}
return {ClientOrderId(k): PositionId(v) for k, v in raw_index.items()}

cpdef dict load_index_order_client(self):
"""
Expand All @@ -446,7 +446,7 @@ cdef class CacheDatabaseAdapter(CacheDatabaseFacade):
return {}

cdef dict raw_index = msgspec.json.decode(result[0])
return {ClientOrderId(k.decode("utf-8")): ClientId(v.decode("utf-8")) for k, v in raw_index.items()}
return {ClientOrderId(k): ClientId(v) for k, v in raw_index.items()}

cpdef Currency load_currency(self, str code):
"""
Expand Down

0 comments on commit 71260c2

Please sign in to comment.