binance: use `@async_lifo_cache` on `.get_mkt_info()` ep
parent
bcf355e2c8
commit
af2f8756c5
|
@ -41,6 +41,7 @@ import numpy as np
|
||||||
import tractor
|
import tractor
|
||||||
import wsproto
|
import wsproto
|
||||||
|
|
||||||
|
from .._cacheables import async_lifo_cache
|
||||||
from ..accounting._mktinfo import (
|
from ..accounting._mktinfo import (
|
||||||
Asset,
|
Asset,
|
||||||
MktPair,
|
MktPair,
|
||||||
|
@ -483,20 +484,12 @@ async def open_history_client(
|
||||||
yield get_ohlc, {'erlangs': 3, 'rate': 3}
|
yield get_ohlc, {'erlangs': 3, 'rate': 3}
|
||||||
|
|
||||||
|
|
||||||
# TODO: bleh, didn't we have an async version of
|
@async_lifo_cache()
|
||||||
# this at some point?
|
|
||||||
# @lru_cache
|
|
||||||
async def get_mkt_info(
|
async def get_mkt_info(
|
||||||
fqme: str,
|
fqme: str,
|
||||||
|
|
||||||
_cache: dict[str, MktPair] = {}
|
|
||||||
|
|
||||||
) -> tuple[MktPair, Pair]:
|
) -> tuple[MktPair, Pair]:
|
||||||
|
|
||||||
both = _cache.get(fqme)
|
|
||||||
if both:
|
|
||||||
return both
|
|
||||||
|
|
||||||
async with open_cached_client('binance') as client:
|
async with open_cached_client('binance') as client:
|
||||||
|
|
||||||
pair: Pair = await client.exch_info(fqme.upper())
|
pair: Pair = await client.exch_info(fqme.upper())
|
||||||
|
@ -517,7 +510,6 @@ async def get_mkt_info(
|
||||||
broker='binance',
|
broker='binance',
|
||||||
)
|
)
|
||||||
both = mkt, pair
|
both = mkt, pair
|
||||||
_cache[fqme] = both
|
|
||||||
return both
|
return both
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue