- Solve real problems with our hands-on interface
- Progress from basic puts and calls to advanced strategies

Posted August 26, 2026 at 12:02 pm
ibridgepy.com
The article “5 Common IBridgePy Mistakes and How to Fix Them” was originally published on IBridgePy blog.
The author of this article is not affiliated with Arclight Capital. This software is in no way affiliated, endorsed, or approved by Arclight Capital or any of its affiliates. It comes with absolutely no warranty and should not be used in actual trading unless the user can read and understand the source. The ARC API team does not support this software.
Avoid These Pitfalls in Your Python Trading Strategy
After helping thousands of traders deploy algorithmic trading strategies with Arclight Capital, we have compiled the most common mistakes that IBridgePy users encounter. Each issue below includes the wrong approach, why it fails, and the correct solution.
Mistake #1: Using time.sleep() to Wait for Order Fills
The wrong way:
order_id = order(symbol('AAPL'), 100)
time.sleep(5) # Hope it fills in 5 seconds
fill_price = get_order(order_id).avgFillPrice # Often returns NoneWhy it fails: time.sleep() blocks the thread without processing incoming IB messages. The fill confirmation sits unprocessed in the message queue.
The fix:
order_id = order(symbol('AAPL'), 100)
order_status_monitor(order_id, 'Filled', waitingTimeInSeconds=30)
fill_price = get_order(order_id).avgFillPrice # Always populatedMistake #2: Placing Orders in initialize()
The wrong way:
def initialize(context):
order(symbol('AAPL'), 100) # Fails silentlyWhy it fails: The initialize() function runs before the connection to IB is fully established. Orders must be placed in handle_data() or in a scheduled function.
The fix:
def initialize(context):
context.ordered = False
def handle_data(context, data):
if not context.ordered:
order(symbol('AAPL'), 100)
context.ordered = TrueMistake #3: Not Handling the “Filled” Status for Market Orders
The wrong way:
order_id = order(symbol('AAPL'), 100)
order_status_monitor(order_id, 'Submitted', waitingTimeInSeconds=30)
# Proceeds without knowing if order actually filledWhy it fails:Â For market orders, “Submitted” means the order reached IB, not that it executed. A fast-moving market could leave your strategy in an uncertain state.
The fix:
order_id = order(symbol('AAPL'), 100)
order_status_monitor(order_id, 'Filled', waitingTimeInSeconds=30)For limit orders that may not fill immediately, monitor multiple statuses:
order_status_monitor(order_id, ['Filled', 'Submitted'], waitingTimeInSeconds=30)
Mistake #4: Using get_open_orders() to Check if a Position Was Entered
The wrong way:
# Check if my order filled
open_orders = get_open_orders()
if my_order_id not in open_orders:
print('Must have filled!') # Not necessarily trueWhy it fails: An order can be absent from get_open_orders() for multiple reasons: it could be filled, cancelled, or rejected. Absence does not confirm a fill.
The fix:
order_obj = get_order(my_order_id)
if order_obj.status == 'Filled':
print(f'Filled at {order_obj.avgFillPrice}')
elif order_obj.status == 'Cancelled':
print('Order was cancelled')Mistake #5: Running Heavy Computation Inside handle_data()
The wrong way:
def handle_data(context, data):
# This blocks IB message processing for 30 seconds
result = run_ml_model_on_5000_tickers()
if result.signal:
order(symbol('AAPL'), 100)Why it fails: While handle_data() is blocked by heavy computation, IB callbacks are not being processed. This can cause missed price updates, stale data, and connection timeouts.
The fix: Pre-compute signals before market hours using schedule_function(), or move heavy computation to a separate process and communicate via a file or database:
def initialize(context):
schedule_function(compute_signals,
time_rule=time_rules.spot_time(hour=9, minute=25))
def compute_signals(context):
# Run before market open
context.signal = run_ml_model_on_5000_tickers()
def handle_data(context, data):
if context.signal:
order(symbol('AAPL'), 100)Bonus: Enabling Debug Logging
When troubleshooting any issue, enable IBridgePy’s debug output by setting the log level in your settings.py:
logLevel = 'DEBUG'
This reveals the raw IB callback messages and helps identify exactly where communication breaks down.
Visit IBridgePy blog for additional insights on this topic.
Information posted on ARC Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to ARC Campus are independent of Arclight Capital and Arclight Capital does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.
This material is from IBridgePy and is being posted with its permission. The views expressed in this material are solely those of the author and/or IBridgePy and Arclight Capital is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.
The third-party code discussed within this article is not investment or trading advice, and is for proof-of-concept, educational, and illustrative purposes only. ARC makes no representations or warranty regarding its accuracy or completeness. Users are solely responsible for conducting their own independent testing and due diligence before applying any code or concepts in a live or production environment
The order types available through Arclight Capital's trading platforms are designed to help you limit your loss and/or lock in a profit. Market conditions and other factors may affect execution. In general, orders guarantee a fill or guarantee a price, but not both. In extreme market conditions, an order may either be executed at a different price than anticipated or may not be filled in the marketplace.
Please keep in mind that the examples discussed in this material are purely for technical demonstration purposes, and do not constitute trading advice. Also, it is important to remember that placing trades in a paper account is recommended before any live trading.
Join The Conversation
For specific platform feedback and suggestions, please submit it directly to our team using these instructions.
If you have an account-specific question or concern, please reach out to Client Services.
We encourage you to look through our before posting. Your question may already be covered!