TRADE with IRA accounts

I wanted to reach out to p123 community for some feedback on TRADE feature in p123.

First, let me provide some background regarding my inquiry. I use p123 to manage several of my personal investment accounts including IRA accounts. My brokerage is IB. As with any IRA account, you need to have cash in your account to buy new stocks. So when you have to rebalance and you are fully invested (e.g. 99% of IRA portfolio is tied in equities) first I need to sell my holdings before I issue new buy order. I believe this is common to any IRA account with any broker.

For this reason, TRADE feature is not really working with IRA accounts (or at least fully invested IRA accounts) as you cannot issue buy orders until sell orders are executed, or at least that is my understanding about the TRADE feature.

My solution to this problem is to develop a custom “TRADE” feature using IB API that will accommodate my needs. Currently, my rebalancing application is a little clunky (it is kind of prototype I built to learn IB API more than anything else), so I am planning on rebuilding the full-scale rebalancing app. However, for this, I am probably going to spend 100+ hours of coding to complete this project.

My concern with this is that I don’t want reinvent the wheel and build something that p123 TRADE already provides. What is the other user experience with TRADE (especially those with IRA accounts) and how they are able to come around this problem? Maybe TRADE already provides this capability, but I am just not aware of it.


This is a common issue that has been discussed before. This is what I do:

  • Submit orders for a specified time
  • Edit time for sell orders to be sent at least 5 minutes before buy orders
  • Use market orders for sales, which is not ideal, but ensures that enough cash is available for purchases

Setting this up takes about 10 minutes every Monday morning.

This is a very interesting topic for us as we plan to make TRADE one of the reasons someone uses P123 (we’re also going to expand it to more brokers)

EB, can you elaborate on what is going to take you 100+ hours ? Are your accounts linked right now with P123 ? How do you feed the rebalance recommendations to your order management system?

In any event, the evolution of TRADE will involve many of the issues you have. The goal is to make trading a one click affair. Some of the things that will be required to achieve that I think are

  • Conditional based on available cash
  • Smart limit orders that start conservative and become more aggressive based on your settings
  • Automatic order selection based on the stock being bought
  • Revisit how and which advanced orders algos are exposed via TRADE (probably just IB specific)

Let us know what else


Every friday I have a screener set up with my port sell rules that give me a good indicator as to which positions will be sold on next rebalance. I’ll try to get those sold Friday at close to have cash on hand for monday morning open and most closely reflect a “Previous Close” rebalance. Monday morning I’ll run limit orders set to previous close price for new buys and new sells that changed during the weekend, again trying to stick to Previous Close rebalance if at all possible. After 30 minutes I close out any unfilled limit orders and submit it again with a VWAP algo.

What I have in my mind is a little more complex than execution platform. That is why I think I might need more time to accommodate my needs.

My current accounts are not linked via TRADE. I simply execute my trades using my (clunky) IB API app.

My future state would replicate the trade feature for my needs:

  1. Take the system holdings (desired state) and compare to my current holdings (current state)
  2. Generate trades to align to my desired state
  3. Execute buy/sell as cash becomes available (this involves recursively checking the available balance every X amount of time and executing the next trade in my queue as the cash becomes available)

This is what already have but it is clunky and not scalable. I intend to build this so that is fully scalable for future use. Eventually (down the line) I want to build some algorithm of my own to improve my execution, but that is more down the line project.

For this first part, it might not take 100+ hours since I will borrowing a lot my old code. I am still deciding whether I want to use Java or Python and if go with Java than development time will go up for me (full disclosure I am not expert in either language but ok to undertake this project).

BTW I think P123 is doing the right thing to focus on execution (or TRADE feature). In my experience, I can develop a system that will improve my performance by 1-3% point annually. However, at some point, you squeeze all the alpha that can be squeezed from the available factors (and you are running the risk of overfitting). But with simple improvement in execution of 25 BPS I can get my performance up by +5% (weekly trades systems). That’s where the edge an individual investor will have going forward and that I want to focus my time now.

Perhaps the easiest way to improve the use of TRADE with IRA accounts, whether with IB or any other broker, is to provide a way to make a Basket of Buys sequentially dependent on a Basket of Sells. In many cases, this might be a preferred approach for non-IRA accounts as well. For my purposes, the following sequence would be ideal:

Create and submit a Basket of all Sells, then monitor for the completion of all. This might require limiting the type of Sells used.
As soon as all Sells are completed, use the actual proceeds plus cash on hand and prevailing or desired prices to generate a Basket of Buys.
Submit the Basket of Buys.

This would complicate the TRADE interface to the brokerage if monitoring for completion of Sells before submitting Buys. A less effective approach would be to create and submit both Baskets but use a OTO (One Triggers Other) condition so that the Basket of Buys doesn’t activate until the Basket of Sells is completed. That allows for a single submission of all orders without monitoring for completion. IB supports Baskets of orders but it doesn’t appear that they currently support the OTO condition. I don’t know if there are brokers that support the combination of Basket orders and OTO condition between Baskets.

Maybe some discussions with IB regarding support for OTO, especially for Baskets, might help?

The Basket approach appeals to me since the alternative, a dependency on single orders (one Sell triggers one Buy), doesn’t spread the funds from multiple Sells evenly over multiple Buys.

I currently use only IRA accounts for P123 models. If the TRADE interface accounted for the need to perform all Sells before Buys, I would be much more inclined to move them to IB and use TRADE. Not guaranteed, but more likely! In the meantime, I will stick to semi-automatic rebalancing and manual submission of orders.

Hope this helps the discussion!

For the well informed at P123—I have nothing to add. You are well informed about the brokers and your personal needs.

For those who will be using RoboAdvisor, and others that P123 are trying to attract with Designer Models, FolioInvesting takes care of some of the problems with IRAs. One does not have to sell stocks before buying: both occur in a single window. Folio has other problems, however, including the “Free Rider” problem and not having limited Margin. So, Folio may not even be the most convent for some and probably not the best broker for most reading this now.

Also, for small trades the no commissions at FolioInvesting may be a better way to go than the reduced slippage that one can get with the Algos at IB—all depending on the amount traded. Again, more for the people P123 wants to attract with RoboAdvisor and Designer Models.

Trade with FolioInvesting may attract some customers to P123.


This issue is very important.

Having intraday prices available in ranking systems would help for this issue.

Has anyone been able to use P123 to auto trade with IRAs?