Account Summary
For most recent version, see the official docs at github.io/IB4m
Contents
Initialize session with Trader Workstation
% initialize session with TWS session = TWS.Session.getInstance(); % create local buffer for account summary events [buf,lh] = TWS.initBufferForEvent(TWS.Events.ACCOUNTSUMMARY); % list of account attributes to querey attrkeys = [ ... 'AccountType' ,... 'NetLiquidation' ,... 'TotalCashValue' ,... 'SettledCash' ,... 'AccruedCash' ,... 'BuyingPower' ,... 'EquityWithLoanValue,' ,... 'PreviousEquityWithLoanValue,',... 'GrossPositionValue,' ,... 'RegTEquity,RegTMargin,' ,... 'SMA,InitMarginReq,' ,... 'MaintMarginReq,' ,... 'AvailableFunds,' ,... 'ExcessLiquidity,' ,... 'Cushion,' ,... 'FullInitMarginReq,' ,... 'FullMaintMarginReq,' ,... 'FullAvailableFunds,' ,... 'FullExcessLiquidity,' ,... 'LookAheadNextChange,' ,... 'LookAheadInitMarginReq,' ,... 'LookAheadMaintMarginReq,' ,... 'LookAheadAvailableFunds,' ,... 'LookAheadExcessLiquidity,' ,... 'HighestSeverity,' ,... 'DayTradesRemaining,' ,... 'Leverage' ... ]; % establish connection with TWS session.eClientSocket.eConnect('127.0.0.1',7496,0);
Make request for account summary
% request account attributes session.eClientSocket.reqAccountSummary(0,'All',attrkeys); pause(1);
Processing Account Summary Events
% get the event from the local buffer and convert to cell array attrs = collection2cell(buf.get().data); % blab about account attributes cellfun(@(a) ... fprintf('%s: %s = %s (%s)\n',... char(a.account ) ,... char(a.key ) ,... char(a.value ) ,... char(a.currency) ... ), ... attrs ... );
DU207406: FullMaintMarginReq = 0.00 (USD) DU207406: GrossPositionValue = 0.00 (USD) DU207406: FullAvailableFunds = 1003650.61 (USD) DU207406: LookAheadNextChange = 0 () DU207406: SMA = 1003650.62 (USD) DU207406: Cushion = 1 () DU207406: ExcessLiquidity = 1003650.61 (USD) DU207406: LookAheadInitMarginReq = 0.00 (USD) DU207406: DayTradesRemaining = -1 () DU207406: LookAheadExcessLiquidity = 1003650.61 (USD) DU207406: MaintMarginReq = 0.00 (USD) DU207406: FullInitMarginReq = 0.00 (USD) DU207406: LookAheadMaintMarginReq = 0.00 (USD) DU207406: RegTMargin = 0.00 (USD) DU207406: RegTEquity = 1003650.61 (USD) DU207406: AvailableFunds = 1003650.61 (USD) DU207406: FullExcessLiquidity = 1003650.61 (USD) DU207406: InitMarginReq = 0.00 (USD) DU207406: LookAheadAvailableFunds = 1003650.61 (USD)
See Also
AccountUpdatesExample | PositionsExample
References
Interactive Brokers API:
TWS@Github:
Apache Commons:
Oracle: