Skip to content

Commit

Permalink
neg risk cache
Browse files Browse the repository at this point in the history
  • Loading branch information
mshrieve committed Jul 19, 2024
1 parent 2fed57d commit 0fc3c56
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions py_clob_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ def __init__(
self.builder = OrderBuilder(
self.signer, sig_type=signature_type, funder=funder
)

# local cache
self.__tick_sizes = {}
self.__neg_risk = {}

self.logger = logging.getLogger(self.__class__.__name__)

def get_address(self):
Expand Down Expand Up @@ -293,7 +297,11 @@ def get_tick_size(self, token_id: str) -> TickSize:
return self.__tick_sizes[token_id]

def get_neg_risk(self, token_id: str) -> bool:
if token_id in self.__neg_risk:
return self.__neg_risk[token_id]

result = get("{}{}?token_id={}".format(self.host, GET_NEG_RISK, token_id))
self.__neg_risk[token_id] = result["neg_risk"]
return result["neg_risk"]

def __resolve_tick_size(
Expand Down

0 comments on commit 0fc3c56

Please sign in to comment.