| Current Members Log-In |  View Your Shopping Cart

Home
Data Products
Publications
Fundamentals
CRB Indexes
B2B Products

CRB Home Page
CRB DataCenter
Final Markets
More ...
CRB PriceCharts
CRB Encyclopedia of Commodity and Financial Charts
CRB Commodity Yearbook
More ...
Crop Production Calendar Maps
Weekly Precipitation Maps (NOAA)
More ...
Index Quotes and Charts
Daily Closing Values
More ...
Publications
Data Products
More ...


 
- CRB PRO Format Description

Created for CRB, the PRO format is a binary file format. As such, data in a PRO file can not be read with a standard word processor. CRB provides PowerPro for viewing and editing these files. Only edit PRO data files with such an editor.

The PRO File Structure:

Typically the ticker symbol is used as the name of the PRO file. For example, if you were charting IBM, then you would have a file called "IBM.PRO" in your C:\CRB\STOCKS data directory.

Each record in a PRO data file contains 26 bytes. The date is stored as a 2-byte signed integer. The rest of the fields are each 4-byte single precision (in Visual Basic) or type float (in Visual C) values for the Open, High, Low, and Settlement prices, and the Volume and Open Interest, respectively.

The integer date values are calculated as an offset from 12/31/1982. That is day Zero. Each successive day is simply one number greater. Count back into negative numbers for dates earlier than 12/31/1982. October 14, 1999 is day 6131. This date scheme will be valid until the middle of the year 2072.

Prices are stored in the files "as is". Typically we do not adjust prices before storing them or when reading them. If some stock had a value of 12.875 for the close, we would store 12.875 in a floating point-type variable and then write it to the file. On days where there is no trade, such as holidays or weekends, simply do not store any data. We never store records where all the fields are zero's.

The KRV (Volatility) File Structure:

If you were charting S&P 500 June 2002 Volatility, then you would have a file called "SP2002M.KRV" in your C:\CRB\PRO data directory.

Each record in a KRV data file contains 26 bytes. The date is stored as a 2-byte signed integer. The rest of the fields are each 4-byte single precision (in Visual Basic) or type float (in Visual C) values for the Implied and 20-day Historic volatility percentages. The remaining 4 (l,s,v,oi) fields are empty.

Visual C# Example

Visual Basic Example:

Here is a User Type definition (which would go in a VB module) for the PRO format:

Type PROREC Date As Integer Opn As Single Hi As Single Lo As Single Cl As Single Vol As Single Oin As Single End Type

Sample code which could read a PRO file could be something like this:

Dim Rec As PROREC
Dim FileLoc as Long
Open "C:\PRO\IBM.PRO" for Binary as #1

Get #1, 1, Rec  'Read the first record in the file
StartDate = Rec.Date

LastRec = LOF(1) - 25&  'Read the last record in the file
Get #1, LastRec, Rec
EndDate = Rec.Date

Redim AllRecs(StartDate to EndDate) As PROREC 'Set up array
to hold all the data in the file

FileLoc = 1
Counter = 0
While FileLoc < LOF(1)
 Get #1, FileLoc, Rec
 AllRecs(Rec.Date) = Rec
 Counter = Counter + 1
 FileLoc = FileLoc + 26& '26 is the size of each record. Use
 "26&" in case the file size is over 32670 bytes, avoiding
 integer overflow.
end

Close #1

That little bit of code will read an entire PRO data file. The AllRecs array will have space for every day from the earliest date in the file to the latest date. If you want to make room on either end of the array for adding new data, just make the extremes of the array's dimensions wider (ie: Redim AllRecs(StartDate -400 to EndDate + 400) As PROREC ).

Why use binary files? In PRO files, the newest data is at the tail end of the file. To find a recent date fast, just start at the end of the file and search toward the beginning of the file. In files which span 30 or forty years, this will improve performance substantially over having to start at the beginning of the file all the time. Here is an example of reading the 100th most recent date in a PRO file (it assumes the file is open as file number 1):

FileLen = LOF(1)
Day100 = FileLen - (100 * 26) + 1
Get #1, Day100, Rec

That is all it takes to grab a specific record from the file. This is made possible by the fact that each record is 26 bytes long. So, you take the length of the whole file, go back 100 days times 26 bytes per day, and add 1 to position on the first byte of that record. (That adding "1" can be confusing. Assume the file has one day in it and you want to read the last record of the file. You would take the file length, 26, minus 1 * 26, which is Zero. In VB the first byte of a file is numbered 1, not zero. So, you then need to add 1 to get to byte number 1. This is true for reading or writing any record in the binary file.)

To convert a PRO date to a common date string in VB use the following code:

DateStr$ = Format$(Rec.Date + 30316&, "mm/dd/yyyy")

If Rec.Date equaled 6131, then DateStr$ would come out of
that line equal to "10/14/1999".

To go the other way, use this code:

Rec.Date = Datevalue( "10/14/1999") - 30316&

In this case, Rec.Date would wind up with a value of 6131.

The constant (30316&) which is being applied here is the difference between day zero in a PRO file and day zero in the various VB date functions. You code it with an ampersand ("&") after it to make it a type-long value. Without the ampersand, in some situations VB will attempt to use integer math to calculate the date, which may cause an Overflow Error.


Quotes & Charts | About CRB | Contact CRB | Support Pages | Sitemap
Copyright © 1934 - 2017 by Commodity Research Bureau - CRB. All Rights Reserved.
Market data provided by ddf and subject to user agreement and privacy policy.
209 W. Jackson Blvd. • Suite 200 • Chicago, Illinois 60606-6940 • USA
Phone: 800.621.5271 or 312.554.8456 • Fax: 312.939.4135 • Email: info@crbtrader.com
Press Ctrl+D to bookmark this page - Set http://www.crbtrader.com as your Home Page