Skip to content

Commit

Permalink
Refactor caching logic in get_candles function
Browse files Browse the repository at this point in the history
  • Loading branch information
saleh-mir committed Apr 17, 2024
1 parent 66f4b5f commit 1cdf5f8
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions jesse/services/candle.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ def get_candles(
) -> Tuple[np.ndarray, np.ndarray]:
symbol = symbol.upper()

caching = False

# convert start_date and finish_date to timestamps
trading_start_date_timestamp = jh.timestamp_to_arrow(start_date_timestamp).floor(
'day').int_timestamp * 1000
Expand Down Expand Up @@ -283,7 +281,7 @@ def _get_candles_from_db(

if caching:
# cache for 1 week it for near future calls
cache.set_value(cache_key, candles_tuple, expire_seconds=60 * 60 * 24 * 7)
cache.set_value(cache_key, tuple(candles_tuple), expire_seconds=60 * 60 * 24 * 7)

return np.array(candles_tuple)

Expand Down

0 comments on commit 1cdf5f8

Please sign in to comment.