• C#
  • Java
  • VB
  • C++
  • Python
Contact us
Financial Advisors

Allocation Methods and Groups

A number of methods and profiles are available with Financial Advisor and IBroker account structures to specify how trades should be distributed across multiple accounts. This functionality allows for trades to be placed across multiple accounts. The API has the same functionality available as TWS.

Group and Profile order allocation methods for Financial Advisor Accounts can be created directly in TWS: Allocations and Transfers, or utilize the IBApi.EClient.replaceFA() method via the API directly.

As suggested from the method names below, a Group will distribute the order based on inherent properties such as the account's liquidation value or equity whereas a Profile will offer the possibility to assign the allocated proportion based on explicit ratios or percentages.
Note, however, in TWS v983+, there is an API setting which merges groups and profiles, where both allocation methods are considered groups. See Unification of Groups and Profiles

Allocation by Group

EqualQuantity

Requires you to specify an order size. This method distributes shares equally between all accounts in the group.

Example: You transmit an order for 400 shares of stock ABC. If your Account Group includes four accounts, each account receives 100 shares. If your Account Group includes six accounts, each account receives 66 shares, and then 1 share is allocated to each account until all are distributed.

NetLiq

Requires you to specify an order size. This method distributes shares based on the net liquidation value of each account. The system calculates ratios based on the Net Liquidation value in each account and allocates shares based on these ratios.

Example: You transmit an order for 700 shares of stock XYZ. The account group includes three accounts, A, B and C with Net Liquidation values of $25,000, $50,000 and $100,000 respectively. The system calculates a ratio of 1:2:4 and allocates 100 shares to Client A, 200 shares to Client B, and 400 shares to Client C.

AvailableEquity

Requires you to specify an order size. This method distributes shares based on the amount of available equity in each account. The system calculates ratios based on the Available Equity in each account and allocates shares based on these ratios.

Example: You transmit an order for 700 shares of stock XYZ. The account group includes three accounts, A, B and C with available equity in the amounts of $25,000, $50,000 and $100,000 respectively. The system calculates a ratio of 1:2:4 and allocates 100 shares to Client A, 200 shares to Client B, and 400 shares to Client C.

PctChange

Do not specify an order size. Since the quantity is calculated by the system, the order size is displayed in the Quantity field after the order is acknowledged. This method increases or decreases an already existing position. Positive percents will increase a position, negative percents will decrease a position. For exmaple, to fully close out a position, you just need to specify percentage to be -100.

BUY ORDERPositive PercentNegative Percent
Long PositionIncreases positionNo effect
Short PositionNo effectDecreases position
SELL ORDERPositive PercentNegative Percent
Long PositionNo effectDecreases position
Short PositionIncreases positionNo effect

Allocation by Profile

Percentages

This method will split the total number of shares in the order between listed accounts based on the percentages you indicate. For example, an order for 1000 shares using a profile with four accounts at 25% each would allocate 250 shares to each listed account in the profile.

Financial Ratios

This method calculates the allocation of shares based on the ratios you enter. For example, an order for 1000 shares using a profile with four accounts set to a ratio of 4, 2, 1, 1 would allocate 500, 250, 125 and 125 shares to the listed accounts, respectively.

Shares

This method allocates the absolute number of shares you enter to each account listed. If you use this method, the order size is calculated by adding together the number of shares allocated to each account in the profile.

Profile Methods Matching
Profile MethodsType Number
PercentagesType - 1
Financial RatiosType - 2
SharesType - 3


Groups and Profiles from the API

The IBApi.EClient.requestFA function allows Financial Advisor to manually request current allocation configuration data from TWS.

Request Account Aliases

  • client.requestFA(Constants.FaAliases);
  • client.requestFA(FADataType.ALIASES.ordinal());
  • client.requestFA(Constants.FaAliases)
  • m_pClient->requestFA(faDataType::ALIASES);
  • 1  self.requestFA(FaDataTypeEnum.ALIASES)

Request FA Groups

  • client.requestFA(Constants.FaGroups);
  • client.requestFA(FADataType.GROUPS.ordinal());
  • client.requestFA(Constants.FaGroups)
  • m_pClient->requestFA(faDataType::GROUPS);
  • 1  self.requestFA(FaDataTypeEnum.GROUPS)

Request FA Profiles

  • client.requestFA(Constants.FaProfiles);
  • client.requestFA(FADataType.PROFILES.ordinal());
  • client.requestFA(Constants.FaProfiles)
  • m_pClient->requestFA(faDataType::PROFILES);
  • 1  self.requestFA(FaDataTypeEnum.PROFILES)

The resulting FA allocation configuration will be delivered via the IBApi.EWrapper.receiveFA. The event includes an XML string containing the requested information.

  • public class EWrapperImpl : EWrapper
    {
    ...
    public virtual void receiveFA(int faDataType, string faXmlData)
    {
    Console.WriteLine("Receing FA: "+faDataType+" - "+faXmlData);
    }
  • public class EWrapperImpl implements EWrapper {
    ...
    @Override
    public void receiveFA(int faDataType, String xml) {
    System.out.println("Receiving FA: "+faDataType+" - "+xml);
    }
  • Public Class EWrapperImpl
    Implements EWrapper
    ...
    Public Sub receiveFA(faDataType As Integer, faXmlData As String) Implements IBApi.EWrapper.receiveFA
    Console.WriteLine("Receing FA: " & faDataType & " - " & faXmlData)
    End Sub
  • class TestCppClient : public EWrapper
    {
    ...
    void TestCppClient::receiveFA(faDataType pFaDataType, const std::string& cxml) {
    std::cout << "Receiving FA: " << (int)pFaDataType << std::endl << cxml << std::endl;
    }
  • 1 class TestWrapper(wrapper.EWrapper):
    ...
    1  def receiveFA(self, faData: FaDataType, cxml: str):
    2  super().receiveFA(faData, cxml)
    3  print("Receiving FA: ", faData)
    4  open('log/fa.xml', 'w').write(cxml)

The IBApi.EClient.replaceFA function can be called to replace the previous FA configuration in TWS by passing in a FULL XML string that contains all allocation information.

Replace Account Groups Configuration

  • public static string FaOneGroup = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    + "<ListOfGroups>"
    + "<Group>"
    + "<name>Equal_Quantity</name>"
    + "<ListOfAccts varName=\"list\">"
    //Replace with your own accountIds
    + "<String>DU119915</String>"
    + "<String>DU119916</String>"
    + "</ListOfAccts>"
    + "<defaultMethod>EqualQuantity</defaultMethod>"
    + "</Group>"
    + "</ListOfGroups>";
    ...
    client.replaceFA(1000, Constants.FaGroups, FaAllocationSamples.FaOneGroup);
  • public static final String FA_ONE_GROUP = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    + "<ListOfGroups>"
    + "<Group>"
    + "<name>Equal_Quantity</name>"
    + "<ListOfAccts varName=\"list\">"
    //Replace with your own accountIds
    + "<String>DU119915</String>"
    + "<String>DU119916</String>"
    + "</ListOfAccts>"
    + "<defaultMethod>EqualQuantity</defaultMethod>"
    + "</Group>"
    + "</ListOfGroups>";
    ...
    client.replaceFA(1000, FADataType.GROUPS.ordinal(), FAMethodSamples.FA_ONE_GROUP);
  • 'Replace with your own accountIds
    Public Shared FaOneGroup As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" &
    "<ListOfGroups>" &
    "<Group>" &
    "<name> Equal_Quantity</name>" &
    "<ListOfAccts varName=""list"">" &
    "<String>DU119915</String>" &
    "<String>DU119916</String>" &
    "</ListOfAccts>" &
    "<defaultMethod>EqualQuantity</defaultMethod>" &
    "</Group>" &
    "</ListOfGroups>"

    ...

    client.replaceFA(1000, Constants.FaGroups, FaAllocationSamples.FaOneGroup)
  • std::string groupXml =
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    "<ListOfGroups>"
    "<Group>"
    "<name>Equal_Quantity</name>"
    "<ListOfAccts varName=\"list\">"
    "<String>DU119915</String>"
    "<String>DU119916</String>"
    "</ListOfAccts>"
    "<defaultMethod>EqualQuantity</defaultMethod>"
    "</Group>"
    "</ListOfGroups>";
    ...
    m_pClient->replaceFA(1000, faDataType::GROUPS, FAMethodSamples::FAOneGroup());
  • 1  FaOneGroup = "".join(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    2  , "<ListOfGroups>"
    3  , "<Group>"
    4  , "<name>Equal_Quantity</name>"
    5  , "<ListOfAccts varName=\"list\">"
    6  #Replace with your own accountIds
    7  , "<String>DU119915</String>"
    8  , "<String>DU119916</String>"
    9  , "</ListOfAccts>"
    10  , "<defaultMethod>EqualQuantity</defaultMethod>"
    11  , "</Group>"
    12  , "</ListOfGroups>"))
    ...
    1  self.replaceFA(1000, FaDataTypeEnum.GROUPS, FaAllocationSamples.FaOneGroup)

Note: The above command will replace any previous FA group configuration in TWS with one 'Group_Equal_Quantity' group allocation.

  • public static string FaTwoGroups = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    +"<ListOfGroups>"
    + "<Group>"
    + "<name>Equal_Quantity</name>"
    + "<ListOfAccts varName=\"list\">"
    //Replace with your own accountIds
    + "<String>DU119915</String>"
    + "<String>DU119916</String>"
    + "</ListOfAccts>"
    + "<defaultMethod>EqualQuantity</defaultMethod>"
    + "</Group>"
    + "<Group>"
    + "<name>Pct_Change</name>"
    + "<ListOfAccts varName=\"list\">"
    //Replace with your own accountIds
    + "<String>DU119915</String>"
    + "<String>DU119916</String>"
    + "</ListOfAccts>"
    + "<defaultMethod>PctChange</defaultMethod>"
    + "</Group>"
    + "</ListOfGroups>";
    ...
    client.replaceFA(1001, Constants.FaGroups, FaAllocationSamples.FaTwoGroups);
  • public static final String FA_TWO_GROUPS = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    +"<ListOfGroups>"
    + "<Group>"
    + "<name>Equal_Quantity</name>"
    + "<ListOfAccts varName=\"list\">"
    //Replace with your own accountIds
    + "<String>DU119915</String>"
    + "<String>DU119916</String>"
    + "</ListOfAccts>"
    + "<defaultMethod>EqualQuantity</defaultMethod>"
    + "</Group>"
    + "<Group>"
    + "<name>Pct_Change</name>"
    + "<ListOfAccts varName=\"list\">"
    //Replace with your own accountIds
    + "<String>DU119915</String>"
    + "<String>DU119916</String>"
    + "</ListOfAccts>"
    + "<defaultMethod>PctChange</defaultMethod>"
    + "</Group>"
    + "</ListOfGroups>";
    ...
    client.replaceFA(1001, FADataType.GROUPS.ordinal(), FAMethodSamples.FA_TWO_GROUPS);
  • 'Replace with your own accountIds
    Public Shared FaTwoGroups As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" &
    "<ListOfGroups>" &
    "<Group>" &
    "<name> Equal_Quantity</name>" &
    "<ListOfAccts varName = ""list"">" &
    "<String> DU119915</String>" &
    "<String> DU119916</String>" &
    "</ListOfAccts>" &
    "<defaultMethod> EqualQuantity</defaultMethod>" &
    "</Group>" &
    "<Group>" &
    "<name> Pct_Change</name>" &
    "<ListOfAccts varName = ""list"">" &
    "<String> DU119915</String>" &
    "<String> DU119916</String>" &
    "</ListOfAccts>" &
    "<defaultMethod> PctChange</defaultMethod>" &
    "</Group>" &
    "</ListOfGroups>"
    ...
    client.replaceFA(1001, Constants.FaGroups, FaAllocationSamples.FaTwoGroups)
  • std::string groupXml =
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    "<ListOfGroups>"
    "<Group>"
    "<name>Equal_Quantity</name>"
    "<ListOfAccts varName=\"list\">"
    "<String>DU119915</String>"
    "<String>DU119916</String>"
    "</ListOfAccts>"
    "<defaultMethod>EqualQuantity</defaultMethod>"
    "</Group>"
    "<Group>"
    "<name>Pct_Change</name>"
    "<ListOfAccts varName=\"list\">"
    "<String>DU119915</String>"
    "<String>DU119916</String>"
    "</ListOfAccts>"
    "<defaultMethod>PctChange</defaultMethod>"
    "</Group>"
    "</ListOfGroups>";
    ...
    m_pClient->replaceFA(1001, faDataType::GROUPS, FAMethodSamples::FATwoGroups());
  • 1  FaTwoGroups = "".join(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    2  ,"<ListOfGroups>"
    3  , "<Group>"
    4  , "<name>Equal_Quantity</name>"
    5  , "<ListOfAccts varName=\"list\">"
    6  #Replace with your own accountIds
    7  , "<String>DU119915</String>"
    8  , "<String>DU119916</String>"
    9  , "</ListOfAccts>"
    10  , "<defaultMethod>EqualQuantity</defaultMethod>"
    11  , "</Group>"
    12  , "<Group>"
    13  , "<name>Pct_Change</name>"
    14  , "<ListOfAccts varName=\"list\">"
    15  #Replace with your own accountIds
    16  , "<String>DU119915</String>"
    17  , "<String>DU119916</String>"
    18  , "</ListOfAccts>"
    19  , "<defaultMethod>PctChange</defaultMethod>"
    20  , "</Group>"
    21  , "</ListOfGroups>"))
    ...
    1  self.replaceFA(1001, FaDataTypeEnum.GROUPS, FaAllocationSamples.FaTwoGroups)

Note: The above command will add another 'Group_Pct_Change' group allocation to the previous FA configuration.

Replace Account Profiles Configuration

You can find the corresponding type number for profile allocation in the "Profile Methods Matching" table above.

  • public static string FaOneProfile = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    + "<ListOfAllocationProfiles>"
    + "<AllocationProfile>"
    + "<name>Percent_60_40</name>"
    + "<type>1</type>"
    + "<ListOfAllocations varName=\"listOfAllocations\">"
    + "<Allocation>"
    //Replace with your own accountIds
    + "<acct>DU119915</acct>"
    + "<amount>60.0</amount>"
    + "</Allocation>"
    + "<Allocation>"
    //Replace with your own accountIds
    + "<acct>DU119916</acct>"
    + "<amount>40.0</amount>"
    + "</Allocation>"
    + "</ListOfAllocations>"
    + "</AllocationProfile>"
    + "</ListOfAllocationProfiles>";
    ...
    client.replaceFA(1002, Constants.FaProfiles, FaAllocationSamples.FaOneProfile);
  • public static final String FA_ONE_PROFILE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    + "<ListOfAllocationProfiles>"
    + "<AllocationProfile>"
    + "<name>Percent_60_40</name>"
    + "<type>1</type>"
    + "<ListOfAllocations varName=\"listOfAllocations\">"
    + "<Allocation>"
    //Replace with your own accountIds
    + "<acct>DU119915</acct>"
    + "<amount>60.0</amount>"
    + "</Allocation>"
    + "<Allocation>"
    //Replace with your own accountIds
    + "<acct>DU119916</acct>"
    + "<amount>40.0</amount>"
    + "</Allocation>"
    + "</ListOfAllocations>"
    + "</AllocationProfile>"
    + "</ListOfAllocationProfiles>";
    ...
    client.replaceFA(1002, FADataType.PROFILES.ordinal(), FAMethodSamples.FA_ONE_PROFILE);
  • 'Replace with your own accountIds
    Public Shared FaOneProfile As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" &
    "<ListOfAllocationProfiles>" &
    "<AllocationProfile>" &
    "<name> Percent_60_40</name>" &
    "<type>1</type>" &
    "<ListOfAllocations varName=""listOfAllocations"">" &
    "<Allocation>" &
    "<acct> DU119915</acct>" &
    "<amount>60.0</amount>" &
    "</Allocation>" &
    "<Allocation>" &
    "<acct> DU119916</acct>" &
    "<amount>40.0</amount>" &
    "</Allocation>" &
    "</ListOfAllocations>" &
    "</AllocationProfile>" &
    "</ListOfAllocationProfiles>"
    ...
    client.replaceFA(1002, Constants.FaProfiles, FaAllocationSamples.FaOneProfile)
  • std::string profileXml =
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    "<ListOfAllocationProfiles>"
    "<AllocationProfile>"
    "<name>Percent_60_40</name>"
    "<type>1</type>"
    "<ListOfAllocations varName=\"listOfAllocations\">"
    "<Allocation>"
    "<acct>DU119915</acct>"
    "<amount>60.0</amount>"
    "</Allocation>"
    "<Allocation>"
    "<acct>DU119916</acct>"
    "<amount>40.0</amount>"
    "</Allocation>"
    "</ListOfAllocations>"
    "</AllocationProfile>"
    "</ListOfAllocationProfiles>";
    ...
    m_pClient->replaceFA(1002, faDataType::PROFILES, FAMethodSamples::FAOneProfile());
  • 1  FaOneProfile = "".join(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    2  , "<ListOfAllocationProfiles>"
    3  , "<AllocationProfile>"
    4  , "<name>Percent_60_40</name>"
    5  , "<type>1</type>"
    6  , "<ListOfAllocations varName=\"listOfAllocations\">"
    7  , "<Allocation>"
    8  #Replace with your own accountIds
    9  , "<acct>DU119915</acct>"
    10  , "<amount>60.0</amount>"
    11  , "</Allocation>"
    12  , "<Allocation>"
    13  #Replace with your own accountIds
    14  , "<acct>DU119916</acct>"
    15  , "<amount>40.0</amount>"
    16  , "</Allocation>"
    17  , "</ListOfAllocations>"
    18  , "</AllocationProfile>"
    19  , "</ListOfAllocationProfiles>"))
    ...
    1  self.replaceFA(1002, FaDataTypeEnum.PROFILES, FaAllocationSamples.FaOneProfile)

Note: The above command will replace any previous FA profile configuration in TWS with one 'Percent_60_40' profile allocation

  • public static string FaTwoProfiles = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    + "<ListOfAllocationProfiles>"
    + "<AllocationProfile>"
    + "<name>Percent_60_40</name>"
    + "<type>1</type>"
    + "<ListOfAllocations varName=\"listOfAllocations\">"
    + "<Allocation>"
    //Replace with your own accountIds
    + "<acct>DU119915</acct>"
    + "<amount>60.0</amount>"
    + "</Allocation>"
    + "<Allocation>"
    //Replace with your own accountIds
    + "<acct>DU119916</acct>"
    + "<amount>40.0</amount>"
    + "</Allocation>"
    + "</ListOfAllocations>"
    + "</AllocationProfile>"
    + "<AllocationProfile>"
    + "<name>Ratios_2_1</name>"
    + "<type>2</type>"
    + "<ListOfAllocations varName=\"listOfAllocations\">"
    + "<Allocation>"
    //Replace with your own accountIds
    + "<acct>DU119915</acct>"
    + "<amount>2.0</amount>"
    + "</Allocation>"
    + "<Allocation>"
    //Replace with your own accountIds
    + "<acct>DU119916</acct>"
    + "<amount>1.0</amount>"
    + "</Allocation>"
    + "</ListOfAllocations>"
    + "</AllocationProfile>"
    + "</ListOfAllocationProfiles>";
    ...
    client.replaceFA(1003, Constants.FaProfiles, FaAllocationSamples.FaTwoProfiles);
  • public static final String FA_TWO_PROFILES = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    + "<ListOfAllocationProfiles>"
    + "<AllocationProfile>"
    + "<name>Percent_60_40</name>"
    + "<type>1</type>"
    + "<ListOfAllocations varName=\"listOfAllocations\">"
    + "<Allocation>"
    //Replace with your own accountIds
    + "<acct>DU119915</acct>"
    + "<amount>60.0</amount>"
    + "</Allocation>"
    + "<Allocation>"
    //Replace with your own accountIds
    + "<acct>DU119916</acct>"
    + "<amount>40.0</amount>"
    + "</Allocation>"
    + "</ListOfAllocations>"
    + "</AllocationProfile>"
    + "<AllocationProfile>"
    + "<name>Ratios_2_1</name>"
    + "<type>2</type>"
    + "<ListOfAllocations varName=\"listOfAllocations\">"
    + "<Allocation>"
    //Replace with your own accountIds
    + "<acct>DU119915</acct>"
    + "<amount>2.0</amount>"
    + "</Allocation>"
    + "<Allocation>"
    //Replace with your own accountIds
    + "<acct>DU119916</acct>"
    + "<amount>1.0</amount>"
    + "</Allocation>"
    + "</ListOfAllocations>"
    + "</AllocationProfile>"
    + "</ListOfAllocationProfiles>";
    ...
    client.replaceFA(1003, FADataType.PROFILES.ordinal(), FAMethodSamples.FA_TWO_PROFILES);
  • 'Replace with your own accountIds
    Public Shared FaTwoProfiles As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" &
    "<ListOfAllocationProfiles>" &
    "<AllocationProfile>" &
    "<name> Percent_60_40</name>" &
    "<Type>1</type>" &
    "<ListOfAllocations varName = ""listOfAllocations"">" &
    "<Allocation>" &
    "<acct> DU119915</acct>" &
    "<amount>60.0</amount>" &
    "</Allocation>" &
    "<Allocation>" &
    "<acct> DU119916</acct>" &
    "<amount>40.0</amount>" &
    "</Allocation>" &
    "</ListOfAllocations>" &
    "</AllocationProfile>" &
    "<AllocationProfile>" &
    "<name> Ratios_2_1</name>" &
    "<Type>2</Type>" &
    "<ListOfAllocations varName = ""listOfAllocations"">" &
    "<Allocation>" &
    "<acct> DU119915</acct>" &
    "<amount>2.0</amount>" &
    "</Allocation>" &
    "<Allocation>" &
    "<acct> DU119916</acct>" &
    "<amount>1.0</amount>" &
    "</Allocation>" &
    "</ListOfAllocations>" &
    "</AllocationProfile>" &
    "</ListOfAllocationProfiles>"
    ...
    client.replaceFA(1003, Constants.FaProfiles, FaAllocationSamples.FaTwoProfiles)
  • std::string profileXml =
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    "<ListOfAllocationProfiles>"
    "<AllocationProfile>"
    "<name>Percent_60_40</name>"
    "<type>1</type>"
    "<ListOfAllocations varName=\"listOfAllocations\">"
    "<Allocation>"
    "<acct>DU119915</acct>"
    "<amount>60.0</amount>"
    "</Allocation>"
    "<Allocation>"
    "<acct>DU119916</acct>"
    "<amount>40.0</amount>"
    "</Allocation>"
    "</ListOfAllocations>"
    "</AllocationProfile>"
    "<AllocationProfile>"
    "<name>Ratios_2_1</name>"
    "<type>2</type>"
    "<ListOfAllocations varName=\"listOfAllocations\">"
    "<Allocation>"
    "<acct>DU119915</acct>"
    "<amount>2.0</amount>"
    "</Allocation>"
    "<Allocation>"
    "<acct>DU119916</acct>"
    "<amount>1.0</amount>"
    "</Allocation>"
    "</ListOfAllocations>"
    "</AllocationProfile>"
    "</ListOfAllocationProfiles>";
    ...
    m_pClient->replaceFA(1003, faDataType::PROFILES, FAMethodSamples::FATwoProfiles());
  • 1  FaTwoProfiles = "".join(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    2  , "<ListOfAllocationProfiles>"
    3  , "<AllocationProfile>"
    4  , "<name>Percent_60_40</name>"
    5  , "<type>1</type>"
    6  , "<ListOfAllocations varName=\"listOfAllocations\">"
    7  , "<Allocation>"
    8  #Replace with your own accountIds
    9  , "<acct>DU119915</acct>"
    10  , "<amount>60.0</amount>"
    11  , "</Allocation>"
    12  , "<Allocation>"
    13  #Replace with your own accountIds
    14  , "<acct>DU119916</acct>"
    15  , "<amount>40.0</amount>"
    16  , "</Allocation>"
    17  , "</ListOfAllocations>"
    18  , "</AllocationProfile>"
    19  , "<AllocationProfile>"
    20  , "<name>Ratios_2_1</name>"
    21  , "<type>2</type>"
    22  , "<ListOfAllocations varName=\"listOfAllocations\">"
    23  , "<Allocation>"
    24  #Replace with your own accountIds
    25  , "<acct>DU119915</acct>"
    26  , "<amount>2.0</amount>"
    27  , "</Allocation>"
    28  , "<Allocation>"
    29  #Replace with your own accountIds
    30  , "<acct>DU119916</acct>"
    31  , "<amount>1.0</amount>"
    32  , "</Allocation>"
    33  , "</ListOfAllocations>"
    34  , "</AllocationProfile>"
    35  , "</ListOfAllocationProfiles>"))
    ...
    1  self.replaceFA(1003, FaDataTypeEnum.PROFILES, FaAllocationSamples.FaTwoProfiles)

Note: The above command will add another 'Group_Pct_Change' group allocation to the previous FA configuration

Confirming replaceFA Configuration Updates

In order to confirm that your FA changes were saved, you may wait for the IBApi::EWrapper::replaceFAEnd callback shown below, which provides the corresponding reqId.

  • public class EWrapperImpl : EWrapper
    {
    ...
    public virtual void replaceFAEnd(int reqId, string text)
    {
    Console.WriteLine("Replace FA End. ReqId: " + reqId + ", Text: " + text + "\n");
    }
  • public class EWrapperImpl implements EWrapper {
    ...
    @Override
    public void replaceFAEnd(int reqId, String text) {
    System.out.println(EWrapperMsgGenerator.replaceFAEnd(reqId, text));
    }
  • Public Class EWrapperImpl
    Implements EWrapper
    ...
    Public Sub replaceFAEnd(reqId As Integer, text As String) Implements IBApi.EWrapper.replaceFAEnd
    Console.WriteLine("replaceFAEnd. ReqId: {0}, Text: {1}", reqId, text)
    End Sub
  • class TestCppClient : public EWrapper
    {
    ...
    void TestCppClient::replaceFAEnd(int reqId, const std::string& text) {
    printf("Replace FA End. Request: %d, Text:%s\n", reqId, text.c_str());
    }
  • 1 class TestWrapper(wrapper.EWrapper):
    ...
    1  def replaceFAEnd(self, reqId: int, text: str):
    2  super().replaceFAEnd(reqId, text)
    3  print("ReplaceFAEnd.", "ReqId:", reqId, "Text:", text)

In addition, after saving changes, it is advised to verify the new FA setup via IBApi::EClient::requestFA. If it is called before changes are fully saved, you may receive an error. See Message Codes.

Unification of Groups and Profiles

With TWS/IBGW build 983+, the API settings will have a new flag/checkbox, "Use Account Groups with Allocation Methods" (enabled by default for new users). If not enabled, groups and profiles would behave the same as before. If it is checked, group and profile functionality will be merged, and API clients will see the following changes:

Model Portfolios and the API

Placing Orders to a FA account