Possible to query list of FA / F&F accounts by Group?

Using IBController, is it possible to get a list of FA sub-accounts that are within a "Group" that was setup in TWS?

The reason I ask is that although I can use FAParams to allocate shares to Groups, I don't see a function that would let me see how much cash the accounts in the group have.

1 Like

To expand on this question above, I have 5 accounts in the Family and Friends.

I can obtain the aggregate of all account.

In TWS I have set up groups. I want to send an order to a group called "Swing" and I understand how to do that. Since I need to specify the number of shares, I need to do a calculation. My calculation is 1% risk of account liquidity and based on the distance between the stop and limit entry price.

To perform the calculation, I need the liquidity information from these 3 accounts.

Is it possible to pull that info for only the group? (I don’t think so)

I know I can pole each account separately but there is a delay, and TWS goes nuts if we change accounts to often.

Any suggestions for implementing this?

Is there something obvious I am missing in my architecture for placing these trades?

Here is what I came up with.
It will get the balances only once and store the total of 3 of the accounts (from a group of accounts "P_Swing") in 'AvalabkleFunds'
Then I use that total to do my risk calculation.

Since the paper account is new all the 5 accounts are the same balances.
Will I need to use ibc.ClearList( -1 ) between each ibc.SetInfoAccount( Account ) ??
I will need to wait until the market is open and I get the balances different by placing some big paper trades.


    if( Status( "stocknum" ) == 0 AND  Nz( StaticVarGet( "ChangeAccountDone" ) ) == 0 )
    {
        ibc.SetInfoAccount( Account );
        AccountNetLq = StrToNum( ibc.GetAccountValue( "NetLiquidationByCurrency" ) );
        _TRACE( "Account " + Account + ", NetLq: " + AccountNetLq );

        ibc.SetInfoAccount( Account1 );
        Account1NetLq = StrToNum( ibc.GetAccountValue( "NetLiquidationByCurrency" ) );
        _TRACE( "Account1 " + Account1 + ", NetLq: " + Account1NetLq );

        ibc.SetInfoAccount( Account2 );
        Account2NetLq = StrToNum( ibc.GetAccountValue( "NetLiquidationByCurrency" ) );
        _TRACE( "Account2 " + Account2 + ", NetLq: " + Account2NetLq );

        ibc.SetInfoAccount( Account3 );
        Account3NetLq = StrToNum( ibc.GetAccountValue( "NetLiquidationByCurrency" ) );
        _TRACE( "Account3 " + Account3 + ", NetLq: " + Account3NetLq );

        ibc.SetInfoAccount( Account4 );
        Account4NetLq = StrToNum( ibc.GetAccountValue( "NetLiquidationByCurrency" ) );
        _TRACE( "Account4 " + Account4 + ", NetLq: " + Account4NetLq );

        ibc.SetInfoAccount( Account5 );
        Account5NetLq = StrToNum( ibc.GetAccountValue( "NetLiquidationByCurrency" ) );
        _TRACE( "Account3 " + Account5 + ", NetLq: " + Account5NetLq );

        StaticVarSet( "ChangeAccountDone", 1 );

        if( AccountInput == "P_Swing" )
        {
            AvailableFunds = Account2NetLq +  Account3NetLq +  Account4NetLq;
            StaticVarSet("AvailableFunds", AvailableFunds);
            _TRACE( "Available funds =  " +  AvailableFunds );
        }
    }
//ibc.ClearList( -1 );
AvailableFunds = StaticVarGet("AvailableFunds");

After changing the infoaccount, you have to make your code wait until the account actually changes, and the code has to check the infoaccount to verify that it is the correct one. It can take a few seconds. Then it has to wait for the balances to populate because they will be zero if there is no delay.

In this same way you also query all the positions for each account and store them as static variables. It's important to do this on each account because you could have a long position in one account that is offset by an equal short position in another account, that would be reported as zero shares at the master level.

Also, you should have a string that contains the list of accounts, and loop through the list instead of writing redundant code. You'll need a loop within the account loop to store the information on each position within each account.

I hope this helps.

1 Like

Also I think you should change the infoaccount back to what it was before you changed it.

1 Like

Hi Pater, just wanted to thank you for the time you took to help me out and point me in the right direction. Very helpfull indeed