DDE
T4 supports sending data via DDE to other application providers, such as Microsoft Excel and Open Office.
On the Main tab of the Main Properties you will find the DDE Format option. This allows you to change between Excel and OpenOffice Calc DDE syntax. They are not the same.
To recieve quote data from a particular DDE link MUST have a Quote Board window open and containing the desired market. Then click the ‘DDE’ button on the Quote Board. Right click on a cell in your spreadsheet and choose the ‘Paste’ menu item. This will paste a table of links to T4 that contain the same markets and columns as your Quote Board. Alternatively, you can right click on a single value in the Quote Board and select the ‘Copy DDE Link’ menu item, then paste into your spreadsheet. Only the specific value will be linked.
Again, the market must be displayed in the Quote Board window BEFORE it is linked to your spreadsheet. This also applies if you are loading a saved spreadsheet.
Getting Data Into Excel
IMPORTANT: In order to pull data via DDE from T4, you first need to have T4 open and subscribed to the desired markets. A subscription can be made by adding the desired markets to a quote board. It is good practice to open T4 first, then open Excel; and to close Excel first, then close T4.
The DDE link format for market data in Excel is:
=T4Screen|'MKT_<marketid>'!<value>
Where:
<marketid> is the unique identifier for the market in T4. This does not match any exchange published symbol. You can only obtain these by using the above method of copying the link for a value from T4 and pasting it into Excel or some other application.
<value> is the data value of the market that you want, for example last trade price. The valid values are shown below:
Value | Meaning |
---|---|
Description | The name of the market. |
Numerator | The smallest amount that the price of a market can move by, in ticks. |
Denominator | The denominator used for converting ticks into price and vice-versa. |
Settlement_Price,Settlement_Ticks | The last settlement price received. |
Open_Price,Open_Ticks | The opening trade price for the day. |
High_Price,High_Ticks | The highest traded price for the day. |
Low_Price,Low_Ticks | The lowest traded price for the day. |
Mode | The current market state, e.g. PreOpen, Open, Closed etc. |
Total_Traded_Volume | The total volume traded by this market today. |
Last_Trade_Volume | The last volume traded at the current price. If the frontend is set to show the total traded at this price since the last price changed then that value will be sent, otherwise the volume just traded will be sent. |
Last_Trade_Price,Last_Trade_Ticks | The price of the last trade to occur. |
Bid_Volume | The volume of the current best bid. |
Bid_Price,Bid_Ticks | The price of the current best bid. |
Offer_Volume | The volume of the current best offer. |
Offer_Price,Offer_Ticks | The price of the current best offer. |
Net_Change_Price,Net_Change_Ticks | The net change from the last settlement price to the last trade price. |
The last trade information will include trades in outrights due to spreads trading if the frontend is configured to show that information itself.
The Bid and Offer information will include implied prices if the frontend is configured to show it.
The difference between the ‘_TICKS’ and ‘_PRICE’ values is that the ‘_PRICE’ values are display prices (what you see on the frontend, e.g. 30yr bond = 11215) and the ‘_TICKS’ values are the decimal equivalent that can have math done on it (e.g. 30yr bond = 11215 = 112 points + 15/32 = expressed as a decimal is (112 + (15/32) = 112.46875). Please note that the decimal point is not present for all markets and must be added in programmatically if desired.
To send account and position data you can use the same method as above, except using the Account window instead of the Quote Board. Note that if you trade in a new market then Excel will not automatically detect that position, you must place links in Excel for each specific position that you want.
The DDE link format for account data in Excel is:
=T4Screen|'ACT_<accountid>'!<value>
Where:
<accountid> is the unique identifier for the account in T4. This does not match the account number or name. You can only obtain these by using the above method of copying the link for a value from T4 and pasting it into Excel or some other application.
<value> is the data value of the account that you want, for example P&L. The valid values are shown below:
Value | Meaning |
---|---|
Description | The name of the account. |
Account | The account number. |
Firm | The firm this account belongs to. |
Status | The status of this account, e.g. OK, Blocked etc. |
PL | The total P&L of all the positions for this account |
UPL | The total unrealized P&L of all the positions for this account. |
RPL | The total realized P&L of all the positions for this account. |
Overnight_UPL | The total unrealized P&L due to fills carried over from the previous trading day of all the positions for this account. |
Cash | The amount of available cash the account has available to trade with. Takes into consideration the Balance, P&L and Margin. |
Net_Equity | The balance of the account if all positions were closed. Takes into consideration the Balance and P&L. |
Margin | The total margin requirement for all the positions for this account. |
Balance | The start of day balance of the account. |
The DDE link format for position data in Excel is:
=T4Screen|'POS_<accountid>_<marketid>'!<value>
Where:
<accountid> is the unique identifier for the account in T4. This does not match the account number or name. You can only obtain these by using the above method of copying the link for a value from T4 and pasting it into Excel or some other application.
<marketid> is the unique identifier for the market in T4. This does not match any exchange published symbol. You can only obtain these by using the above method of copying the link for a value from T4 and pasting it into Excel or some other application.
<value> is the data value of the position that you want, for example P&L or net position. The valid values are shown below:
Column A | Column B |
---|---|
Description | The name of the market this position is for. |
Net | The net position of this account in this market. |
PL | The total P&L of this position. |
UPL | The unrealized P&L from the open position. |
RPL | The realized P&L from the closed position. |
Overnight_UPL | The unrealized P&L due to positions carried over from the previous trading day. |
Margin | The margin requirement for this position. |
Buys | The total number of contracts bought. |
Sells | The total number of contracts sold. |
Working_Buys | The number of buy contracts that are working. |
Working_Sells | The number of sell contracts that are working. |
DDE Commands
You can control some aspects of the T4 frontend via DDE commands. These are aimed at people programming applications within Excel that interact with T4.
Opening a Contract Window
You can cause T4 to activate or open a Contract window with a specific market displayed. To do this you need to enter the following in a cell:
=T4Screen|'CW_<MarketID>'!SHOW
where <MarketID> is the id of the market to display.
e.g. =T4Screen|'CW_CME_20130700_OZCN3_SPACE_C0680'!SHOW
Sending this command will cause the frontend to look for the most recently used Contract window for that Contract and bring it on top of any other application, making the specified market the active market. If no Contract window is found for that Contract then it will open a new Contract window and display it with that market active.
If you wish to repeatedly display the same market (e.g. user clicks a cell to display the contract window, then closes the contract window and clicks the cell again) then you need to replace the above cell contents with:
=T4Screen|'CW_<MarketID>'!CLEAR
where <MarketID> is the id of the market.
This clears out the last command processed and will allow the previous command to be sent again as a new command.
If the command succeeds then the value '<Command Succeeded>' will be returned to Excel, if the market is not found then '<Market Not Found>' is returned.
Changing the DDE Advertise Interval
You can change the timer interval that DDE advertisements are sent on. An advertisement is sent when a piece of data you are interested in has changed, e.g. last trade price. This is set at 10ms by default. If you want to slow down the updates then you can change this to be anything up to 60,000ms.
To change the timer you need to enter the following into a cell:
=T4Screen|'TMR_<Interval>'!SET
where <Interval> is the timer interval to set, in milliseconds, between 10 and 60000.
e.g. =T4Screen|'TMR_500'!SET will set the timer interval to be 500ms.
If the command succeeds then the value '<Command Succeeded>' will be returned to Excel.
If you close T4 desktop and reopen it then you would need to execute this command again for it to take effect.
Breaking DDE Links
Excel will allow a user to manually edit excel links. This provides the opportunity for end user error in the form of a typo as Excel DDE links are case sensitive. If a typo occurs the user will have no choice but to remove the broken link and create it correctly from scratch. This is a limitation in Excel.
An example would be if the month is changed using lower case charactors. Excel won't allow the correction of the formula and the formula will never again work.
In Excel 2010 go to the Data tab and click Edit Links.
A dialog will be displayed.
Find the broken link and click “Break Link” and close the dialog.
Use T4 to generate the correct link so that there is no chance of a typo.