Commodity Systems Incorporated
200 W. Palmetto Park Road
Boca Raton, FL 33432
TITLE: Unfair Advantage API (API2) Functional Specification
STAGE: Released
DATE: , 1998
RELEASE:
Prepared by :_________________________________________ ____________
JOSHUA REED Programmer Date
Approved by :_________________________________________ ____________
Bob Pelletier President Date
CSI PROPRIETARY
: The information contained herein is the property of CSI and all unauthorized use and reproduction is prohibited.COPYRIGHT (c) CSI 1998. This media contains an authorized copy or copies of material copyrighted by CSI and is the confidential, unpublished property of CSI. This copyright notice and any other copyright notices included in machine readable copies must be reproduced on all authorized copies.
PURPOSE:
( X ) Review & Approve ( ) Review & Comment ( ) Info Copy ( ) File Copy
REVISION HISTORY
Rev Date Section Description By
REVISION HISTORY (Page 2)
Rev Date Section Description By
TABLE OF CONTENTS
1. Introduction * 2. Related/Reference Documentation * 3. High Level Access Description *This document is the Functional Specification for the CSI Unfair Advantage API (API2). The intent of this document is as follows:
to facilitate customers’ usage of API2 and,
to provide a means by which changes to API2 shall be controlled.
API2 is an interface between Unfair Advantage (UA) and a client software product. The interface provides a way for the client software to request commodity price data. UA responds to interface requests by checking licensing information, retrieving the data, and copying the data onto the clipboard and exposed data members.
2. Related/Reference Documentation
This document assumes a general understanding of stock and commodity trading. Section 4.3.2 on computed contracts assumes a detailed understanding of each computed contract discussed. The Unfair Advantage User Manual is one such source.
For details on the Perpetual Contract®, the reader is invited to read the Futures magazine article "Contracts that don't expire aid technical analysis" by Robert Pelletier published in March 1983 issue.
Additional details on the Back Adjusted contracts are provided on the website at http://ua.csidata.com/ua/backadj.htm.
3. High Level Access Description
3.1 Description of OLE Automation Interfacing
An OLE Automation object has certain properties, such as commodity symbol, data date, delivery month, opening price, and actions, such as retrieving contract, copying the price data to the clipboard, and looking up market information. All of the properties can be read and modified by the client application. When the client application wants UA to take some action, such as retrieving some data, the client applications accesses one of the interface's actions (functions). The following example should clarify.
The following working VBA code is an example of client code accessing the interface.
Line #
Line 1 declares an OLE Automation object. Lines 2 through 4 declare a number of temporary variables used in the example. Line 5 activates the OLE Automation object. This causes Unfair Advantage to be launched if it is not already running. Line 6 is unnecessary within Excel. Please see section 3.4 for additional information. Line 7 places the symbol SP into a local variable named symbol. Line 8 sets the API2 property "symbol" using the local variable. Unfortunately the intermediate variable symbol is required for this to work correctly in Excel. Line 9 identifies the symbol as not a stock symbol (1 for stocks, 0 for futures.)
Line 10 and 11 requests a Market look-up based on the given symbol. The intermediate local variable is needed for VB.Net only. Line 12 requests detailed Market Specifications about the market. Lines 13 and 14 generates a message box with several of the results of this lookup.
Line 15 requests a December 2007, Copper contract from the first (-1) to the last (-1) day. Line 16 requests that the data be copied to the clipboard. Lines 17 and 18 paste the results into a spreadsheet.
Line 19 specifies that you want UA to close when you are done with it, and line 20 closes the connection.
3.3 Notes for Users of UA.COM_API.
API2 is an extension of the COM_API OLE interface created by Josh Reed which is no longer available starting with version 2.0.0. COM_API is not documented here.
3.4 Time Delay Between Creation of OLE Connection to First Usage
Because there are a number of things during the initialization of UA which may require user attention, the Windows message pump is allowed to start before initialization is completed. Although I have gone to great lengths to prevent CreateObject from returning until initialization is complete, it is theoretically possible for CreateObject to return a connection before UA has fully initialized. Waiting 0.1 second between the receipt of the connection and its usage insures that UA has begun its actual initialization before data requests are made. This is not important with VBA access as there is enough latency without an explicit wait. For interpreted languages such as Perl and VBScript, sleep(1) and WScript.Sleep(100) are sufficient. For compiled languages, one may wish to use WaitForInputIdle so that you wait the very least amount of time necessary.
Because it takes some time between when you release the connection to UA and when UA has actually been removed from memory, one should not immediately CreateObject again unless HoldUAOpenOnClose is 1. Testing has demonstrated that at least 2 seconds are needed to insure that your new connection request is not caught by the previous UA. If it is caught during the close, UA should return an ErrorMessage.
Starting with version 2.0 of UA, a property ErrorMessage is accessible. This is set or cleared by each function call. Look for an empty ErrorMessage to mean that there was no error. Additionally each of the functions has some kind of error return. If ErrorMessage is not empty, please pass it on to the user so that the problem may be resolved.
4.1 Retrieving Market Information
CSI identifies a stocks and commodity by a symbol and by a number. For example, the cotton traded at NYCE is labeled with the market symbol CT and with the number 7. The number is needed since it is a unique assignment made by CSI whereas no agreement exists between the exchanges to keep the symbols as unique. Further, symbols are sometimes changed or reused in an effort to keep consistent with the exchanges.
To this end, the properties "MarketSymbol" and "MarketNumber" can be used to identify what the current market is or to specify the current market.
MarketSymbol is a string of up to 6 characters.
4.1.1.2 Prop: Market Number, IsStock
MarketNumber is an integer assigned by CSI. The value is only required to fit within a four-byte integer.
IsStock is either 0 or 1 reflecting whether the currently described market is a Stock/Mutual Fund/Index rather than a future.
4.1.1.3 Func: FindMarketNumber
FindMarketNumber searches an internal database (cdbfacts.adm) for any exact match to the symbol. If a match is found, the MarketNumber property is set to the result and the return value is the MarketNumber. If no match is found, the value –1 is set instead and the return value is non-positive.
Starting with version 2.0 of UA, the IsStock property is used to determine if you are asking for a Stock symbol lookup. UA has settings to determine whether inactive stocks are to be included in this search. There are sometimes stocks with no data and this can trip-up the API programmer.
The Factsheet property in UA is used to determine if the function is supposed to include delisted stocks in the search.
To learn more about the identified market, you need to get its Profile, which consists of the following fields:
|
Profile Field |
Field Type |
Value Assigned |
|
FirstDate |
Long Integer (yyyymmdd) |
The first day on record for the commodity. |
|
LastDate |
Long Integer (yyyymmdd) |
The most recent day on record for the commodity. |
|
FirstOptionDate |
Long Integer (yyyymmdd) |
The first day on record for the commodity’s options. |
|
LastOptionDate |
Long Integer (yyyymmdd) |
The most recent day on record for the commodity’s options. |
|
Exchange |
String |
A symbol for the exchange. |
|
MarketName |
String |
A description of the market. |
|
ConversionFactor |
Short Integer |
An integer from –8 to +6 describing how the price field is encoded. |
|
OptionConversionFactor |
Short Integer |
The conversion factor to apply to option premiums. |
|
TradingUnits |
String |
|
|
ContractSize |
String |
|
|
PointValue |
String |
The currency value of a 1 point move. (A tick need not be an even number of points.) (See WholePointValue 4.4.24) |
|
ValidMonths |
String of 12 characters |
|
|
MinTickInPoints |
Float (single precision) |
The number of points (may be fractional) to the current minimal price change. |
|
ShortMarketSymbol |
String (2 character) |
Most commodities should also have a unique two-character symbol. |
|
Currency |
String |
4.1.2.1 Func: GetMarketProfile
This interface action searches the commodity database for a matching MarketNumber. The MarketNumber is returned if any are found. Otherwise a non-positive is returned. Starting with version 2.0 of UA, the IsStock property is used to determine if you are asking to step through the equities.
The first and last date available for a given data set. When accessing a market profile, the data set is from the first contract, or cash if earlier, to the last contract, or cash if later. Although for most data, the data goes continuously from one date to the next, this is not necessarily the case for all markets. The Mexican Peso, for example, was illegal to trade for several years in the middle of its price history.
A symbol representing the exchange on which the commodity trades.
This property is a description of the market.
4.1.2.6 Prop: ConversionFactor
4.1.2.7 Prop: OptionConversionFactor
Conversion factors determine how to interpret the price information for either a market price, a strike price, or for an option premium:
|
Description |
Factor |
Example Value |
Example Decimal |
Example Printed |
|
Hundred Millionths |
+8 |
1010501 |
.01010501 |
.01010501 |
|
Ten Millionths |
+7 |
101051 |
.0101051 |
.0101051 |
|
Millionths |
+6 |
10105 |
.010105 |
.010105 |
|
Hundred Thousands |
+5 |
10105 |
.10105 |
.10105 |
|
Ten Thousands |
+4 |
10105 |
1.0105 |
1.0105 |
|
Thousands |
+3 |
10105 |
10.105 |
10.105 |
|
Hundredths |
+2 |
10105 |
101.05 |
101.05 |
|
Tenths |
+1 |
10105 |
1010.5 |
1010.5 |
|
Literal |
0 |
10105 |
10105 |
10105 |
|
Eighths |
-1 |
10105 |
1010.625 |
1010^5 1010 5/8 |
|
Sixteenths |
-2 |
10105 |
101.3125 |
101^05 101 5/16 |
|
Thirty-seconds |
-3 |
10105 |
101.15625 |
101^05 101 5/32 |
|
Sixty-fourths |
-4 |
10105 |
101.078125 |
101^05 101 5/64 |
|
128ths |
-5 |
10105 |
10.8203125 |
10^105 10 105/128 |
|
256ths |
-6 |
10105 |
10.41015625 |
10^105 10 105/256 |
|
32nds and halves |
-7 |
10105 |
10.328125 |
10^10.5 10 10/32 1/64 |
|
32nds and quarters |
-8 |
10105 |
10.328125 |
101^10.50 10 10/32 2/128 |
CSI reserves the right to add additional conversion factors without notice. Unknown conversion factors should be treated as +0. The MinTickInPoints is often needed to make meaningful use of these results see sec. 4.1.2.9.
This is a string of 12 characters. Each of those characters is either an ‘I’ for inactive, ‘V’ for active (valid), or ‘S’ for switching (currently low volume.) During retrieval, the condition is 'V' to retrieve and not 'V' to ignore. If the active months have changed historically, it is up to the users to convert 'S's to 'V's to build representative contracts. Of course 12 Vs ('VVVVVVVVVVVV') retrieves every contract ever traded.
The minimum tick in points is used in conjunction with the conversion factor to interpret the database entries. Because floor traders are always trying to split the difference, futures have developed some odd mixed-fractional numbering systems. For example, Live Cattle #2 (LC) is quoted as 23 cents, 6 tenths of cents, and ¾ of a tenth of a cent. Mathematically, this can be represented as 23.675 or 23 27/40. Since no one likes to work with fractions, especially when placing an order, the 23.675 representation is preferred. To save costs and to avoid a slippery slope, they choose to not print the final 5 just as they would not print 2.3333333333333333333333333333333 either. CSI which got much of its early history from newspapers and books followed suit. UA will either output 2367, 23.675, or 23.67500000 depending upon the circumstances and settings.
If you would rather not deal with these things, then you might want to look at ShowDecimalPoint (sec. 4.3.1.4).
A related issue is that sometimes opening prices in CSI are not valid exchange prices. For example, if the opening range of LC were 23.625 and 23.650, then CSI might list the open as 23.64 which can easily throw off your code when it tried to figure out how many quarters that is. For that reason, UA offers the "Round to Nearest Tick" option.
Provided that you don’t mind rounding to the nearest tick, then you can convert point values (2367) to decimal values (23.675) using the conversion factor and minimum tick as follows:
|
Initial Value |
Action |
Method |
Result |
|
|
2367 |
Split by cvf |
Divide by num digits |
-> |
23 67/100 |
|
23 67/100 |
Round Up |
Add .5 |
-> |
23 67.5/100 |
|
23 67.5/100 |
Apply Min Tick |
Truncating Divide |
-> |
23 27/40 |
|
23 27/40 |
Convert to decimal |
Divide |
-> |
23.675 |
These properties do not exist in UA versions 2.6.1 and higher.
4.1.2.12 Prop: FirstOptionDate
The first and last date available for the options associated with the given data set. Although for most data, the data goes continuously from one date to the next, this is not necessarily the case for all markets.
There are two actions (functions) provided for enumerating the known markets. There may be data available for unknown markets, but this should not be used.
4.1.3.1 Func: GetFirstMarketProfile
This interface action extracts the Market Profile for the first commodity (IsStock=0) or stock (IsStock=1) in the database. Returns the 1 on success, 0 at end of list, and -1 on error.
4.1.3.2 Func: GetNextMarketProfile
This interface action extracts the Market Profile for the next commodity(IsStock=1) or stock (IsStock=1) in the database. Returns the 1 on success, 0 at end of list, and -1 on error.
The following table of properties provides various current fundamental data for some stocks. IsStock must be 0, and MarketNumber provides the identification of the stock. Not every stock, much less every series in the Stock Database, has fundamental data so make sure to check the property HasStockFundamentalData first as it may save you time. Even if HasStockFundamentalData is 1, some field may be missing for a variety of reasons including the field being inapplicable by accounting standards, the field was not provided in the company filings, or our current source may not carry certain information which a previous source carried.
|
Property |
Type |
|
HasStockFundamentalData |
1 or 0 (short) |
|
NumInstitutionalShareHolders |
Long |
|
EarningsPerShare |
Double Precision Floating Point |
|
SharesOutstanding |
Double Precision Floating Point |
|
PercentageOfSharesHeldByInstitutions |
Double Precision Floating Point |
|
StockBeta |
Double Precision Floating Point |
|
RevenueGrowth5Year |
Double Precision Floating Point |
|
DividendGrowth5Year |
Double Precision Floating Point |
|
DividendYield |
Double Precision Floating Point |
|
LatestAnnualTotalNetIncome |
Double Precision Floating Point |
|
PE5YearAverage |
Double Precision Floating Point |
|
LatestAnnualOperatingRevenue |
Double Precision Floating Point |
|
IncomeGrowth5Year |
Double Precision Floating Point |
|
PriceEarningsRatio |
Double Precision Floating Point |
|
EarningsPerShare1QtrAgo |
Double Precision Floating Point |
|
EarningsPerShare2QtrAgo |
Double Precision Floating Point |
|
EarningsPerShare3QtrAgo |
Double Precision Floating Point |
|
EarningsPerShare4QtrAgo |
Double Precision Floating Point |
|
EarningsPerShareTotalLastYear |
Double Precision Floating Point |
|
EPSGrowth5Year |
Double Precision Floating Point |
4.2 Retrieving Contract Specifications
Commodity trading relies upon standardization of deliverable contracts. A ContractDeliveryCode identifies the class of deliverable contracts is identified by. For example Pork Bellies deliverable in August 1996 is designated 199608. An immediately deliverable or forward deliverable contract is labeled with a ContractDeliveryCode of 54 for compatibility with previous CSI products. In the case of Stock Options, the ContractDeliveryCode tells in which year and month the option expires.
long BuildContractList(long MarketNumber,
short inIsStock, short inIsOption)
This function takes a long integer argument for the MarketNumber, a short integer for IsStock, and a short integer for IsOption. It returns a short integer for the number of series, including cash if available, present for that stock or commodity. If IsStock is 1, then the MarketNumber is interpreted to be a stock, else 0. If IsOption is 1, then a list of options is created. If IsOption is 0, then a list of contracts is created. The order of the list is cash (if exists,) lag cash (if exists and is separate,) then most distant to oldest contract with the strike prices numerically ordered. It returns the number of contracts found.
The property NumContracts is a short integer, which reports the number of contracts in the contract list which is built by the BuildContractList function, see 4.2.1.
4.2.3 Func: GetNextContractDetails
4.2.4 Prop: ContractDeliveryCode
4.2.5 Prop: ContractStrikePrice
The function, GetNextContractDetails, can be called repeatedly following a BuildContractList function, see 4.2.1, to enumerate the contracts available for a commodity. At least the properties ContractDeliveryCode, ContractStrikePrice, ContractFirstDate, and ContractLastDate are set. The ContractFirstDate and ContractLastDate are the first and last dates of the contract respectively. The ContractDeliveryCode is a number describes a futures contract (200512 for the Decmeber 2005 contract). For data not associated with a futures delivery month, such as the cash series or an econometric series, use the delivery month 54 for cash.
4.2.7 Func: GetContractDeliveryCode
long GetContractDeliveryCode(long ContractListIndex)
4.2.7 Func: GetContractStrikePrice
long GetContractStrikePrice(long ContractListIndex)
4.2.8 Func: GetContractFirstDate
long GetContractFirstDate(long ContractListIndex)
4.2.9 Func: GetContractLastDate
long GetContractLastDate(long ContractListIndex)
These allow random access to the ContractList which is set by BuildContractList (MarketNumber), see 4.2.1. These functions simply return the same values as 4.2.4 through 4.2.6 except not requiring you to step through the list.
4.2.10 Func: InvalidateContractList ()
This function flushes the contract list and the retrieve data list. This automatically called when a download/distribution has successfully completed.
4.3.1 Retrieving Actual Price Data
Before we look into synthetic contract generation, let us look at the simpler case of actual contract retrieval. There are two functions of interest: RetrieveContract and CopyDataToClipboard.
Important Note. If you are looking for COT data, Econometric data, LME Forward data, or any other data where does not have a futures commodity month associated with it, then either RetrieveStock or RetrieveContract is the relevant method. If the series is found under the Stocks Market Specifications, then use RetrieveStock. Otherwise, use RetrieveContract with the ContractDeliveryCode of 54 for cash.
4.3.1.1.1 Func: RetrieveContract
long RetrieveContract(
long MarketNumber, long ContractDeliveryCode,
long LoadStartDate, long LoadEndDate)
This function takes two long integer arguments, MarketNumber and ContractDeliveryCode. The MarketNumber is discussed in section 4.1.1.2. The ContractDeliveryCode is discussed in section 4.2.4. Given this information, UA decompresses the corresponding database file and loads the data into memory.
The IncludeSaturdays (4.3.1.9), IncludeHolidays (4.3.1.3), DetrendMethod (4.3.1.8), FillInCashPrice(4.3.1.9) , ApplyCommodityAdjustments (4.4.11), CloseOutOfRangeAdjustmentMethod (4.4.15), RoundToTick (4.4.16), UseTradeableTick(4.4.16), OnHolidaysUsePreviousData (4.3.1.3), OnHolidaysUseCloseOnly (4.3.1.3), AggregateVolAs (4.3.1.10), AggregateOiAs (4.3.1.10), AggregateCashAs (4.3.1.10), AggregateDateAs (4.3.1.10), AggregateDayOfWeekAs (4.3.1.10) are accessed
The return value is the number of data days found.
4.3.1.1.2 StartDate, EndDate Retrieval Options
These two long integers allow the user to limit the retrieval to a date range. Use the values -1, -1 or 0,0 if you want the full history available. Can significantly improve performance, but for forward generated Nth Nearest Future and Back-Adjusted contracts can result in different contract choices.
4.3.1.2 Func: CopyDataToClipboard ()
4.3.1.3 Prop: IncludeHolidays, OnHolidaysUsePreviousData, OnHolidaysUseCloseOnly
4.3.1.4 Prop: ShowDecimalPoint
4.3.1.5 Func: GetUAStrClipFormat ()
Once you have the data loaded into memory, the CopyDataToClipboard function writes the information to the clipboard.
The function has two control properties: IncludeHolidays and ShowDecimalPoint. If IncludeHolidays is not true, than all data records reflect actual trading. If it is true, then weekdays on which there is not a record, inclusive to the date range of the result set, are recorded with a day of week value of 8 and no price information. If OnHolidaysUsePreviousData is 1, then the previous days data is copied with the Date and DayOfWeek changed. If also the OnHolidaysUseCloseOnly is 1, then the price values are set to the previous close and the volumes are set to zero. The ShowDecimalPoint property controls whether prices are listed as integers or as strings representing the number (see 4.1.2.6 for details.)
At least two formats are provided: Text and UAStraightData. To retrieve either of the results, the Clipboard Format Id is required. For Text, Microsoft provides the value CF_TEXT (1). To determine the UAStraightData Clipboard format Id, the client software can either Register the "UAStraightData" format or call the API function GetUAStrClipFormat that takes no arguments.
Both formats provide the same information, but the future expansion is a little different. The text image placed on the clipboard is in a CSV format. The first 17 fields are described here. There may be additional fields. In the binary format, additional bytes are reserved for future expansion.
Also the first record in the binary format, has a RecordDate which records the version of the file, currently +1. The version number for this clipboard format shall not reach 10000. The record length is stored in the Day of Week field. Make sure to read this value and to seek accordingly.
Unfortunately in UA 2.8.1, the Unadjusted Close field was inserted after the Close field. Make sure to check for this version number if you need your software to be compatible with that version.
|
Field Name |
Field Type |
Value Assigned |
|
RecordDate |
Long Integer (yyyymmdd) |
The trading date for the record. |
|
Day of Week |
Long Integer 1..5,8 |
The day of the week on which trading occurred. A value of 8 is used to denote holidays without trading. |
|
DeliveryCode |
Long Integer |
See section 4.1.4. |
|
Open |
Long Integer |
The average of the first bid and the first ask on the floor. |
|
High |
Long Integer |
The highest price paid. |
|
Low |
Long Integer |
The lowest price paid. |
|
Close |
Long Integer |
The settlement price. |
|
Cash |
Long Integer |
The Cash price or if not available, nearest contract close. |
|
Volume |
Long Integer |
The volume of trading for this contract |
|
Open Interest |
Long Integer |
The open interest for this contract. |
|
Total Volume |
Long Integer |
The volume of trading for the commodity. |
|
Total Open Interest |
Long Integer |
The Open Interest in this commodity. |
|
Closing Bid |
Long Integer |
The closing bid for the option. |
|
Closing Ask |
Long Integer |
The closing ask for the option. |
|
Unadjusted Close |
Long Integer |
The closing price without adjustments. |
|
Unadjusted Volume |
Long Integer |
The Volume without adjustments |
|
Unadjusted Open Interest |
Long Integer |
The Open Interest without adjustments. |
|
Expansion |
Char[12] or additional fields (depending on format) |
Reserved for future expansion. |
4.3.1.7 Func: CombineDataToClipboard, CombineDataToClipboard2
long CombineDataToClipboard(short Period)
long CombineDataToClipboard2(short Period, BSTR Separator)
CombineDataToClipboard and CombineDataToClipboard2 extend CopyDataToClipboard by allowing different data compress: daily, weekly, monthly, quarterly, or yearly bars depending on the Periodicity argument and by allowing you to specify a field separator. CombineDataToClipboard(p) assume you want a comma (‘,’) as a separator. The Periodicity following values are valid.
|
Name |
Value |
|
Daily |
0 |
|
Weekly |
1 |
|
Monthly |
2 |
|
Quarterly |
3 |
|
Yearly |
4 |
In each case, the following definitions apply
|
Open |
first day's open |
|
Close |
last day's close |
|
High |
highest high |
|
Low |
lowest low |
|
Cash |
last day's cash |
|
Volume, Total Volume |
last day's volume, total volume |
|
Open Interest, Total Open Interest |
last day's open interest, total open interest |
The return value is the number of data days found.
This function has no useful purpose when applied to a NearestFuturesContract, discussed in 4.3.2.3.
DetrendMethod
Indicates how and whether to detrend data being retrieved. Detrending a NearestFuturesContract has no useful purpose. Detending takes two prices, the first close (of the earliest date) in the series and a pivot price. The pivot price may either be the close of the last day for the second-to-the-last contract or the close of the second-to-the-last day on file. All days within the range have an amount added so that afterward the first close in the series matches the pivot price. Here are the valid values.
|
Name |
Value |
|
Detrend By Second Contract |
-1 |
|
Not Detrended |
0 |
|
Detrend by Second Day |
+1 |
Previous versions of UA only allowed detrending of cash data and computed contracts. The current version allows it, but it is of dubious value for short series.
4.3.1.9 Prop: FillInCashPrices
This Boolean property indicates whether a second pass through the database should be done to determine a "cash" price for each retrieved data day. The "cash" price may be an actual cash price, it may be lagged cash, which would only have been known the day after, or it may simply be the nearest future contract.
Since the cash series often starts at the beginning of the database and extends all the way to the end, it often more than doubles the retrieval time this option.
These short integer properties indicates what method is used to aggregate volume and total volume, aggregate open interest and total open interest, aggregate cash, date, and day of week in weekly, monthly, quarterly, and annual series. The values for Volume, Open Interst, and Cash are listed below. A total cash doesn’t make sense, so value 4 is not allowed in the AggregateCashAs parameter.
|
Name |
Value |
|
Aggregate As Largest |
0 |
|
Aggregate As Smallest |
1 |
|
Aggregate As Average |
2 |
|
Aggregate As Last |
3 |
|
Aggregate As Total |
4 |
The AggregateDateAs is 0 for the first day of the week and 1 for the last actual day of trading.
The AggregateDayOfWeekAs can be one of the following:
|
Name |
Value |
|
Sunday |
1 |
|
Monday |
2 |
|
Tuesday |
3 |
|
Wednesday |
4 |
|
Thursday Friday Saturday |
5 6 7 |
4.3.1.13 Func: CopyRetrievedDataToArray
long CopyRetrievedDataToArray(short Period,
VARIANT *DateArray, VARIANT *DowArray, VARIANT *DydmArray,
VARIANT *OpenArray, VARIANT *HighArray, VARIANT *LowArray,
VARIANT *CloseArray, VARIANT *ClosingBidArray, VARIANT *ClosingAskArray,
VARIANT *VolumeArray, VARIANT *OIArray,
VARIANT *TotalVolumeArray, VARIANT *TotalOIArray,
VARIANT *CashArray);
CopyRetrievedDataToArray does the same things as CombineDataToClipboard, except that it writes the data to variant arrays which are passed in as arguments. (A variant array is not an array of variant objects. Please see variant documentation for your language.) Please see 4.3.1.6 Clipboard Field List concerning the meaning of the arguments.
The return value is the number of data days found.
This function does not work with VBScript; because VBScript cannot pass an array by reference.
The following VBA code may help to clarify how to handle a variant array:
Set UA = CreateObject("UA.API2")
Dim datea, dowa, dydma, opena, higha, lowa, closea
Dim closingbida, closingaska, vola, oia, tvola, toia, casha
UA.ShowDecimalPoint = 0
UA.IncludeHolidays = 0
MyErrNo = UA.RetrieveStock(1006, 20050101, -1)
MyErrNo = UA.CopyRetrievedDataToArray(1, datea, dowa, dydma,
opena, higha, lowa, closea, closingbida, closingaska, vola, oia, tvola, toia, casha)
MsgBox Format(datea(0))+Format(closea(0))
This code displays a message box with the first date and the first closing price.
4.3.1.14 Func: CopyDataToResource
long CopyDataToResource(short Period, HGLOBAL *StrFormat, HGLOBAL *TxtFormat);
This function is no longer available.
4.3.1.15 Func: CopyRetrievedDataToArray2
long CopyRetrievedDataToArray2(short Period,
VARIANT* IntResultArray,
VARIANT* FltResultArray)
CopyRetrievedDataToArray does the same things as CombineDataToClipboard, except that it writes the data to variant arrays which are passed in as arguments. (A variant array is not an array of variant objects. Please see variant documentation for your language.) Please see 4.3.1.6 Clipboard Field List concerning the meaning of the arguments.
The return value is the number of data days found.
This function does not work with VBScript; because VBScript cannot pass an array by reference.
The IntResultArray and FltResultArray return the values, and the return code is the number of records retrieved. Use 0(zero) for ContractDeliveryCode if you want all of them. Use 0(zero) for the StrikePrice if IsOption is 0(zero) or if you want all of the strikes. Currently the IntResultArray is an 8 column table, and FltResultArray is also an 8 column table. Additional columns will be added without notice. The following table lists what is in those columns currently. The FillInCashPrice and DetrendMethod properties are ignored. The IncludeHolidays, IncludeSaturdays, AggregateVolAs, AggregateOiAs, AggregateCashAs properties are ignored.
|
IntResultArray |
Column Index |
|
Date |
0 |
|
ContractDeliveryCode |
1 |
|
StrikePrice (in points) |
2 |
|
Volume |
3 |
|
Open Interest |
4 |
|
Total Volume |
5 |
|
Total Open Interest |
6 |
|
Dow |
7 |
|
FltResultArray |
Column Index |
|
StrikePrice (in decimal) |
0 |
|
Open (average of high and low for options) |
1 |
|
High |
2 |
|
Low |
3 |
|
Close |
4 |
|
ClosingBid |
5 |
|
ClosingAsk |
6 |
|
Cash |
7 |
|
Additional columns will be added to either table without notice. |
The following VBA code may help to clarify how to handle a variant array:
Set UA = CreateObject("UA.API2")
MyErrNo = UA.RetrieveStock(5159, 20030728, 20030730)
MyErrNo = UA CopyRetrievedDataToArray2(0, IntArray, FltArray)
MsgBox Format(IntArray(0, 0))+Format(FltArray(3,0))
4.3.2 Retrieving Computed Contract Data
Computed contracts allow the multitude of changing, deliverable contracts to be synthesize into a time series with useful, if not exact, characteristics. A back-adjusted computed contract, for example, generally exists for every day on which any non-cash contract was traded from the first day of trading to the last, and the prices vary continuously.
4.3.2.1 Func: RetrieveNthNearestFuture
long RetrieveNthNearestFuture(
long MarketNumber,
short TargetForwardContract,
short rollLogicType,
short rollWhenVOIKnown,
short DayOfMonthToRoll,
short MonthsPriorToRoll,
String ValidMonths,
short GenerateForward,
short RollAtLeastNDaysBeforeExpiration,
long StartDate,
long EndDate);
This method retrieves an Nth Nearest Futures Contract. UA decompresses the corresponding database file and loads the data into memory.
The return value is the number of data days found.
The IncludeSaturdays (4.3.1.9), IncludeHolidays (4.3.1.3), DetrendMethod (4.3.1.8), FillInCashPrice(4.3.1.9), ApplyCommodityAdjustments (4.4.11), UseAlternateBackAdjuster (4.4.9), RaiseNegBackAdjustSeries (4.4.10), NumDaysConfirmation (4.3.2.1.6), CloseOutOfRangeAdjustmentMethod (4.4.15), RoundToTick (4.4.16), UseTradeableTick(4.4.16), OnHolidaysUsePreviousData (4.3.1.3), OnHolidaysUseCloseOnly (4.3.1.3), AggregateVolAs (4.3.1.10), AggregateOiAs (4.3.1.10), AggregateCashAs (4.3.1.10), AggregateDateAs (4.3.1.10), AggregateDayOfWeekAs (4.3.1.10) are accessed
The MarketNumber is discussed in section 4.1.1.2. The ContractDeliveryCode is discussed in section 4.2.4. The remaining arguments are discussed in the following sections.
4.3.2.1.1 TargetForwardContract argument
Refers to which future. For example, the nearest future contract is the 1st nearest future, 1. The next contract out is the 2nd nearest future, 2.
4.3.2.1.2 rollLogicType argument
Identifies the logic to be used in deciding when to ignore a near contract. The following values are valid. Other values may be supported in the future.
|
RollOnOpenInterest |
-1 |
|
RollOnVolume |
-2 |
|
RollOnOpenInterestAndVolume |
-4 |
|
RollOnOpenInterestOrVolume |
-3 |
|
RollOnDayRelativeToStartOfMonth |
-5 |
|
RollOnDayRelativeToEndOfMonth |
-6 |
These same values are available for the back-adjusted contract.
rollWhenVOIKnown/rollWhenKnown argument
Identifies how the time delay between when the day's prices are published and when the day's volume and open interest are published is handled. (There is almost always a one-day delay.) The following values are valid. Other values may be supported in the future.
As example, suppose that roll on open interest is selected and, if back adjusted, close-to-close splicing is requested with two days of confirmation.
|
Date |
March Open Interest |
July Open Interest |
|
19980526 |
20000 |
10000 |
|
19980527 |
10000 |
20000 |
|
19980528 |
10000 |
20000 |
|
19980529 |
10000 |
20000 |
|
19880530 |
10000 |
20000 |
|
Name |
Value |
Nth Nearest Rolls |
Alt Back Adjust |
Std Back Adjust |
|
RollWhen_Anticipated |
2 |
Invalid |
Invalid |
28th |
|
RollWhen_Reported |
0 |
28th |
28th |
29th |
|
RollWhen_Known |
1 |
29th |
29th |
30th |
|
RollWhen_Lagged2 |
3 |
30th |
30th |
Invalid |
For a comprehensive discussion, see the web page:
http://www.csidata.com/ua/backadj.htm.4.3.2.1.4 DayOfMonthToRoll and MonthsPriorToRoll arguments
are used when the rollLogicType is a date roll. If the DayOfMonthToRoll were 3 and the MonthsPriorToRoll where 2, then a March 1998 contract would be disallowed on January, 3, 1998 if the rollLogicType is from start of month and January 29, 1998 if from end of month. DayOfMonthToRoll values may not exceed 31.
To include all contracts in determining the nearest use, 31/0 and roll from start of month. Unfair Advantage does not currently record information after the earlier of expiration or the end of the month of delivery. December 1997 Milk, for example, traded in the first few days of January 1998, but this is not recorded by Unfair Advantage. In the event that Unfair Advantage changes to allow recording of such information, many things will have to change, including the upper limit to DayOfMonthToRoll.
The MonthsPriorToRoll parameter is allowed to have values between 0 and 15 and the value 99. Only the Standard Back Adjuster accepts 99. In the event that this value is entered, the rollLogicType and rollWhenVOIKnown values are ignored. Rolling is based on DayOfMonthToRoll days prior to expiration instead. (DayOfMonthToRoll equals 1 means roll on the last day on record of the contract.)
4.3.2.1.5 ValidMonths argument
Selects which delivery months to consider. The ValidMonths argument must be a string of 12 characters, one character for each month. Each character determines whether contracts deliverable in that month are included. A contract is included if there is a 'V' (for valid) in that position. A value of 'I' for invalid causes exclusion..
4.3.2.1.6 Prop: NumDaysConfirmation
Unless an explicit date roll is requested, this parameter selects how many consecutive volume and/or open interest roll signals are required before the algorithm rolls. For the Standard Back Adjuster which views the market backward in time from the most recent to the most distant, this argument is ignored and has an effective value of 1. For the Nth Nearest Future and the Alternate Back Adjuster, a value of at least 1 is required. Spikes in volume can cause premature rolling on volume. For this reason, a NumDaysConfirmation value of 1 to is not recommended when rolling on volume.
4.3.2.1.7 Prop: GenerateForward/
RollAtLeastNDaysBeforeExpirationThe effects of this depend greatly on the GenerateForward option. If the UseAlternateBackAdjuster is zero then GenerateFoward will have no effect.
If you are generating forward (non-zero), then the alternate back adjuster is applied. This back adjuster begins with the first day of data and steps forward backing roll decisions based on the data as it becomes available. If the RollAtLeastNDaysBeforeExpiration argument causes a roll to happen if necessary to avoid getting too close to expiration.
If you are not generating forward (zero), then the standard back adjuster is applied. If the RollAtLeastNDaysBeforeExpiration is greater than zero, then the rollLogicType is overridden so that rolls happen based only on expiration. (Like a roll relative to month end.)
4.3.2.2 Func: RetrieveBackAdjustedContract, RetrieveBackAdjustedContract2
long RetrieveBackAdjustedContract2(
long MarketNumber,
short rollLogicType,
short rollWhen,
short DayOfMonthToRoll,
short MonthsPriorToRoll,
short accumulationMethod,
short rollDeltaType,
String ValidMonths,
short GenerateForward,
short RollAtLeastNDaysBeforeExpiration,
long StartDate,
long EndDate,
short ProportionalAdjustment);
long RetrieveBackAdjustedContract(
long MarketNumber,
short rollLogicType,
short rollWhen,
short DayOfMonthToRoll,
short MonthsPriorToRoll,
short accumulationMethod,
short rollDeltaType,
String ValidMonths,
short GenerateForward,
short RollAtLeastNDaysBeforeExpiration,
long StartDate,
long EndDate);
This method retrieves a Back- or Forward- Adjusted Contract. UA decompresses the corresponding database file and loads the data into memory. For the RetrieveBackAdjustedContract function, the accumulationMethod for Proportional adjustment is used together with the GenerateForward option to determine the ProportionalAdjustment parameter.
The return value is the number of data days found.
The IncludeSaturdays (4.3.1.9), IncludeHolidays (4.3.1.3), DetrendMethod (4.3.1.8), FillInCashPrice(4.3.1.9), ApplyCommodityAdjustments (4.4.11), UseAlternateBackAdjuster (4.4.9), RaiseNegBackAdjustSeries (4.4.10), NumDaysConfirmation (4.3.2.1.6), CloseOutOfRangeAdjustmentMethod (4.4.15), RoundToTick (4.4.16), UseTradeableTick(4.4.16), OnHolidaysUsePreviousData (4.3.1.3), OnHolidaysUseCloseOnly (4.3.1.3), AggregateVolAs (4.3.1.10), AggregateOiAs (4.3.1.10), AggregateCashAs (4.3.1.10), AggregateDateAs (4.3.1.10), AggregateDayOfWeekAs (4.3.1.10) are accessed
The MarketNumber is discussed in section 4.1.1.2. rollLogicType is discussed in section 4.3.2.1.2. rollWhen is discussed in section 4.3.2.1.3. DayOfMonthToRoll and MonthsPriorToRoll are discussed in section 4.3.2.1.4. ValidMonths is discussed in section 4.3.2.1.5. The remaining arguments are discussed in the following sections. Then GenerateForward and RollAtLeastNDaysBeforeExpiration arguments are discussed in section 4.3.2.1.6. The StartDate and EndDate parameters are discussed in section 4.3.1.1.2. The ProportionalAdjustment parameter is described in
4.3.2.2.1 accumulationMethod, ProportionalAdjustment arguments
identify how the adjustments are to take cumulative effect. Valid values are:
|
Name |
Valid |
Meaning |
|
Proportional |
-1 |
(Deprecated)A multiplicative ratio factor is applied rather than an additive factor. Because of the backward viewing perspective, the standard back adjuster brings the data to the current day contract level whereas because of the forward viewing perspective, the alternate back adjuster brings the data to the earliest contract level. Prices cannot fall into negative territory in the past with this option. |
|
Back |
0 |
Adds adjustments to bring historical data to the current day contract level. This option can result in negative price readings into the past. |
|
Forward |
+1 |
Subtracts adjustments to bring historical data to the earliest contract level. Because of the effects of inflation, by using this option, prices are less likely to move negative into the future. |
If the ProportionalAdjustment parameter is non-zero, then the Backward or Forward adjustments are applied by a multiplicative ratio factor rather than an additive factor. When the standard back adjuster is applied, only Backward adjustments can be applied proportionally. This option has three advantages: prices cannot fall into negative territory in the past with this option, compounding of profits/loses is better represented, and the proportional profit/loss per trade is correct. The disadvantage is that trade profit/loss numbers are not correct.
Notice that the standard back adjuster is fundamentally backward looking while the alternate back adjuster is fundamentally forward-looking which is why the Proportional accumulation is different.
rollDeltaType argumentidentifies which contract values are used to measure the carrying charges for which the data is being adjusted.
|
Name |
Value |
Effect |
|
OpenToOpen |
-1 |
Simulates rolling by an on-the-open spread order. |
|
CloseToClose |
0 |
Simulates rolling by an on-the-close spread order. |
|
CloseToOpen |
+1 |
Simulates an exit order on the close and an enter order on the next open. |
|
CloseToOpenOldGap |
+2 |
Mathematically equivalent to OpenToOpen. |
|
CloseToOpenNewGap |
+3 |
Mathematically equivalent to CloseToClose, except that the Alternate back adjuster requires one fewer days of existence for an explicit CloseToClose. |
4.3.2.3 Func: RetrieveNearestFutures
long RetrieveNearestFutures(
long MarketNumber,
short NumOfFuturesToInclude,
short /*DayOfMonthToRoll*/,
short /*MonthsPriorToRoll*/,
boolean IncludeCash,
String ValidMonths,
long StartDate,
long EndDate);
This method retrieves all of the data for the current nearest contracts lined up by day and then by delivery code. UA decompresses the corresponding database file and loads the data into memory.
The return value is the number of data days found.
The IncludeSaturdays (4.3.1.9), IncludeHolidays (4.3.1.3), DetrendMethod (4.3.1.8), FillInCashPrice(4.3.1.9), ApplyCommodityAdjustments (4.4.11), CloseOutOfRangeAdjustmentMethod (4.4.15), RoundToTick (4.4.16), UseTradeableTick(4.4.16), OnHolidaysUsePreviousData (4.3.1.3), OnHolidaysUseCloseOnly (4.3.1.3), AggregateVolAs (4.3.1.10), AggregateOiAs (4.3.1.10), AggregateCashAs (4.3.1.10), AggregateDateAs (4.3.1.10), AggregateDayOfWeekAs (4.3.1.10) are accessed
The MarketNumber is discussed in section 4.1.1.2. DayOfMonthToRoll and MonthsPriorToRoll arguments are not used. Instead the contract are selected according to which have current day data. ValidMonths is discussed in section 4.3.2.1.5. The remaining arguments are discussed in the following sections. The StartDate and EndDate parameters are discussed in section 4.3.1.1.2.
Applying the CombineDataToClipboard has no useful purpose on this series.
4.3.2.3.1 NumOfFuturesToInclude argument
Identifies the maximal number of contracts to extract. You were requesting the data on March 13, 1998. Then if you ask for 1 contract, you might well get the March 1998 contract. If you asked for 2, you might well get the March 1998 and April 1998 contracts with the data ordered primarily by date.
4.3.2.3.2 IncludeCash argument
If true, then the cash data is considered the nearest contract and is included in the count of the number of contracts to extract.
4.3.2.4 Func: RetrievePerpetualContract
long RetrievePerpetualContract(
long MarketNumber,
short MonthsAheadToViewMarket,
short OIWeighted,
short DayOfMonthToRoll,
short MonthsPriorToRoll,
String ValidMonths,
long StartDate,
long EndDate);
This method retrieves a Perpetual Contract. UA decompresses the corresponding database file and loads the data into memory.
The return value is the number of data days found.
The IncludeSaturdays (4.3.1.9), IncludeHolidays (4.3.1.3), DetrendMethod (4.3.1.8), FillInCashPrice(4.3.1.9), ApplyCommodityAdjustments (4.4.11), CloseOutOfRangeAdjustmentMethod (4.4.15), RoundToTick (4.4.16), UseTradeableTick(4.4.16), OnHolidaysUsePreviousData (4.3.1.3), OnHolidaysUseCloseOnly (4.3.1.3), AggregateVolAs (4.3.1.10), AggregateOiAs (4.3.1.10), AggregateCashAs (4.3.1.10), AggregateDateAs (4.3.1.10), AggregateDayOfWeekAs (4.3.1.10) are accessed
The MarketNumber is discussed in section 4.1.1.2. DayOfMonthToRoll and MonthsPriorToRoll are discussed in section 4.3.2.1.4. ValidMonths is discussed in section 4.3.2.1.5. The remaining arguments are discussed in the following sections. The StartDate and EndDate parameters are discussed in section 4.3.1.1.2.
MonthsAheadToViewMarket argumentWorks together with the DayOfMonthToRoll and MonthsPriorToRoll to determine which contracts are to be combined. See Futures magazine article "Contracts that don't expire aid technical analysis" by Robert Pelletier published in the March 1983 issue for details.
OIWeighted argumentWhen the value is 1, the open-interest, rather than the number of days from rolling, is used as the weight factor. This is a short integer parameter, rather than Boolean parameter, because this may change to include other interpretations in the future.
4.3.2.5 Func: RetrieveGannContract
long RetrieveGannContract(
long MarketNumber,
short DeliveryMonthToView,
short DayOfMonthToRoll,
short MonthsPriorToRoll,
long StartDate,
long EndDate);
This method retrieves a Gann Contract. UA decompresses the corresponding database file and loads the data into memory.
The return value is the number of data days found.
The IncludeSaturdays (4.3.1.9), IncludeHolidays (4.3.1.3), DetrendMethod (4.3.1.8), FillInCashPrice(4.3.1.9) , AggregateVolAs (4.3.1.10), ApplyCommodityAdjustments (4.4.11), CloseOutOfRangeAdjustmentMethod (4.4.15), RoundToTick (4.4.16), UseTradeableTick(4.4.16), OnHolidaysUsePreviousData (4.3.1.3), OnHolidaysUseCloseOnly (4.3.1.3), AggregateVolAs (4.3.1.10), AggregateOiAs (4.3.1.10), AggregateCashAs (4.3.1.10), AggregateDateAs (4.3.1.10), AggregateDayOfWeekAs (4.3.1.10) are accessed
The MarketNumber is discussed in section 4.1.1.2. DayOfMonthToRoll and MonthsPriorToRoll are discussed in section 4.3.2.1.4. The remaining arguments are discussed in the following sections. The StartDate and EndDate parameters are discussed in section 4.3.1.1.2.
4.3.2.5.1 DeliveryMonthToView argument
is a value between 1 and 12. Individual contracts with the same delivery month are concatenated together. Notice that if a given contract did not trade for a full year, there most likely will be a gap in the Gann contract.
long RetrieveStock(
long MarketNumber,
long StartDate,
long EndDate);
This method retrieves all of the data for a stock up to the last day updated unless the StartDate and/or EndDate are greater than zero. If a date greater than zero is supplied, then it is used instead of the beginning and end of the database respectively. UA decompresses the corresponding database file and loads the data into memory. The FillInCash property is ignored.
The return value is the number of data days found.
The IncludeSaturdays (4.3.1.9), IncludeHolidays (4.3.1.3), DetrendMethod (4.3.1.8), ApplyStockSplitAdjustments (4.4.12), ApplyStockDividendAdjustments (4.4.13), PropStockAdjustments (4.4.14), PropStockVolumeAdjustments (4.4.23), CloseOutOfRangeAdjustmentMethod (4.4.15), RoundToTick (4.4.16), UseTradeableTick(4.4.16), CoverMutualFundHigh (4.4.17), OnHolidaysUsePreviousData (4.3.1.3), OnHolidaysUseCloseOnly (4.3.1.3), AggregateVolAs (4.3.1.10), AggregateOiAs (4.3.1.10), AggregateCashAs (4.3.1.10), AggregateDateAs (4.3.1.10), AggregateDayOfWeekAs (4.3.1.10) are accessed
The MarketNumber is discussed in section 4.1.1.2. The StartDate and EndDate parameters are discussed in section 4.3.1.1.2.
4.3.4 Func: RetrieveOptionSeries
long RetrieveOptionSeries(
long MarketNumber,
short IsStock,
long ContractDeliveryCode,
long StrikePrice,
long StartDate,
long EndDate);
This method retrieves all of the option premium data for a commodity or stock up to the last day updated. UA decompresses the corresponding database file and loads the data into memory.
The return value is the number of data days found.
The FillInCash (4.3.1.9) property is ignored.
The IncludeSaturdays (4.3.1.9), IncludeHolidays (4.3.1.3), DetrendMethod (4.3.1.8), ApplyCommodityAdjustments (4.4.11), ApplyStockSplitAdjustments (4.4.12), ApplyStockDividendAdjustments (4.4.13), PropStockAdjustments (4.4.14), PropStockVolumeAdjustments (4.4.23), CloseOutOfRangeAdjustmentMethod (4.4.15), RoundToTick (4.4.16), UseTradeableTick(4.4.16), OnHolidaysUsePreviousData (4.3.1.3), OnHolidaysUseCloseOnly (4.3.1.3), AggregateVolAs (4.3.1.10), AggregateOiAs (4.3.1.10), AggregateCashAs (4.3.1.10), AggregateDateAs (4.3.1.10), AggregateDayOfWeekAs (4.3.1.10) are accessed
The MarketNumber is discussed in section 4.1.1.2. IsStock is 1 for a stock series and 0 for a commodity series as in section 4.1.1.2. The ContractDeliveryCode is discussed in section 4.2.4. The strike price is negative for puts. The StartDate and EndDate parameters are discussed in section 4.3.1.1.2.
StrikePrice argumentOnly non-zero values have a defined value. Positive values refer to Call options and Negative values refer to Put options. A call option results in a long position when exercised.
4.3.5 Func: RetrievePutCallRatio
long RetrievePutCallRatio(
long MarketNumber,
short IsStock,
long StartDate,
long EndDate);
The method, RetrievePutCallRatio, retrieve the total call volume, total call open Interest, total put volume, and total put open interest. The values are then stored as
|
Open |
Total Put Volume |
|
High |
Total Call Volume |
|
Low |
Total Put Open Interest |
|
Close |
Total Call Open Interest |
The return value is the number of data days found.
The CloseOutOfRangeAdjustmentMethod (4.4.15), RoundToTick (4.4.16), UseTradeableTick(4.4.16), FillInCash (4.3.1.9) properties are ignored.
The IncludeSaturdays (4.3.1.9), IncludeHolidays (4.3.1.3), DetrendMethod (4.3.1.8), ApplyCommodityAdjustments (4.4.11), ApplyStockSplitAdjustments (4.4.12), ApplyStockDividendAdjustments (4.4.13), PropStockAdjustments (4.4.14), PropStockVolumeAdjustments (4.4.23), OnHolidaysUsePreviousData (4.3.1.3), OnHolidaysUseCloseOnly (4.3.1.3), AggregateVolAs (4.3.1.10), AggregateOiAs (4.3.1.10), AggregateCashAs (4.3.1.10), AggregateDateAs (4.3.1.10), AggregateDayOfWeekAs (4.3.1.10) are accessed
The MarketNumber is discussed in section 4.1.1.2. IsStock is discussed in section 4.1.1.2. The StartDate and EndDate parameters are discussed in section 4.3.1.1.2.
long RetrieveSnapShot(
long MarketNumber,
short IsStock,
short IsOption,
long ContractDeliveryCode,
long StrikePrice,
long StartDate,
long EndDate,
VARIANT* IntResultArray,
VARIANT* FltResultArray);
This method retrieves adjusted database data collated by date, contract, and strike. The IntResultArray and FltResultArray return the values, and the return code is the number of records retrieved. Use 0(zero) for ContractDeliveryCode if you want all of them. (54 and 61 also return all.) Use 0(zero) for the StrikePrice if IsOption is 0(zero) or if you want all of the strikes. Currently the IntResultArray is a 7 column table, and FltResultArray is also a 7 column table. Additional columns will be added without notice. The following table lists what is in those columns currently.
The return value is the number of data days found.
The IncludeSaturdays (4.3.1.9), IncludeHolidays (4.3.1.3), DetrendMethod (4.3.1.8), ApplyCommodityAdjustments (4.4.11), ApplyStockSplitAdjustments (4.4.12), ApplyStockDividendAdjustments (4.4.13), PropStockAdjustments (4.4.14), PropStockVolumeAdjustments (4.4.23), CloseOutOfRangeAdjustmentMethod (4.4.15), RoundToTick (4.4.16), UseTradeableTick(4.4.16), OnHolidaysUsePreviousData (4.3.1.3), OnHolidaysUseCloseOnly (4.3.1.3), AggregateVolAs (4.3.1.10), AggregateOiAs (4.3.1.10), AggregateCashAs (4.3.1.10), AggregateDateAs (4.3.1.10), AggregateDayOfWeekAs (4.3.1.10), FillInCash (4.3.1.9) are accessed
If you are requesting a stock, but not the option on the stock, than this function returns all of the stocks in that group of 50. To find the one you want, search by ContractDeliveryCode.
|
IntResultArray |
Column Index |
|
Date |
0 |
|
ContractDeliveryCode/Stock MarketNumber |
1 |
|
StrikePrice (in points) |
2 |
|
Volume |
3 |
|
Open Interest |
4 |
|
Total Volume |
5 |
|
Total Open Interest |
6 |
|
FltResultArray |
Column Index |
|
StrikePrice (in decimal) |
0 |
|
Open (average of high and low for options) |
1 |
|
High |
2 |
|
Low |
3 |
|
Close |
4 |
|
ClosingBid |
5 |
|
ClosingAsk |
6 |
|
Additional columns will be added without notice. |
4.3.7 Func: RetrieveAdjAndUnadjStock
long RetrieveAdjAndUnadjStock(
long MarketNumber,
long StartDate, long EndDate,
VARIANT* IntResultArray,
VARIANT* FltResultArray)
RetrieveAdjAndUnadjStock combines calling RetrieveStock twice, once with default adjustment setting and a second time with adjustments turned off, and also a CopyRetrievedDataToArray
The IntResultArray and FltResultArray return the values, and the return code is the number of records retrieved. Use 0(zero) for ContractDeliveryCode if you want all of them. Use 0(zero) for the StrikePrice if IsOption is 0(zero) or if you want all of the strikes. Currently the IntResultArray is an 8 column table, and FltResultArray is also an 8 column table. Additional columns will be added without notice. The following table lists what is in those columns currently.
The return value is the number of data days found.
The IncludeSaturdays (4.3.1.9), IncludeHolidays (4.3.1.3), DetrendMethod (4.3.1.8), ApplyStockSplitAdjustments (4.4.12), ApplyStockDividendAdjustments (4.4.13), PropStockAdjustments (4.4.14), PropStockVolumeAdjustments (4.4.23), CloseOutOfRangeAdjustmentMethod (4.4.15), RoundToTick (4.4.16), UseTradeableTick(4.4.16), CoverMutualFundHigh (4.4.17), OnHolidaysUsePreviousData (4.3.1.3), OnHolidaysUseCloseOnly (4.3.1.3), AggregateVolAs (4.3.1.10), AggregateOiAs (4.3.1.10), AggregateCashAs (4.3.1.10), AggregateDateAs (4.3.1.10), AggregateDayOfWeekAs (4.3.1.10) are accessed
|
IntResultArray |
Column Index |
|
Date |
0 |
|
Adjusted Volume |
1 |
|
UnAdjusted Volume |
2 |
|
FltResultArray |
Column Index |
|
Adjusted Open |
0 |
|
Adjusted High |
1 |
|
Adjusted Low |
2 |
|
Adjusted Close |
3 |
|
Unadjusted Close |
4 |
|
Additional columns will be added to either table without notice. |
The following VBA code may help to clarify how to handle a variant array:
Set UA = CreateObject("UA.API2")
MyErrNo = UA. RetrieveAdjAndUnadjStock (5159, 20030728, 20030730, IntArray, FltArray)
MsgBox Format(IntArray(0, 0))+Format(FltArray(3,0))
4.3.8 Func: RetrieveMysteryIndex
long RetrieveMysteryIndex(
long MarketNumber,
short IsStock,
long StartDate,
long EndDate);
The method, RetrieveMysteryIndex, was removed in version 2.9.2.
4.3.9 Func: RetrieveCashSeries, RetrieveNumericalSeries
long RetrieveCashSeries(
long MarketNumber,
long StartDate,
long EndDate);
long RetrieveNumericalSeries(
long MarketNumber,
long StartDate,
long EndDate);
Exactly the same as RetrieveContract(MarketNumber, 54, StartDate, EndDate).
Both method retrieves the cash contract for the future specified, or the series if there are no futures for that market.
4.3.10 Function: RetrieveDividendsSplitsAndCapitalGains
void GetDividendsSplitsAndCapitalGains(
/* in */
long MarketNumber, short IsStock,
long LoadStartDate, long LoadEndDate,
/* out */
long *NumDividends, long *NumCapitalGains, long *NumSplits,
VARIANT *DivDataList, VARIANT *DividendList,
VARIANT *CapDateList, VARIANT *CapitalGainsList,
VARIANT *SplitDateList, VARIANT *SplitToList, VARIANT *SplitFromList);
This function provides direct access to the Capital Gains, Dividends, and Splits for the stock/mutual fund referenced by MarketNumber. IsStock should be 1. LoadStartDate and LoadEndDate should be -1 to get all of the data available.
This information is an add-on to the standard stock and mutual fund package at the time of this writing. If you are not entitled to receive this information, then the corresponding list will be blank and corresponding count (NumDividends, NumCapitalGains, NumSplits) will be -1. Also check the ErrorMessage property for other possible problems.
The dividends are returned in the DividendList array along with their corresponding dates in the DivDateList array. Likewise, the capital gains and splits are returned with one data field per array. The following example demonstrates how to retrieve this information in VBA.
Set UA = CreateObject("UA.Api2")
Dim DivDateList, DividendList, CapDateList, CapitalGainsList
Dim SplitDateList, SplitToList, SplitFromList
Dim NumDividends As Long, NumCapitalGains As Long, NumSplits As Long
MyErrNo = UA.RetrieveDividendsSplitsAndCapitalGains(3451, 1, -1, -1, NumDividends, NumCapitalGains, NumSplits, DivDateList, DividendList, CapDateList, CapitalGainsList, SplitDateList, SplitToList, SplitFromList)
Range("a1") = "DivDate"
Range("b1") = "Dividend"
If NumDividends < 0 Then
MsgBox ("Need to purchase Dividends")
Else
For I = LBound(DivDateList, 1) To UBound(DivDateList, 1)
Range("a" & (I - LBound(DivDateList, 1) + 2)) = DivDateList(I)
Range("b" & (I - LBound(DividendList, 1) + 2)) = DividendList(I)
Next I
End If
Range("c1") = "CapDate"
Range("d1") = "CapitalGains"
If NumCapitalGains < 0 Then
MsgBox ("Need to purchase Capital Gains")
Else
For I = LBound(CapDateList, 1) To UBound(CapDateList, 1)
Range("c" & (I - LBound(CapDateList, 1) + 2)) = CapDateList(I)
Range("d" & (I - LBound(CapitalGainsList, 1) + 2)) = CapitalGainsList(I)
Next I
End If
Range("e1") = "SplitDate"
Range("f1") = "SplitTo"
Range("g1") = "SplitFrom"
If NumSplits < 0 Then
MsgBox ("Need to purchase Splits")
Else
For I = LBound(SplitDateList, 1) To UBound(SplitDateList, 1)
Range("e" & (I - LBound(SplitDateList, 1) + 2)) = SplitDateList(I)
Range("f" & (I - LBound(SplitToList, 1) + 2)) = SplitToList(I)
Range("g" & (I - LBound(SplitFromList, 1) + 2)) = SplitFromList(I)
Next I
End If
4.4.1 Func: UpdateDatabase, UpdateDatabaseFromCompletedDownload, UpdateDatabase2
void UpdateDatabase(void)
void UpdateDatabaseFromCompletedDownload(void)
void UpdateDatabase2(long WaitForTransmissionId, long CollectGroupIndex)
UpdateDatabase is only available in UA 2.1 or later, and UpdateDatabaseFromCompletedDownload is only available in UA 2.8.3 and higher. Both function takes no arguments and returns no value. UpdateDatabase checks for conflicting simultaneous tasks, finding none, it initiates download and updating of the database and portfolio. Provided browser access is not requested, the function returns when done. UpdateDatabaseFromCompletedDownload assumes that a download has already been completed, and proceeds to distribute it. In the event of error/s, check the ErrorMessage property.
UpdateDatabase2 is only available in UA 2.10.1 or later. It does the same thing as UpdateDatabase, but allows you to specify the WaitForTransmissionId and CollectionGroupIndex. Use 0 and -1, respectively, if you don’t know what value you want.
4.4.1.1 Arg: WaitForTransmissionId
CSI collects data all day long. When all of the data is collected, coordinated, and tested for a predefined set of markets (for example the Asian markets), then CSI releases a transmission containing these markets and any previously released data. UA customers are only charged once per day so that they may collect each transmission as it becomes available without penalty. Each predefined set is identified with an integer starting with zero. The predefined sets are described at
http://www.csidata.com/data/posting/Transmittals.txt. For example, Transmittal 1 contains the Pacific Rim markets and Transmittal 2 adds the European markets. These descriptions are vague. For more precise information see the page http://www.csidata.com/cgi-bin/UaPostingStatusPage.pl.The list of transmittals doesn’t change very often, but when it does change, it changes quite a bit, and often several days in a row as exceptions are resolved. If you are going to hard-code a TransmissionId, then you should download the file
http://www.csidata.com/data/posting/Transmittals.txt each time and compare the results with the previous download. Often the changes are cosmetic, but that is the only wait to know if your TransmissionId is still valid.4.4.1.2 Arg: CollectionGroupIndex
UA can distribute a selected group of exchanges rather than all exchanges. These Collection Groups can only be defined in the user interface, and their index is only valid until the list is modified in the user interface. To view this list, open UA, click on the menus Database -> Update Database. The list at the top contains your Collection Groups. The "All Dataseries and Markets" item has CollectionGroupIndex -1. The next item, if it exists, has CollectionGroupIndex 0. If you want to verify that nothing has changed, they are defined in the unfair.ini file in the section DistributionFilters with keys formed by "List:" followed by the CollectionGroupIndex plus 1. So for example, "List:1=ALBRTA,AEX,ADEX" refers to CollectionGroupIndex 0.
This property should not be used as it has been replaced with the function UpdateDatabase.
This property returns a 2-byte integer. None-zero after and during a download. Set to 0 after you have completed your processing to detect next download.
4.4.3 Func: ConvertPointsToDecimal
void ConvertPointsToDecimal(
short cvf, float MinTick, long pnts, double *dec)
This function only available in UA 2.1.4 or later. This function takes the ConversionFactor (cvf) and Minimum Tick (MinTick) from the market along with a price in points. It returns the price in decimal.
For efficiency sake, it is better to implement your own.
long PriConv_PntsPerUnit[15]= {128,64,256,128,64,32,16,8,1,10,100,1000,10000,100000L,1000000L };
float TicksPerUnit = (float)(PriConv_PntsPerUnit[cvf+8]/MinTick);
BOOL sign = (pnts<0);
long ticks = (sign?-1:1)*(long)(cPTD(cvf,(sign?-pnts:pnts))*TicksPerUnit+0.5);
*dec = (double)ticks /(TicksPerUnit);
cPTD follows the Conversion Factor definitions.
4.4.4 Func: ConvertDecimalToPoints
void ConvertDecimalToPoints(
short cvf, double dec, long *pnts)
This function only available in UA 2.1.4 or later. This function takes the ConversionFactor (cvf) and a price in decimal form. It returns the price in points.
For efficiency sake, it is better to implement your own.
This property controls the window state (normal, minimized, maximzed) of UA. It does not control the window state of the Market Scanner, Multi-Market Analyzer, Trade System Performance Evaluator, or any other UA software. Set to value 0 for normal mode, to 1 for minimized mode, and 2 for maximized mode. Minimizing UA can be especially helpful when you are keeping a UA connection open for a while.
This property controls whether UA closes when you end your sessions. By default it does. Set to value 0 to close UA when you close your connection. Set to 1 to keep UA open once the OLE connection is closed.
This string property is the version number for the UA installed. For example, "2.4.4".
4.4.8 Func: AddStockScanResultToPortfolio
void AddStockScanResultToPortfolio(BSTR list, long StartDate)
This is a special purpose function which allows you to import into UA a scan result list. This function only available in UA 2.4.5 or later. This function creates a set of invisible charts based on its arguments and opens the SaveToPortfolio dialog. The user can then specify which directory (possibly creating a new directory) to save them to, what export format, and such things.
StartDate is as described in 4.3.1.1.2.
List is a linefeed seperated list of comma seperated list of symbol (or for better performance csinum) and IsStock (0 for future, 1 for stock). For example if the list were the single string
QQQ,1
S,0
DELL,1
Then UA would try to insert the stock QQQ, future S, and stock DELL into the portfolio.
4.4.9 Prop: UseAlternateBackAdjuster
This property controls whether UA uses the standard or alternate back adjusters. The default is the non-portfolio chart option value in UA. It can be overridden by setting this property for the session. If the value is 1, then the Alternate Back Adjuster is used for all series. (Warning, many customers are not pleased with the results of rolling by volume.) If the value is 0, then the standard back adjuster is used when possible..
4.4.10 Prop: RaiseNegBackAdjustSeries
This property controls whether UA automatically adds the smallest number of thousands of points to bring the back adjuster series into the non-negative domain.
4.4.11 Prop: ApplyCommodityAdjustments
This property controls whether UA applies commodity adjustments.
4.4.12 Prop: ApplyStockSplitAdjustments
This property controls whether UA applies stock split adjustments.
4.4.13 Prop: ApplyStockDividendAdjustments
This property controls whether UA applies dividend and capital gains adjustments.
4.4.14 Prop: PropStockAdjustments
This property controls whether UA applies dividends and capital gains proportionally or additively. (Reinvest or disburse.) See also PropStockVolumeAdjustments.
4.4.15 Prop: CloseOutOfRangeAdjustmentMethod
This property controls whether UA should adjust the close, high, or low to make them consistent.
typedef enum {
LeaveAlone_CloseOutOfRangeAdjustmentMethod=0,
CompromiseHighLow_CloseOutOfRangeAdjustmentMethod=1,
CompromiseClose_CloseOutOfRangeAdjustmentMethod=2,
} CloseOutOfRangeAdjustmentMethodType;
4.4.16 Prop: RoundToTick, UseTradeableTick
This property controls whether UA rounds values to the nearest tick. If so, then UseTradeableTick determines whether the settlement price should be rounded as per the exchange or the same way as the other prices.
The property currently has no affect on my market, but we can make up an example, suppose an E-mini contracts where the settlement is from the full-sized contract which has a different minimal trade increment. Please consider the following example from a back-adjusted series:
|
Open |
High |
Low |
Close |
|
|
Unrounded Data |
1202.25 |
1208.25 |
1200.00 |
1205.25 |
|
Rounded without Tradeable Tick |
1202.30 |
1208.30 |
1200.00 |
1205.25 |
|
Rounded with Tradeable Tick |
1202.30 |
1208.30 |
1200.00 |
1205.30 |
If the Tradeable Tick is set, then the numbers are rounded to the nearest tradeable tick (.1), otherwise the close is rounded to .05 while the open, high, and low are round to .1.
4.4.17 Prop: CoverMutualFundHigh
This property controls whether UA automatically copies the close value of a mutual fund to the high value. This hides fund loading information.
4.4.18 Prop: RoundUpDateToEndOfPeriod
This property controls whether UA aggregates the date field to be the last existing date in the period, or the last logical date in the period.
4.4.19 Prop: OnHolidaysUserPerviousData
This property controls how UA fills holidays.
4.4.20 Prop: OnHolidaysUseCloseOnly
This property controls how UA fills holidays.
4.4.21 Method: GetPortfolioContents
void GetPortfolioContents(long PortfolioIndex, BSTR* Value)
This method returns the contents of the customer’s UA portfolio when the PortfolioIndex is set to –1. The results are not defined for any other value. The format of the return is in CSV format. The first line describes the column contents. The table below describes some of column headers. Other column headings should be ignored.
|
PortfolioIndex |
Which portfolio the items is contained in. (starting from zero.) |
|
PortfolioName |
The name given the portfolio. |
|
PortfolioPath |
The root directory for the Portfolio. The Portfolio may cascade into other directories. |
|
Csinum |
The Market Number for the item. |
|
IsStock |
0 if not a stock, 1 if a stock |
|
IsOption |
0 if not an option, 1 if an option |
|
ComputationMethod |
NONCOMPUTED_CONTRACT = -3, NEAREST_CONTRACTS = -1, PERPETUAL_CONTRACT = 0, NEARESTFUTURE_CONTRACT = 1, BACKADJUSTED_CONTRACT = 2, GANN_CONTRACT = 3, PUTCALLRATIO_CONTRACT = 5, |
|
Dydm |
The delivery month if applicable. (Blank unless ComputationMethod == NONCOMPUTED_CONTRACT.) |
|
Strike |
The strike if applicable (negative is put, positive is call.) (Blank unless ComputationMethod == NONCOMPUTED_CONTRACT.) |
|
LastRollDate |
The last time the computed contract or Individual Futures Group rolled. -1 if not known or not applicable. |
|
CurrIFGContract |
The most current Individual Futures Group contract. -1 if not known. Blank if not applicable. |
4.4.22 Func: RemoveStockScanResultFromPortfolio
void RemoveStockScanResultFromPortfolio(
long PortfolioIndex, BSTR Series, short Confirm)
This is a special purpose function allows you to remove items from your portfolio. See 4.4.8 for introduction method.
The portfolio is speicifed by the PortfolioIndex. -1 is used when you want to delete the series from all series. Other values can be obtained by using the GetPortfolioContents function in 4.4.21.
The Series list follows the same format as in 4.4.8.
Confirm should be one if you want a dialog prompting for confirmation on the deletion. Pass through a zero if you do not want this dialog.
4.4.23 Property: PropStockVolumeAdjustments
This setting refers to whether the volume should be adjusted for dividends and capital gains.
double WholePointValue(long MarketNumber, short IsStock, short IsOption)
This function retrieves the numerical profit of a full point move. IsStock should be 1 or 0 depending on whether the market is in the stock database, respectively. IsOption should be 1 or 0 depending on whether you wish a full point move of the option or of the underlying, respectively.
This function returns a number in the base currency which would reflect the profit made by a full-point move in the market for a 1 contract position. This is an easy multiplier to convert between the difference in entry and exit prices and dollar profit/loss. Of course, you made need to do some currency conversions to get an estimated total profit/loss on the aggregate account.
Some people prefer to access the Contract Size and Point Value fields directly so lets see how they are related using Corn as an example. The contract size is 5000 bu and the units are cents/bu so a full-point move would be 5000 bu/cntrt * 1 cent/bu = 5000 cents = 50.00 USD/cntrt. To get this number for the Point Value is a bit more difficult. Many data providers list the Tick Value as 12.50 because corn trades in quarters so 1 tick = 1/4 cent has a value of 5000 bu/cntrt * 1/4 cent/bu = 5000/4/100 USD/cntrt = 12.50 USD/cntrt. CSI computes the Point Value a bit differently. Since Corn is quoted in 1/8 s, the Point Value is 5000 bu/cntrt * 1/8 cent/bu = 6.25 USD/cntrt. It is usually easiest to use the Whole Point Value 50 USD/cntrt, but they are all equivalent.
4.4.25 Func: LaunchStockScanChart
void LaunchStockScanChart(long MarketNumber, short IsStock, long StartDate)
This function opens a chart in UA for the specified Market (see 4.1.1.2) and StartDate (see 4.3.1.1.2). If IsStock is zero, then the cash contract is displayed. This function has since been replaced by the 4.5.4 Chart Commands.
AddCsinumToRefreshHistoryList
void AddCsinumToRefreshHistoryList(
long MarketNumber, short IsStock, short IsOption)
This function adds a database and/or split file to the list of items which are believed to be corrupt and needing to be replaced.
SetDownloadDate
void SetDownloadDate(int CollectionGroupIndex, long Date, short Overwrite)
This function exists for internal operations purposes only. It allows the download date of the UA to be modified.
RemoveUserEdit2
void RemoveUserEdit2(BSTR Cmd)
This function exists for internal purposes only. The Command is a comma separated list consisting of the csinum, IsStock, IsOption, date, delivery month, strike price. It is used internally to delete user edits system-wide.
This property is an integer of whose digits are YYYYMMDD. This is the date of the last full distribution. Setting this date back will also set back the date of all collection groups.
4.5.1 Func: PerformXmlCommands
BSTR PerformXmlCommands(BSTR Commands)
This function performs the actions encoded in the Commands argument on the UA portfolio with results returned in the Results variable. For example,
<?xml version="1.0" encoding="ISO-8859-1"?>
<ActionList SaveDocumentEditsToEnd="False">
<Action Command="AddPortfolio" Id="132">
<Name>TestXml2</Name>
<Directory>c:\\ua\\files\\testxml2\\</Directory>
</Action>
<Action Command="AddDocument" Id="811">
<Symbol>DDR</Symbol>
<IsStock>True</IsStock>
<PortfolioName>TestXml</PortfolioName>
<FileFormat>CSI</FileFormat>
<FilePeriod>Daily</FilePeriod >
</Action>
<Action Command="AddPortfolio" Id="583">
<Name>TestOther</Name>
<Directory>c:\\ua\\files\\testother\\</Directory>
</Action>
</Action>
<Action Command="AddDocument" Id="3">
<Symbol>INTC</Symbol>
<IsStock>True</IsStock>
<Periodicity>Daily</Periodicity>
</Action>
</ActionList>
could return
<?xml version="1.0" encoding="ISO-8859-1"?>
<ResultList>
<Result Id="132">
<Success/>
</Result>
<Result Id="583">
<Success/>
</Result>
<Result Id="811">
<Error>Unrecognized Symbol</Error>
</Result>
<Result Id="3">
<Error>Too Many Charts Open</Error>
<Error>Maximum Chart Limit: 12</Error>
</Result>
</ResultList>
The root node for the Command is ActionList which can contain several Action nodes. The action nodes either command actions on Portfolios (Directories), on Documents (Files), or on Charts. The actions Document actions can either be completed in order or the Document actions can be completed as one transaction after all of the Portfolio actions. By completing all of the Document transactions at once, the actions process more quickly and can avoid certain conflicts, but multiple actions on the same document are not guaranteed to produce the same result as if performed one at a time.
The root node for the Results is ResultList which can contain several Result nodes. There should be a Result node for every Action node in the input. The Result node references the Id provided in the Action node. One should not assume that the Result nodes will be in the same order as the Action nodes.
The Command attribute for a Portfolio Action nodes include AddPortfolio, ModifyPortfolio, or DeletePortfolio. AddPortfolio creates a new Portfolio with the options provided. If the Name or Directory conflict with an existing Portfolio an exception is thrown. ModifyPortfolio will look for a matching Portfolio by Name or Directory. If none is found, it will attempt to create a new one. For this to work, the Name field must be provided. The properties provided or omitted automatically overwrite the existing Portfolio. DeletePortfolio searches by Name or Directory. If found, it deletes all of the Documents and the Portfolio.
The attribute nodes for a Portfolio node:
|
Attribute Name |
Meaning/Values |
|
Name |
Identifying Name visible to Users |
|
Directory |
Base directory used to store Documents. Perferably starting with "c:\ua\files" if "c:\ua\" is where UA is installed. |
|
DeleteExpringIFG or DeleteExpiringNFG |
"True" if Nearest Futures Groups/Individual Futures Groups are supposed to delete the old contract when they roll. |
|
FillInCashPrice |
"True" if the Documents should have the Cash field computed. This slows processing, and is often unneeded. |
|
SkipTotalVolumeAndTotalOpenInterest |
"True" if the Total Volume and Open Interest are not needed. Speeds processing. |
|
IncludeSaturdays |
"True" if Saturday data is desired. Most software cannot handle Saturday data. |
|
RaiseNegBackAdjustSeries |
"True" to avoid negative series. Proportionally adjusting is usually a better choice. |
|
UseAlterBackAdjust |
"True" to have all Back Adjust and Nth Nearest Futures result handled by the alternate back adjuster. See http://www.csidata.com/ua/backadj.htm for more information |
|
AggregateVolAs, AggregateOiAs, and AggregateCashAs |
When making weekly, monthly, quarterly, or annual Documents, how are these fields to be treated: AggregateAsLargest, AggregateAsSmallest, AggregateAsAverage, AggregateAsLast, AggregateAsTotal, |
|
ApplyCommodityAdjustments |
"True" to have adjustments made for unit of contract specification changes. |
|
ApplyStockSplitAdjustments |
"True" to have stocks price and volume data adjusted for stock splits |
|
ApplyStockDividendAdjustments |
"True" to have stocks price data adjusted for stock dividends and capital gains |
|
PropStockAdjustments |
"True" to have stock price dividends and capital gains adjusted proportionally rather than additively. Slows processing. |
|
PropStockVolumeAdjustments |
"True" to have volume also adjusted proportionally for dividends and capital gains. Must have PropStockAdjustments True for this to have an affect. |
|
Use2CharSymbol |
"True" to use the alternate character set for futures whose symbol is more than 2 characters. This feature has become about useless as almost all futures have had to be remapped to obscure 2 character symbols. |
|
Decimalize |
"True" to see charts and output prices as decimal equivalents rather than in the traded units. |
|
CloseOutOfRangeAdjustmentMethod |
When a series settles outside of the daily range some software required the data to be "adjusted". The following are allowed: "LeaveAlone", "CompromiseHighLow", "CompromiseClose", |
|
ForceToTick |
"True" to rounds prices to the nearest tradable unit. Adjusted data often doesn’t correspond to current contract specifications, and some software cannot handle that. |
|
CoverMutualFundHigh |
"True" to have the high price (NAV+Load) replaced with the close price (NAV) |
|
AggregateDateAsLastRecord |
"True" if weekly, monthly, quarterly, and annual Documents should end on the date of the last data available. For a weekly file generated after the close on Tuesday, the records would be Friday, Friday, …, Friday, Tuesday. If not "True", all records are on the same day of the week. Necessary for some software. |
|
AggregateDayOfWeekAs |
If "AggregateDateAsLastRecord"is not "True", then what day of the week should the aggregate data be assigned to: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" Some software require Friday, some Monday. |
|
AsciiFilesHaveHeaderLine |
"True" to have the first record of each Ascii Document contain the names of the columns. Very helpful to make your software robust. |
|
FileOutputIncludeHolidays |
"True" to have data record on Holidays. |
|
FileOutputUsePreviousData |
"True" to have the data record on the Holiday filled with the previous records information. Requires "FileOutputIncludeHolidays"="True". "FileOutputTreatHolidayByCloseOnly" takes precedence over "FileOutputUsePreviousData". |
|
FileOutputTreatHolidayByCloseOnly |
"True" to have the data record on the Holiday filled with the previous records settlement prices only. Requires "FileOutputIncludeHolidays"= "True". "FileOutputTreatHolidayByCloseOnly" takes precedence over "FileOutputUsePreviousData". |
|
UseCsinumInsteadOfSymbolForStocks |
"True" to have the Symbol replaced with the MarketNumber in Ascii and Excel Documents. |
|
CsvFormColumns |
"True" to have Ascii files padded with spaces to form columns. Not a good idea for robustness of your program. |
|
AsciiColumnMask |
Specifies which columns to include in Ascii and Excell output. See Portfolio -> Edit Portfolio for options. |
|
AsciiFileName |
Specifies what information is used to generate file names for Ascii and Excel output. See Portfolio -> Edit Portfolio for options. |
|
VendorAssociation |
Specifies what Charting Software the portfolio is associated with: "None", "odatcts", "odatifg", "odatstk", "vantpnt5", "vantpnt6", "natorder", "omnifut", "omnistk", "odatfut", "smm", |
|
CSIMFormatCascadeMethod and CSIFormatCascadeMethod |
Specifies how to handle directory overflow situations for the CSIM, MS Format, and CSI format directories: "DepthCascadeMethod", "WidthCascadeMethod", "ContinueCascadeMethod", |
|
CSIMFormatUseContractVOI |
CSIM and MS Format data records have a Volume and an Open Interest field. Specify this attribute as "True" to use the contract values rather than the total values. |
|
CSIFormat999FilesPerDirectory |
"True" if the limit for the number of CSI format files per directory should be raised to 999 from 120. Only very old software needs the directory to be limited to 120. |
|
CSICopyContractVOIToTotal |
"True" if the records in CSI format should have the total volume/open interest values overwritten by the contract values. |
|
CSICopyTotalVOIToContract |
"True" if the records in CSI format should have the contract volume/open interest values overwritten by the total values. |
|
CSIFormatExtendedRecordCount |
Specify the minimum number of empty data records you wish to have at the end of CSI format Documents. This is used by some analysis software which makes predictions/what-if scenarios. |
|
AsciiFile_DisplayDecimalsWithMaximalPrecision |
"True" is decimal output Ascii/Excel files should be written with 8 decimal digits rather than the minimal number of digits to express the quantity. |
|
AsciiFilesEndInPrn |
"True" to have Ascii files end in "Prn" rather than "csv". Takes precedence to AsciiFilesEndInTxt. |
|
AsciiFilesEndInTxt |
"True" to have Ascii files end in "Txt" rather than "csv". Has no effect if AsciiFilesEndInPrn is "True". |
|
AutoUpdate |
"True" to specify that the Document is to be written and kept uptodate. |
The Command attribute for a Document Action node include AddDocument, ModifyDocument, or DeleteDocument. A similar document is searched for by a complex set of comparisons. At least the Symbol, IsStock, ComputationMethod, FileFormat, and FilePeriod must agree. Depending upon the ComputationMethod still more may need to be specified. For example, to delete a 24000 Oct ’03 strike series for Cotton, the strike and delivery month are also needed to distinguish the series. When possible, it is usually better for the end user if Documents are separated into different Portfolios so that the whole Portfolio can be deleted and readded rather than trying to modify the documents.
The attribute nodes for all Document nodes:
|
Attribute Name |
Meaning/Values |
|
Symbol |
Underlying tradable symbol. |
|
Csinum |
Used if Symbol is not present to identify market by MarketNumber. One or the other must be present and valid. |
|
IsStock |
"True" is the tradable is listed in the Stock database rather than as a Future. There are some Cash series in each. |
|
PortfolioName |
The name of the Portfolio(logical Directory) in which the Document is to be written. May not be omitted. |
|
ComputationMethod |
Designates the type of Document: Contract, Stock, IFG, NearestContracts, Perpetual, OIPerpetual, NearestFuture, BackAdjust/ BackAdjusted, Gann, PutCallRatio. May not be omitted. |
|
DetrendMethod |
Specifies method of detrending: "DetrendBySecondContract", "NotDetrended", "DetrendBySecondDay", |
|
Inverted |
"True" to have open -> 1/open, high -> 1/low, low -> 1/high, close -> 1/close. |
|
CustomPostProcessing |
Contains text of PostProcessing code. Attribute Language should be provided. Values: "Unknown_Language", "VBScript_Language", "PerlScript_Language", "Perl_Language", "JScript_Language", "AnyLanguage_Language" |
|
StartDate |
Specify the earliest date requested (-1 for as available). For example 20041231 for 12/31/2004. |
|
EndDate/StopDate |
Specify the latest date requested (-1 for as available). For example 20041231 for 12/31/2004. |
|
FileFormat |
Specifies format of Document: "None", (Default used only for charting in UA) "CSI", "CSIM", "Ascii", "MS Format", "Excel", |
|
AsciiFileSeparator |
Specify the character to be used when generated Ascii files ‘,’ by default. |
|
AsciiIncludesCentury |
"True" if you want date to include centurary (1999 instead of 99). |
|
FilePeriod |
Specifies the aggregation of the Document: "Daily", "Weekly", "Monthly", "Quarterly", "Semiannually", "Yearly", |
|
ODBCAlias |
Unused |
|
ODBCParms |
Unused |
The attribute nodes for Contract/Stock Document nodes:
|
Attribute Name |
Meaning/Values |
|
Dydm |
Delivery month for contract. 54 for stock or cash series. |
|
Strike |
An identifier for the strike price P12000 for example. Start with P or C for Put or Call, or use negative numbers for puts and positive numbers for calls. |
There are no special attribute nodes for PutCallRatio documents.
The attribute nodes for IFG/NearestContracts group Document nodes:
|
Attribute Name |
Meaning/Values |
|
IncludeCash |
"True" to include the Cash contract as part of the group. |
|
ValidMonths |
A string of 12 characters see 4.1.2.8 Prop: ValidMonths for details. |
|
NumOfFuturesToInclude |
The number of futures (including possibly cash) to include. |
|
DayOfMonthToRoll |
Which day of the month to roll (31 for on-expiration.) |
|
MonthsPriorToRoll |
How many months before the contract month to roll (0 for expiration month.) |
|
IncludesHistory |
Indicates whether the contract prior to the current group should be written. (Not guaranteed to be maintained.): "HistoryHasBeenWritten", "HistoryNotWanted", "HistoryIsNeeded", |
The attribute nodes for Perpetual or OIPerpetual Document nodes:
|
Attribute Name |
Meaning/Values |
|
ValidMonths |
A string of 12 characters see 4.1.2.8 Prop: ValidMonths for details. |
|
MonthsAheadToViewMarket |
Forward time perspective |
|
DayOfMonthToRoll |
Which day of the month to roll (31 for on-expiration.) |
|
MonthsPriorToRoll |
How many months before the contract month to roll (0 for expiration month.) |
|
OIWeighted |
"True" to use OI weighting rather than time remaining. |
The attribute nodes for NearestFuture and BackAdjust/BackAdjusted nodes (see sec. 4.3.2 for more information):
|
Attribute Name |
Meaning/Values |
|
ValidMonths |
A string of 12 characters see 4.1.2.8 Prop: ValidMonths for details. |
|
DayOfMonthToRoll |
Which day of the month to roll (31 for on-expiration.) |
|
MonthsPriorToRoll |
How many months before the contract month to roll (0 for expiration month.) |
|
RollLogicType |
"RollOnDayRelativeToEndOfMonthType", "RollOnDayRelativeToStartOfMonthType", "RollOnOpenInterestAndVolumeType", "RollOnOpenInterestOrVolumeType", "RollOnVolumeType", "RollOnOpenInterestType", |
|
RollWhenValue |
"RollWhen_ReportedErrValue", "RollWhen_Known", "RollWhen_Reported", "RollWhen_Anticipated", |
|
RollDeltaComputatationType |
"ZeroRollDelta", "OpenToOpenRollDelta", "CloseToCloseRollDelta", "CloseToOpenRollDelta", "CloseToOpenOldGapRollDelta", "CloseToOpenNewGapRollDelta", |
|
NumDaysConfirmation |
Specify the number of days of confirmation including the rolling day. Must be at least 1. |
|
GenerateForward |
"True" or "1" to begin with the earliest data and step day-by-day to the current day. "False" or "0" to begin with the current contract and prepend earlier data. |
|
RollPriorToExpiration |
Specify to force rolling before expiration. Must be at least 1 day, if used. |
|
TargetForwardContract (NearestFuture only) |
Specify which forward contract to select. Must be at least 1. Using large numbers creates gaps. |
The attribute nodes Gann Document nodes:
|
Attribute Name |
Meaning/Values |
|
DeliveryMonthToView |
A number 1 to 12 or "January" to "February" |
|
DayOfMonthToRoll |
Which day of the month to roll (31 for on-expiration.) |
|
MonthsPriorToRoll |
How many months before the contract month to roll (0 for expiration month.) |
The Command attribute for a Document Action node may be LaunchChart. Specify the same attributes you would for a Document (see 4.5.3) those that don’t apply such as FileFormat, FilePeriod, and PortfolioName.
Appendix A: List of Properties and Methods
|
Type |
Name |
Reference |
|
Long |
ContractDeliveryCode |
4.2.4 |
|
Long |
ContractFirstDate |
4.2.5 |
|
Long |
ContractLastDate |
4.2.6 |
|
String |
ContractSize |
4.1.2 |
|
Short (+8 … -8) |
ConversionFactor |
4.1.2.6 |
|
String |
Currency |
4.1.2 |
|
Short |
DetrendMethod |
4.1.3.8 |
|
String |
Exchange |
4.1.2.4 |
|
Boolean (non-zero is true) |
FillInCashPrice |
4.3.1.9 |
|
Long (YYYYMMDD) |
FirstDate |
4.1.2.2 |
|
Boolean (non-zero is true) |
IncludeHolidays |
4.3.1.3 |
|
Long (YYYYMMDD) |
LastDate |
4.1.2.3 |
|
String |
MarketName |
4.1.2.5 |
|
Long Integer |
MarketNumber |
4.1.1.2 |
|
String |
MarketSymbol |
4.1.1.1 |
|
Float |
MinTickInPoints |
4.1.2.8 |
|
Long |
NumContracts |
4.2.2 |
|
Short |
NumDaysConfirmation |
4.3.2.1.6 |
|
String |
PointValue |
4.1.2 |
|
String |
ShortMarketSymbol |
4.1.2 |
|
Boolean (non-zero is true) |
ShowDecimalPoint |
4.3.1.4 |
|
String |
TradingUnits |
4.1.2 |
|
String (Char[12] each I or V) |
ValidMonths |
4.1.2.7 related to 4.3.2.1.5 |
|
Boolean (non-zero is true) |
DBWasUpdated |
4.4.2 |
|
Method Returns |
Method Invocation |
Reference |
|
Long |
FindMarketNumber() |
4.1.1.3 |
|
Boolean |
GetMarketProfile() |
4.1.2.1 |
|
Long |
GetFirstMarketProfile() |
4.1.3.1 |
|
Long |
GetNextMarketProfile() |
4.1.3.2 |
|
Long |
BuildContractList(long MarketNumber) |
4.2.1 |
|
Long |
GetNextContractDetails() |
4.2.3 |
|
Long |
GetContractDeliveryCode(long ContractListIndex) |
4.2.7 |
|
Long |
GetContractFirstDate(long ContractListIndex) |
4.2.8 |
|
Long |
GetContractLastDate(long ContractListIndex) |
4.2.9 |
|
BOOL |
InvalidateContractList() |
4.2.10 |
|
Long |
RetrieveContract( LongMarketNumber, long ContractDeliveryCode, long StartDate, Long EndDate) |
4.3.1.1 |
|
Long |
CopyDataToClipboard() |
4.3.1.2 |
|
Long |
GetUAStrClipFormat() |
4.3.1.5 |
|
Long |
RetrieveNthNearestFuture( long MarketNumber, short TargetForwardContract, short rollLogicType, short rollWhenVOIKnown, short DayOfMonthToRoll, short MonthsPriorToRoll, String ValidMonths, short GenerateForward, short RollAtLeastNDaysBeforeExpiration, long StartDate, Long EndDate) |
4.3.2.1 |
|
Long |
RetrieveNearestFutures( long MarketNumber, short NumOfFuturesToInclude, short DayOfMonthToRoll, short MonthsPriorToRoll, Boolean IncludeCash, String ValidMonths, long StartDate, Long EndDate) |
4.3.2.3 |
|
Long |
RetrieveBackAdjustedContract( long MarketNumber, short rollLogic, short rollWhen, short DayOfMonthToRoll, short MonthsPriorToRoll, short accumulationMethod, short rollDeltaType, LPCSTR ValidMonths, short GenerateForward, short RollAtLeastNDaysBeforeExpiration, long StartDate, Long EndDate) |
4.3.2 |
|
Long |
RetrievePerpetualContract( long MarketNumber, short MonthsAheadToViewMarket, short OIWeighted, short DayOfMonthToRoll, short MonthsPriorToRoll, String ValidMonths, long StartDate, Long EndDate) |
4.3.2.4 |
|
Long |
RetrieveGannContract( long MarketNumber, short DeliveryMonthToView, short DayOfMonthToRoll, short MonthsPriorToRoll, long StartDate, Long EndDate) |
4.3.2.5 |
|
Long |
RetrieveStock( long MarketNumber, long StartDate, long EndDate) |
|
|
Void |
UpdateDatabase() |