Home


CQG API and MATLAB® FAQ

CQG has integrated its hosted market data servers and exchange gateways with MATLAB from The MathWorks™, the leading developer of mathematical computing software. MATLAB is a widely-used, high-level environment for algorithm development, data visualization, analysis, and mathematical modeling.

Read through our FAQ for detailed information on accessing the CQG API and MATLAB.


 

CQG API and MATLAB FAQ


Which CQG IC versions will allow me to use MATLAB from custom studies?
8x2870 or above.
Can I use the change in open interest for determining when to roll the futures contracts for a continuation chart/data instead of using the roll-over-date for continuation chart/data?
Yes, that is possible using MATLAB in CQG.
Is there any issue with CPU and GPU loads?
There may be depending on the computer; however, CQG believes the best solution currently is the NVIDIA Tesla card. It can process anywhere from 10 to 50 times faster. It is the preferred option for performing complex tests in MATLAB. MathWorks supplies an add-on to MATLAB called the Parallel Computing Toolbox, which allows you to take full advantage of multi-core, and the MATLAB Distributed Computing Server, which supports grid architecture.
Can I create an indicator of indicators, like a confluence of indicators in different time frames?
You can write an indicator of indicators in CQG or in MATLAB.
Do you use COM for data in and out? How does that compare to RTD, Active X, DDE, etc.?
COM is generally faster than other interfaces and is not tied/limited to a specific technology (like DDE to Excel, etc.). We optimized our COM interfaces, so that they would not introduce latency and still be very flexible.
What is the charge for the CQG API for connecting to MATLAB?
CQG fees for the API are determined by the level of service you require. Additional information is available. For MATLAB, the minimum API requirement is Base Historical Data API. API options include:
  • Real-Time Data API:  $45/month
  • Trading API:  $245/month (requires Standard or Advanced Trading)
  • Base Historical Data API:  $100/month
  • Extended Historical Data API:  $300/month
  • Extended Historical Plus Data API:  $1,000/month
  • Unlimited Historical Data API:  $6,000/month. A one-year prepayment is required.
Regarding the DOMTracker with the TFlow® chart, why does low DOM activity indicate market orders are being entered into the market by traders and not limit orders?
The DOMTracker study tracks the size of resting orders in the four queues above the best ask and the four queues below the best bid. If the DOMTracker readings are low, then traders are either entering market orders or are on the sidelines.
Does CQG offer samples of code for setting up the API for CQG to MATLAB?
To use MATLAB functions (canned or custom) within CQG, you do not need to code the API. For more advanced analysis within MATLAB, you will need to code the API. CQG provides the API samples of integration with MATLAB. You need to have some programming experience and knowledge of MATLAB in order to code the API effectively. CQG can only call one value from a MATLAB function at a time; therefore, more sophisticated analysis requires the use of the CQG API.
Do you use ActiveX or Java Socket technologies?
CQG API is a COM server. Our API samples illustrate its usage.
How much intraday data is available per instrument?
Data can be purchased from the CQG Data Factory™. If you are enabled for CQG Backtesting, then 18 months of 5-minute data and multiples thereof are available. Five years of data is available at an additional charge. In terms of utilizing the API for historical data, there are four options to choose from:
Data Types API Historical
API Extended Historical
API Extended Historical Plus
Intraday (Greater than 60 min.), Daily, Weekly, Monthly: 300 Bars 1,000 Bars 4,000 Bars
Intraday (Less than or equal to 60 min.): 3,000 Bars 10,000 Bars 40,000 Bars
Tick Data: 2 Trading Days 2 Trading Days 2 Trading Days
CVB, P&F, and TFlow Bars: 5 Trading Days 10 Trading Days 20 Trading Days
Do MATLAB functions slow down trade system performance?
There is unavoidable latency between the CQG API and MATLAB. However, with high-end computing power, this should be kept to a minimum. Given the fact that MATLAB runs in a different processor on a multicore system, CQG and MATLAB should have minimal impact on each other.
Can MATLAB display real-time charts or custom studies and data?
Yes. The data can be retrieved via the API.
Can MATLAB show sub-interval data, for example, 60-second charts?
Yes. With CQG, you can display market data in the form of constant volume bars (CVB), which build the bars based on a threshold of executed volume or tick volume, not time, as well as TFlow® charts. TFlow charts plot the best bid and best ask at the highs and lows and are color-coded based on the amount of executed volume. Visit our Web site for more information on CQG charting. MATLAB also supports a range of charting from simple line plots and bar charts in base MATLAB to more specific candlestick charts and cash flow plots (functionality within the Financial Toolbox).
I’m currently using Excel® DDE quite heavily, and it seems to slow down the PC noticeably because there are many calculations involved. Will the MATLAB and CQG API combination reduce the load on my PC so it runs faster?
DDE is generally old and heavy technology. Just changing the data source from DDE to API will improve the performance. In addition, if the calculations in question are complex, then MATLAB is a better place to do them than Excel.

MATLAB FAQ


What makes MATLAB faster than conventional C++ or other programming languages to execute instructions?
MATLAB is more effective for development because it provides an extensive mathematical engine while C++ is a tool that allows you to create anything from scratch, which consumes resources.
Can you call DLLs from MATLAB?
You can call DLLs from MATLAB. Three possible techniques include the function loadlibrary, the MEX (MATLAB executable) interface, and the COM interface. CQG also provides the functionality to call DLL libraries for use within CQG.
Can I debug custom studies implemented in MATLAB?
If you write a MATLAB custom function, run it in MATLAB and MATLAB indicates any errors in your programming.
How does MATLAB record data? Does it use a data buffer?
CQG supplies whatever market data MATLAB requires to perform the calculations. The user decides whether the data is stored in MATLAB or in the CQG API. MATLAB can also write data to Excel, databases, or standard formats such as text, csv, and binary.
What functions, such as your example of using the MATLAB "mean" function, are available? Can you access the code behind the function?
MATLAB has over eight thousand functions built in and available for programming. Refer to MATLAB’s user guides for more details.
Does MATLAB offer a financial module?
You need MATLAB to connect to CQG. MATLAB offers toolkits, such as the Fixed Income Toolkit, that provide specific financial functions. For example, the Fixed-Income Toolbox™ extends MATLAB by providing functions for fixed income modeling and analysis. The toolbox includes tools for determining the price, yield, and cash flow for many types of fixed income securities, including mortgage-backed securities, corporate bonds, treasury bonds, municipal bonds, certificates of deposit, and treasury bills. MATLAB can guide you through what is best for your needs.
Are the financial functions integrated into a MATLAB standard version?
No, they are not. This link takes you to a list of available modules.
What energy commodity data is available in CQG?
This link takes you to a list of the exchanges CQG covers for energy, which includes all the major exchanges worldwide and some OTC data. In addition, MATLAB offers a solution for energy suppliers, producers, and traders.
What is the cost for the MATLAB version (plus financial module, if necessary) that works best with CQG?
For a complete listing of MATLAB products and pricing by region, visit http://www.mathworks.co.uk/store/default.do.

CQG API
API Article
API Flyer
API Technical Docs
Markets Covered
Trading Platforms

 

Copyright © CQG, Inc. All rights reserved.

CQG, Inc. has registered CQG®,  DOMTrader®, SnapTrader®, TFOBV®, TFOBVO®, and TFVOL®.
TradeFlow™ and TFlow™ are trademarks of CQG, Inc.