Home
Charts
Feeds
Download
Resources
Help

API Usage Example

A simple programs that demonstrates how to retrieve the data objects from www.tradingphysics.com programmatically via the API interface.

File Purpose Syntax
NinjaTrader 70.0 Beta 20 Indicator Plug-In
Version 2.0
This is a NinjaTrader 7.0 Beta 20 plug-in written in C#. Install this plug-in into your NinjaTrader application to access real-time and historical indicators using our API. Please refer to the list of indicators and list of oscillators that can be used from within this plug-in. Please follow the comments inside the source code to setup the connection to the API server using your account credentials.
NinjaTrader 6.5 Indicator Plug-In
Version 2.0
This is a NinjaTrader 6.5 plug-in written in C#. Install this plug-in into your NinjaTrader application to access real-time and historical indicators using our API. Please refer to the list of indicators and list of oscillators that can be used from within this plug-in. Please follow the comments inside the source code to setup the connection to the API server using your account credentials.
ThreadAPI.cs
Version 2.0
Demonstrate real-time retrieval of Indicators and Oscillators using a C# console application. The data is retrieved in a separate thread using a TradingPhysics.Connection object that manages authentication tickets, data retrieval, parsing, and access to the retrieved time series. Synchronization techniques are used to access data shared among the main and update threads. Events are used to deliver information upon retrieval of the data. This example can be used to create your own real-time handlers to retrieve various object types. Command line parameters:

- StockSymbol (default is QQQ)

- SessionDate in YYYYMMDD
(defaults to today's date)

- TickPeriod in milliseconds
(default is 60000)

Example:
ThreadAPI SPY 20090803 1000

SampleAPI.cs
Version 1.0
Demonstrate the retrieval if historical data, as well as authentication/error handling mechanisms, using a simple C# console application. Please follow the comments inside the program to retrieve various data objects.

Handling archived files (32-bit mode)

You can download the historical data files in archived format. This will help you save disk space. The default file extension is *.z8. You can use our command-line utilities to quickly unpack/pack the data.

File Purpose Syntax
z8a.exe
Version 1.0
Packs file (Zip-Archive). Accepts source (unpacked) and destination (packed) files as command line parameters. z8a InFile OutFile
z8e.exe
Version 1.0
Unpacks file (Zip-Extract). Accepts source (packed) and destination (unpacked) files as command line parameters. z8e InFile OutFile
zlibwapi32.dll
Version 1.2.3
ZLIB library used by the z8a and z8e utilities. It must be located in the same folder, or in one of the PATH folders, for example C:\Windows\System32\ For specifications, please refer to the original provider web site: http://www.zlib.net/

You don't have to always unpack the files prior to production use. You can use the zlibwapi32.dll, or any other library/interface that supports ZLIB stream decompression, to read z8 files and unpack them on the fly. Please refer to the *.z8 files specification for the way to handle these files.


High-performance 64-bit Compression/Decompression

You might want to leverage your 64-bit capable CPU by using the tool below. It offers 10-15% better compression and up to 50% better decompression speeds. For instance, an ITCH file decompression speed of is about 220 MB/Sec in 64-bit mode and only 160 MB/Sec in the 32-bit mode (on an Intel Q9550 CPU with DDR2-800 memory). Also, this tool does not require any DLL libraries.

File Purpose Syntax
z8.exe
Version 2.0
Compresses (-a switch) or decompresses (-e switch) files with a "z8" extension using 64-bit optimized ZLIB library. The destination file is optional: if ommitted, the destination file will be based on the source file name with a letter "z" attached to or removed from the source file extension, for compressed and decompressed files, respectively. z8 (-a|-e) InFile [OutFile]