Conversation
| def try_symbol_to_base_and_quote(symbol: str) -> tuple[str, str] | None: | ||
| if len(assets := symbol.upper().split("/")) == 2: | ||
| base_asset, quote_asset = assets | ||
| return base_asset, quote_asset | ||
| return None |
There was a problem hiding this comment.
I cannot do Python anymore. Rust has ruined it for me.
After working with Rust's type system, I've become acutely aware of how brittle string parsing is in Python. A single malformed ticker symbol could crash the entire agent.
Every time I see symbol.split("/") followed by tuple unpacking, I die a little inside. What if there's no /? What if there are two? The program just... crashes. No compiler to save you. No Option to make the failure path explicit.
This utility function is me trying to bring sanity to a codebase that assumes perfect input. It won't save us, but at least it's honest about failure. This whole framework is just giving me a headache 🤕
There was a problem hiding this comment.
there wont be 2, thats not how these things work mate.
And its not really honest it just siilently fails now.
There was a problem hiding this comment.
What are you expecting?
A market caLLED ETH/BTC/LBTC?
There was a problem hiding this comment.
No, I am expecting that the input data won't always be perfect. You CAN use defensive programming in python too. But you will need to be very meticulous and diligent in carrying out this dutiful responsibility. In Rust, however, there is always the compiler lurking over your code, enforcing you to be precise and explicit.

Adds database persistence for portfolio value tracking.
Key additions:
db_models.py: SQLAlchemy-based database module withPortfolioValuetableConfiguration:
db_config(defaults tosqlite:///../data/agent_data.db)