From e0f8e5a8591f21728538839d8bce91a082d10118 Mon Sep 17 00:00:00 2001 From: goodboy Date: Mon, 30 Mar 2026 13:25:41 -0400 Subject: [PATCH] Guard missing Kraken `src_fiat` at trade startup Raise `ConfigurationError` if private startup lacks source fiat. Deats, - Import `ConfigurationError` in `.kraken.broker`. - Move Kraken's `reg_err_types` imports to the import blocks. Kraken-only extraction from f210a478c64f03e2d524f74878c80032a6ce84e4. (this commit msg was generated in some part by `Codex` using `gpt-6.2-sol` (`OpenAI`)) --- piker/brokers/kraken/api.py | 2 +- piker/brokers/kraken/broker.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/piker/brokers/kraken/api.py b/piker/brokers/kraken/api.py index fbf9d6a9..92297393 100644 --- a/piker/brokers/kraken/api.py +++ b/piker/brokers/kraken/api.py @@ -35,6 +35,7 @@ import hashlib import hmac import base64 import tractor +from tractor._exceptions import reg_err_types import trio from piker import config @@ -118,7 +119,6 @@ class InvalidKey(ValueError): ''' -from tractor._exceptions import reg_err_types reg_err_types([InvalidKey]) diff --git a/piker/brokers/kraken/broker.py b/piker/brokers/kraken/broker.py index d66a9f22..3282bf99 100644 --- a/piker/brokers/kraken/broker.py +++ b/piker/brokers/kraken/broker.py @@ -36,6 +36,7 @@ from typing import ( from bidict import bidict import trio import tractor +from tractor._exceptions import reg_err_types from piker.accounting import ( Position, @@ -45,6 +46,9 @@ from piker.accounting import ( open_trade_ledger, open_account, ) +from piker.config import ( + ConfigurationError, +) from piker.clearing import( OrderDialogs, ) @@ -99,7 +103,7 @@ MsgUnion = Union[ class TooFastEdit(Exception): 'Edit requests faster then api submissions' -from tractor._exceptions import reg_err_types + reg_err_types([TooFastEdit]) @@ -466,7 +470,11 @@ async def open_trade_dialog( # (much like the web UI let's you set an "account currency") # such that all positions (nested or flat) will be translated to # this source currency's terms. - src_fiat = client.conf['src_fiat'] + src_fiat = client.conf.get('src_fiat') + if not src_fiat: + raise ConfigurationError( + 'No `src_fiat: str` field defined in `brokers.toml`' + ) # auth required block acctid = client._name