Tags: mattsta/icli
Tags
Release yearly major feature enhancements
Introducing new features, fixes, and improvements for correctness and performance written over thousands of hours from the past year all in one giant update.
✨ New Features
- **Instrument Database (`instrumentdb`)**: A new module to manage instrument details: automatic price/tick increment fetching for every security type, rounding prices to the correct number of decimals for each security type, also accounting for differences in tick increments down to each individual exchange as well. This is a major feature for ensuring accurate order price rounding compliance and includes robust caching so instrument+exchange lookups happen once via API then are cached for reuse forever.
- **Background Tasks & Scheduler (`bgtask`)**: A new system for managing background tasks and scheduled events with more granular control.
- **Predicate Engine (`ifthen`)**: A way to create real time conditional logic predicates for automated trading or real time alerting.
- **Algo Binder**: A new feature to consume external data feeds via WebSockets for algorithmic trading.
- **Scale/Ladder Orders**: New `Ladder` capability to support scale-in/out orders with multiple price/quantity steps and an average cost stop-loss.
- **New Calculator Functions**: The in-app calculator now supports `ac` for average cost calculation and `abs` for absolute value.
- **Guaranteed Price Transparency**: All prices are now `Decimal()` so exact precision is retained through all operations.
- **`buy` Automation Improved**: More interactive, accurate, realtime `buy` feedback when checking for fills against midpoint-crawling order logic.
🚀 Improvements
- **Configuration Loading**: The application now uses `python-dotenv`'s `load_dotenv` to load environment variables from `.env.icli` directly into `os.environ` for a
cleaner startup process.
- **Error Handling**:
- `awwdio.py`: Error logging for text-to-speech is now throttled to avoid spamming logs for the same recurring error.
- `cli.py`: A `DuplicateMessageHandler` is introduced to suppress repeated API error messages, making the console output cleaner.
- **Contract Qualification & Caching**:
- The `qualify` method is significantly improved with better caching logic, corruption checks, and batching of requests to avoid API rate limits. It now supports
force-refreshing via an `overwrite` parameter.
- Cache expiration for futures contracts is now shorter (5 days) than for other contracts (90 days) to better handle expirations.
- **Order Placement & Management**:
- `placeOrderForContract` is heavily refactored. It now returns a `FullOrderPlacementRecord` and supports bracket orders, ladders, and custom order configs.
- A `safeModify` helper is introduced to safely create order modification requests, cleaning up fields that IBKR's API rejects on updates.
- Logic for handling non-guaranteed spreads is added, including reordering legs and adding necessary tags.
- Order preview (`whatIfOrderAsync`) is improved to show more details like margin impact, commissions, leverage, and risk-reward for credit spreads.
- **Quote & Toolbar Display**:
- Quote sorting logic (`sortQuotes`) is enhanced to handle more security types (`CONTFUT`, `FOP`, `EC`) and sort bags more intelligently based on their legs.
- The toolbar now shows more PnL percentage breakdowns (`RealizedPnL%`, `UnrealizedPnL%`, `TotalPnL%`).
- The toolbar refresh count now distinguishes between total updates and updates since the last reconnect.
- Toolbar style is now customizable via the `colorset` command.
- **Date/Time Handling**:
- `pendulum` has been replaced with `whenever` and `pytz` for timezone-aware datetime operations, primarily using `US/Eastern`.
- Market calendar functions are improved for better caching and accuracy around market close.
- **Code Structure & Helpers**:
- Many helper functions and classes have been moved into new `icli/helpers.py` and `icli/utils.py` modules for better organization.
- `orjson` is now used conditionally (only on CPython) for better performance on PyPy.
- Many dataclasses now use `slots=True` for better memory efficiency.
- Command parsing in `lang.py` is improved to handle quoted arguments with semicolons correctly.
- **Logging**: Logging setup is now encapsulated in a method and provides more structured output, including client ID and timestamp in log file names.
🐛 Bug Fixes
- **Contract Cache Corruption**: Added checks to prevent and detect corrupted contract data in the cache, forcing a re-fetch if necessary.
- **Order Modification**: `safeModify` fixes issues where IBKR would reject order updates due to fields it auto-populates on live orders (e.g., `orderType="IBALGO"`).
- **Futures Options Sorting**: Sorting for futures options is improved by using the full contract month date, ensuring correct chronological order.
Increase version number as much as icli has a "version," this counts as a new one. a couple more months of changes, lots of bug fixes, lots of usability improvements, some new IBKR algo types, some improvements to our auto trading interfaces, and other commands/utilities too. The official changelog is just the commit history. Every commit has a detailed reason for big changes and usually includes usage examples too.
Increase version number arbitrarily Incremented a dependency version number for tradeapis due to adding automatic futures expiration month detection. I guess this can count as the next "version" (this is versioned very weakly), but the commit log since last version number increment includes: - inbound IBKR news alert fixes - metadata improvements around self-running and counting things in a session - add more automated price buffers when using prices from quotes - more automated bulk quote grabbing improvements - uses external lookup table for proper price increment detection - after hours order fixes for some products - print DTE with options quotes - more debugging of failed orders / easier ways to stop stuck orders - migrated to using actual SPXW symbol instead of rewriting SPX requests - calculate daily market circuit breaker levels - allow order placement using in-page :position numbers for any quote - better order modification logic so failed modifies don't edit the cached state - fixes futures->exchange mappings because IBKR rewrote them all and the old quote lookup tables stopped working