Creating QFormulas
Description
|
QFormulas enable you to define specific market spreads, such as crack or crush, or custom indices.
|
Situational examples
|
Weighting spreads between markets to normalize different contract specifications (for example, heating oil is quoted in gallons while crude oil is quoted in barrels).
Monitoring the basis between the cash and futures or two futures contracts of different months.
Monitoring and charting the daily equity gain or loss in a distinct portfolio.
Tracking custom securities indices.
|
Formula components
|
QFormulas can contain multiple symbols, constants, or coefficients as well as specific conditions, bar values, study values, user values, and function values.
|
Formula example
|
SPREAD(DB-3.25*DL+4*DG, , , 4:13:16)
Calculates the spread between the Bund, BOBL, and Schatz.
|
Location
|
Formula Builder, QFormulas window
|
Used with
|
Use these anywhere you’d use a symbol.
QFormulas can be used in quote and chart windows by entering the QNumber in the entry field.
You can assign a set of trading parameters to a particular QFormula on the Risk, Limits & Stops, and Iceberg Strategies trading preference windows. Follow the same steps you would for assigning values to a specific symbol, but select the QFormula instead.
|
Pre-defined formulas
|
CQG provides dozens of pre-set QFormulas.
|
13.To create QFormulas -
Click the Formula button to open Formula Builder.
-
Click the QFormulas tab.
-
Click the New button.
-
Type the name of the formula.
-
Click OK. The system automatically assigns the next available QNumber.
-
Enter the formula in the Formula Editor. Type the formula or use the toolbox.
-
Click Close when you’re finished.
To copy a QFormula
-
This option is helpful when you want to create a new formula from an existing formula.
-
Select the formula you want to copy.
-
Click the Copy button.
-
Enter the name of the new formula.
-
Click OK.
-
Make the necessary changes in the Formula Editor.
-
Click Close when you’re finished.
See also: User-Defined Strategies (UDS)|topic=User-Defined Strategies (UDS)
14.To create XData QFormulas
XData allows you to import your proprietary, external minute or higher time-frame data for charting and analysis. XData is associated with a QFormula.
-
Click the Formula button to open Formula Builder.
-
On the QFormulas window, click the New button.
-
Type a name for the QFormula, and click OK.
-
Click the XData button (at the bottom of the Formula Editor).
-
Enter a CQG symbol in the Issue field. The symbol you choose reflects the same holiday schedule, session information, and price format as your external data.
-
Browse to find the data file to use in the formula.
-
Select the date format that you used in the data file. If you select OldFormat, the date format must be YYMMDD in the data file.
-
If you would like the system to check for changes in the ASCII file and automatically import the data, set the Update Rate in seconds.
-
Click OK.
Data file format
The ASCII file must be tab-delimited (.txt file) or space-delimited (.prn file). File type .csv (comma-delimited) cannot be used. Data must be ascending.
For XData study, the columns should contain this bar data:
Column A = Date
If you select OldFormat as the date type when you set up the QFormula, then the date format must be YYMMDD. Otherwise, the date format can be any combination of DD, YY, and MM with any non-digit delimiter. For example, YYaDDbMM is valid date format.
Column B = Time
Format HH:MM or HHMM. For daily or higher time-framed data, you do not need this column.
Column C = Open
Column D = High
Column E = Low
Column F = Close
The system automatically assigns OHLC to four columns of data following the time, HLC for three columns, HL for two columns, and C for one column.
For BarXData, CVBXData, and TFXData studies, the columns should contain this tick data:
Format MM.DD.YY
Format hh:mm:ss.iii
-
Column C = Bid
-
Column D = BidVolume
-
Column E = Ask
-
Column F = AskVolume
-
Column G = Trade
-
Column H = TradeVolume
You can also create a file using CQG data by copying and pasting data from a Tabular Display chart.
You can calculate the yield of a futures contract based on the treasury delivered against it. The calculation uses the invoice price, which is the conversion factor multiplied by the futures price.
You create a QFormula and then set the treasury and the calculation parameters. For example, if you know the cheapest-to-deliver (CTD), then you can use that treasury’s maturity and coupon to calculate the futures contract yield.
Apply the QFormula as you would any QFormula: on a chart, on a trading application, or on a quote application.
-
On Formula Builder, click the QFormulas tab.
-
Click the New button.
-
Type a name for the QFormula.
-
Click OK.
-
Type Yield( and the system displays the yield formula and an example to assist you. Replace the @ in Yield(@) with a symbol. Alternatively, you can enter the symbol, and then apply the Yield function.
-
Click the Setup button.
-
Choose one of three modes:
Default = Calculates yield based on futures standard contract maturity and coupon. For example, TYA coupon is 6% and a 10-year maturity from today. In addition, you can use a cash treasury issue such as Yield(BTC10) for a QFormula for a tradable spread, such as SPREAD(Yield(TYA)-Yield(BTC10), L1, 0.001, 10:1,, 1). Selecting Default for Yield(BTC10) uses the maturity, coupon, and price for the benchmark 10-year treasury.
Specific Issue (only with futures) = Calculates yield of the futures contract based on the entered treasury maturity, coupon, and invoice price (futures price * conversion factor for that cash treasury).
Custom = Calculates yield based on a treasury.
-
Choose calculation parameters for a specific or custom issue:
Specific Issue = Type a treasury symbol (e.g. B033P1119) or its alias. The convention, maturity, coupon rate, coupon frequency, and day count are provided automatically.
Custom = Convention, maturity, coupon rate, coupon frequency, day count, and settlement are editable. This mode allows you to use a non-standard settlement date, such as delivery date, in the calculation.
16.To create spread QFormulas
The first step in setting up spreads, prior to setting calculation parameters and trading preferences, is understanding how to write a spread formula.
You can use either common or extended notation, which are explained later in this section. You can also add net change and yield operators to the spread formula.
While spreads can be set up and traded directly on trading applications, it’s best to create a spread QFormula. Complex spreads are more easily entered on trading applications by typing a QNumber than by typing a complicated formula.
-
Click the Formula button to open Formula Builder.
-
Click the QFormulas tab.
-
Click the New button.
-
Type a name for the QFormula.
-
Click OK. The new QFormula is displayed in the list, and the next QNumber in the series is automatically assigned to it. Click the arrow to change the QNumber, or type a new number.
-
Enter your spread strategy in the Formula Editor. As soon as you have typed SPREAD( the system displays the spread formula and an example to assist you. Replace the @ in SPREAD(@) with your strategy.
Alternatively, you can enter the common notation (e.g. CLE-ET), and then apply the Spread function.
-
If you prefer to select calculation settings using a parameters window instead of typing them into the formula editor, click the Setup button. This button is active when the spread formula is selected.
The Setup Synthetic Spread Calculation Parameters window opens. Make your selections, and then close the window.
This is also the way to apply net change and yield to the spread formula.
-
Click the Trading Execution Patterns button to set trading parameters. Choose which legs to work, the order type, volume ratio, stacked orders parameters, and incomplete order behavior.
-
Close Formula Builder. Now, you’re able to enter the QFormula number directly on the DOMTrader and Order Ticket.
It will be displayed as a number, name, or formula depending on your display format setting.
In the Formula Editor, when you hover your mouse over a part of the strategy, a tooltip is displayed. That tooltip identifies the element of the formula you’re pointing to.
Working with Formula Builder
Formulas are created in the Formula Editor on Formula Builder. You can:
-
Type complete formulas (extended notation) directly into the editor using system-provided tips for guidance.
-
Apply the Spread function found in the Toolbox to a simple expression.
-
Use synthetic spread calculation parameters to add parameters to common notation.
Net Change and Yield Spreads
Net change and yield are calculated as if all of the legs are wrapped in Yield operator, so that these calculations are identical:
YIELD(SPREAD(leg1-leg2+5))
SPREAD(YIELD(leg1)-YIELD(leg2)+5)
And these calculations are identical:
NC(SPREAD(leg1-leg2+5))
SPREAD(NC(leg1)-NC(leg2)+5)
Offsets are calculated as is.
Net Change
You can trade spreads based on net change, the difference between today’s current price and the settlement price. Order duration is limited to DAY, but all order types are supported.
Net change formulas are identified on the tabs.
You can apply net change to a spread using the Setup Synthetic Spread Calculation Parameters window.
Yield
You can trade spreads based on yield for cash symbols. You can trade any order type. Outrights can be traded with any duration. For spreads, only day orders are accepted.
Yield formulas are identified on the tabs. Instead of price in the price column, the difference in yield is displayed. Yields for the legs are displayed in the right-most column of the DOM ladder. You can change the location of the column in Trading Preferences.
You can apply yield to a spread using the Setup Synthetic Spread Calculation Parameters window.
Setting Synthetic Spread Calculation Parameters (Setup Button)
Click the Setup button to open the calculation parameters window. If the Setup button is not active, make sure the spread formula is selected in the Formula Editor.
Changes entered here are reflected in the spread formula in the editor. For example, SPREAD(CLEH2-CLEJ2,L1) becomes SPREAD(CLEH2-CLEJ2,CUR) if you change the calculation mode to currency.
By selecting Yes for Yield, SPREAD(1.6*TYA-USA, , , 5:3) becomes SPREAD(1.6*YIELD(TYA)-YIELD(USA), , , 5:3).
Field definitions
Field
|
Description
|
Calc Mode
|
Identifies how you would like the spread calculated, by legs or currency.
Auto = Displays difference in price between symbols.
L1, L2, L3, etc. = Displays price based on tick value of leg selected.
CUR = Displays the price based on the full currency values of the legs.
Consider E-Mini S&P versus E-Mini NASDAQ 100 using a one contract leg-to-leg ratio. The dollar value of the E-Mini S&P is the price multiplied by $50. If the price of the futures contract is 1097.25, then the value of the contract is $54,862.50 (1097.25 * $50). The dollar value of the E-Mini NASDAQ 100 is the price multiplied by $20. If the price is of the futures contract is 1798.00, then the value of the contract is $18.902.50 (1798.00 * $20). If you calculate EP-ENQ with CUR selected, the price displayed is $18,902.50 ($54,862.50-$35,960.00).
In the case of a spread where two legs trade in different currencies, adjust the expression to the appropriate currency using a conversion ratio, such as today’s exchange rate, as currency is calculated as a raw number and not as a monetary value in a base currency. For example, consider the DAX Index that trades in Euros versus the E-Mini S&P that trades in dollars. To adjust for Euro: SPREAD(DD-EP/1.5,CUR). For USD: SPREAD(1.5*DD-EP,CUR).
Price for spreads that include cash instruments inherit their formatting from the leg that is used for tick size calculation. For example, SPREAD(BUS02-TUA) is formatted in the same way as BUS02. If the calculation mode is changed to L2, then spread price is formatted in the same way as TUA. If you define the tick size, then the price is formatted as a rounded decimal. Applies to Order Ticket and DOMTrader only.
Default = Auto.
|
Rollover
|
If turned on, when one leg expires, all legs roll over to the same month. Allowed values:
OFF = Same month rollover is turned off.
ON = Same month rollover is turned on.
Default = OFF.
|
Tick Size
|
Use Auto or enter a tick size value.
Auto = Uses L1 tick size for spread tick size.
5 = Uses 5 as the tick increment.
10 = Uses 10 as the tick increment.
Default = Auto.
|
Trade Strategy
|
Opens the trading parameters window.
|
BAT filter
|
You can have the system select bid/ask or trades or you can make the selections yourself for each leg.
Spread
Auto = Tells the system to use bid/ask data if available, otherwise trade data. Default.
By Legs = Indicates that you will make the data selection for each leg.
Leg
Bid/Ask = If leg side is buy, leg ask price is used for spread ask price calculation and leg bid price is used for spread bid price calculation. If leg side is sell, leg ask price is used for spread bid price calculation and leg bid price is used for spread ask price calculation. Default.
Bid/Bid = Leg ask price is used for spread ask price calculation and leg bid price is used for spread bid price calculation.
Trade = Trades of the given leg are used for both synthetic spread ask and bid prices calculation.
|
NC
|
Select Yes to quote by net change instead of price.
|
Yield
|
Select Yes to quote by yield instead of price.
|
17.To create aggregation QFormulas -
Click the Formula button to open Formula Builder.
-
Click the QFormulas tab.
-
Click the New button.
-
Type a name for the QFormula.
-
Click OK. The new QFormula is displayed in the list, and the next QNumber in the series is automatically assigned to it. Click the arrow to change the QNumber, or type a new number.
-
Enter your strategy in the Formula Editor. As soon as you have typed AGGR( the system displays the strategy formula and an example to assist you. Replace @ with your strategy.
Alternatively, you can apply the aggregation function.
-
If you prefer to select calculation settings using a parameters window instead of typing them into the formula editor, click the Setup button. This button is active when the spread formula is selected.
-
Click the Trading Execution Patterns button to set trading parameters. Choose which legs to work, the order type, volume ratio, stacked orders parameters, and incomplete order behavior.
-
Close Formula Builder. Now, you’re able to enter the QFormula number directly on the DOMTrader and Order Ticket.
It is displayed as a number, name, or formula depending on your display format setting.
Setting Aggregation Calculation Parameters (Setup Button)
Click the Setup button to open the calculation parameters window. If the Setup button is not active, make sure the aggregation formula is selected in the Formula Editor.
Changes entered here are reflected in the formula in the editor. Field definitions
Field
|
Description
|
Calc Mode
|
Identifies how you would like the strategy calculated, by legs or currency.
Auto = Displays difference in price between symbols.
L1, L2, L3, etc. = Displays price based on tick value of leg selected.
CUR = Displays the price based on the full currency values of the legs.
Default = Auto.
|
Rollover
|
If turned on, when one leg expires, all legs roll over to the same month. Allowed values:
OFF = Same month rollover is turned off.
ON = Same month rollover is turned on.
Default = OFF.
|
Tick Size
|
Select Auto or a tick size from the drop down menu.
Auto (default) = Uses L1 tick size for strategy tick size.
|
Trade Strategy
|
Opens the trading parameters window.
|
Yield
|
Select Yes to quote by yield instead of price.
|
Share with your friends: |