Creating flex queries (Interactive Brokers)

<< Click to Display Table of Contents >>

Navigation:  Import > Interactive Brokers >

Creating flex queries (Interactive Brokers)

Introduction

 

TradingDiary Pro uses Interactive Brokers (IB) xml statement for importing transaction history.

Interactive Brokers provides two types of xml statements. The Activity Flex and Trade Confirms Flex.

    Activity Flex statement provides daily data with all information at the end of the day (Total equity, open positions, trades, cash transactions etc.)

    Trade Confirms Flex provides the trades only but it is refreshed immediately after the trade is confirmed.

 

For the successful importing process you have to activate the Flex Web Service, generate a token for web service downloading and create three ID-s belonging to the xml statements described above.

 

Please do the following steps:

 

Creating Activity Flex Queries

 

You have to define two queries. One is for the last 30 days' data and one is for the last 365 days' data.

So please log in to the IB Account Management.

Click on the of the Reports/Flex Queries.

 

clip0148

 

In the Custom Flex Queries section click on the CREATE ACTIVITY FLEX QUERY button.

 

You can see something like this:

 

clip0149

 

 

 

Creating 30 days Activity Flex Query

 

Press the create new flex query button and set the followings:

 

Query Name:                Last30Days

 

Output Format:              XML

 

Accounts:                     Select one account id. Note: multiple accounts in one database are currently not supported.

 

Date Configuration, Period         Set the Last 30 Calendar Days, do not set From Date and To Date fields.

 

Include Canceled Trades                No

 

Include Currency Rates                Yes

 

Now you can see available sections of the statement.

 

Setup flex query 

 

You have to add all fields of the following sections:

 

Account Information

Cash Transactions

CFD Charges

Change in Dividend Accruals

Corporate Actions

Financial Instrument Information

Net Asset Value In Base

Open Dividend Accruals

Open Positions (set Level of Detail to Lot)

Option Exercises, Assignments and Expirations

Prior Period Positions

Trades (tick the Executions)

Transaction Fees

Transfers (ACAT, Internal)

 

To add all fields of a section click on the Section Name for example Account Informations. Click on the Select All check box. Scroll down and click on the Save button. Repeat this for all sections.

 

In the Account Configuration click on the Add/Edit accounts and add all account which you'd like to follow in TradingDiary Pro.

Click on the Continue button at the bottom of the page. In the review phase simply scroll down to the bottom of the page and click on the Create button.

 

clip0151

 

 

Creating 365 days Activity Flex Query.

 

To create another query first click on the small gear right.

 

Run defined flex query

 

In the Flex Templates click on the small + sign.

 

clip0155

 

This statement is the same as the previous one except that the date range is 365 days instead of 30 days.

 

Set the followings:

 

Query Name:                Last365Days

 

Output Format:              XML

 

Accounts:                     Select only one account id. Note: multiple accounts in one database are currently not supported.

 

Date Configuration, Period         Set the Last 365 Calendar Days, please do not set From Date and To Date fields.

 

Include Canceled Trades                No

 

Include Currency Rates                Yes

 

You have to add all fields of the following sections:

 

Account Information

Cash Transactions

CFD Charges

Change in Dividend Accruals

Corporate Actions

Financial Instrument Information

Net Asset Value Summary In Base

Open Dividend Accruals

Open Positions (set Level of Detail to Lot)

Option Exercises, Assignments and Expirations

Prior Period Positions

Trades (tick the Executions)

Transaction Fees

Transfers (ACAT, Internal)

 

To add all fields of a section click on the Section Name for example Account Informations. Click on the Select All check box. Scroll down and click on the Save button. Repeat this for all sections.

 

In the Account Configuration click on the Add/Edit accounts and add all account which you'd like to follow in TradingDiary Pro.

Click on the Continue button at the bottom of the page. In the review phase simply scroll down to the bottom of the page and click on the Create button.

 

Press the Save Query button and you can see something like this:

 

clip0156

 

 

Creating Trade Confirms Flex

 

clip0157

 

Click on the CREATE TRADE CONFIRMATIONS FLEX QUERY:

 

 

Creating Trade Confirms Flex.

 

Set the followings:

 

Query Name:                Today

 

Output Format:              XML

 

Accounts:                     Select only one account id. Note: multiple accounts in one database are currently not supported.

 

Date Configuration, Period         Set Today, please do not set From Date and To Date fields.

 

Add all fields in the Trade Confirmations.

 

In the Account Configuration click on the Add/Edit accounts and add all account which you'd like to follow in TradingDiary Pro.

Click on the Continue button at the bottom of the page. In the review phase simply scroll down to the bottom of the page and click on the Create button.

 

clip0158

 

You have create all of the required flex queries. Click on the small gear once again.

 

clip0159

 

 

clip0160

 

In the flex query templates there are 3 queries. Each query has an own ID. Click on each query and write down the query ID.

 

clip0161

 

 

Now you have completed the Flex Query creation so you have three ID-s.

 

1.   Activity Flex of last 30 days ID

2.   Activity Flex of last 365 days ID

3.   Trade Confirms Flex ID

 

If you want to import through the web service do not log off the IB Account Management and follow the Web Service Import chapter. If you would like to use the file import go to the File Import chapter.