r/twsapi

36 archived posts · Jun 2012 – Aug 2026

Random post

u/MarketMole•

What exactly would be required to shift from yahoo to something else?

20


I have zero programming experience, but I have a trading strategy that I'd like to automate (via coding). I believe I can use TWS API to achieve this... I've been told Python is one to learn. Is it possible to go from no-experience to automated-trading fairly quickly? Is there a repository of code that I can access to jump start my progress? Has anyone else attempted to do this? Any advice to help me get up the curve quickly is greatly appreciated. Thank you.

10

u/arpand•

Recently I worked with a client who already had a proprietary trading strategy and wanted to automate execution through Interactive Brokers.

The interesting part wasn't inventing the trading strategy.

It was turning their existing strategy into a reliable execution system — connecting Moomoo/AmiBroker-style strategy validation with IBKR execution — without requiring the client to disclose the parameters that actually make the strategy proprietary.

The setup included:

  • SAR Parabolic + Bollinger-based signal detection using raw OHLC data
  • Candle-by-candle signal validation against Moomoo and AmiBroker
  • Automated options execution through the IBKR TWS API
  • Strike and expiry selectio
10

u/epicaricacy12•

I have a TRAIL LIMIT order that I submit at 10am, but the goodAfterTime is at for 16:00:00... I set my trailingPercent to .25% and my offset to .1... tif = "GTD" and outsideRth = true.

With this just info alone, TWS will accept it if it's just a TRAIL, but since it's a TRAIL LIMIT, they require the trailStopPrice to be set instead of relying on using the market price at 4pm and the trail % to do the stop price calculation when the goodAfterTime triggers it.

Since I'm submitting the order at 10am with a goodAfterTime at 16:00, I don't have the right stop price information to set that field... what is the workaround here? I want to avoid having the API just update it right at 4pm, but I may

11

u/Mamal11•

Hi Guys,

I am trying to code a TWS API in python, and trying to implement a stop loss that changes in multiple steps depending on the price.

I am wondering how do you guys code that? In my code, when it is trying to update the stoploss, I get "duplicate error". I am wondering if you guys can explain how to adjust the stoploss ?

Thanks

10

u/MottledSwan•

Hi community,

Can someone tell me what "Reset API order ID sequence" means? Does it refer to the order of Managed accounts, where, e.g.,

accounts=[Fxxx,Uxxx,]

Thanks,

10


Hi everyone. I decided to start working again on something that was almost finished. I´m not the coder, just altering loging and fine tuning it. Turns out I got this error today that wasn´t triggering a few days ago and I dont get it.

This is the code, hapening for each ticker the algo trades:

, line 1219, in initialise_trade_list_from_broker_data

original_order_id = int(entry_order_ref.split('_')[1])

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ValueError: invalid literal for int() with base 10: 'ENTRY'

I have no idea how this has happened,

This is the relevant part of the code containing the entry.order.ref stuff:

# overwrite __init__ generat
10