|
|
|
|
Purpose |
This function converts a price from the ASPEN_PRICE format to both a text string and a collection of numeric values representing a price’s whole and fractional portions. This decoding provides values necessary for further display and computation. | ||||
|
|
| ||||
|
Syntax |
#include <aspen.h> ... int AspenDecodePrice( ASPEN_PRICE price, ASPEN_QUANTUM quantum, int reduce, char *priceStr, long *whole, long *remainder, long *units); | ||||
|
|
| ||||
|
Parameters |
price price contains an encoded Aspen price value. The value may be either positive or negative (as in a negative net-change value).
quantum quantum is an ASPEN_QUANTUM parameter that contains the base and the exponent describing a price’s minimum trading unit.
reduce reduce is a boolean parameter. If a non-zero (for TRUE) value is used, all fractional values will be reduced to the smallest possible units. For example, a value of 12/16ths would be reduced to 3/4ths. A decimal value of .030 would be reduced to .03. The reduced value will be reflected in the output of the parameters described below. If a zero (for false) value is used, no reduction occurs.
*priceStr *priceStr is a pointer to a user-supplied buffer that will receive a character string with a readable (display scale) representation of the value in price. Set this parameter to NULL if the output string is not desired.
*whole *whole is a pointer to a 32-bit signed integer value that will receive the whole number portion of the value in price. Set this parameter to NULL if the output value is not desired.
*remainder *remainder is a pointer to a 32-bit signed integer value that will receive the fractional remainder of the value in price. This value is in terms of the value returned by the units output variable. Set this parameter to NULL if the output value is not desired.
*units *units is a pointer to a 32-bit integer value that will receive a value describing the mathematical units used by *remainder. For example, the fractional value 3/32nds would be expressed by a value of 3 in *remainder and a value of 32 in *units. Set this parameter to NULL if the output value is not desired. | ||||
|
|
| ||||
|
Remarks |
AspenDecodePrice() eliminates coding necessary to apply an instrument’s quantum. Further, this function can be used to format output, or to perform additional processing on price data. | ||||
|
|
| ||||
|
Return Value |
A function result code.
| ||||
|
|
| ||||
|
See Also |
|||||
|
|
| ||||
|
Example |
void CHistoryEditDemoDlg::OnDecodePrice() { int retval; char priceBuffer[32]; ASPEN_INSTRUMENT contract; ASPEN_GETINSTRUMENT_INPUT input; server_list *slp = list; unsigned long inum; char symbol_xlat[256]; CString strText; GetDlgItemText (EDIT_TEXT, strText); strcpy(symbol_xlat, strText); retval = AspenRequest(slp->server_session, ASPEN_GetInstrumentNumber, symbol_xlat, &inum); if (ASPEN_OK == retval) { input.want_updates = ASPEN_NO; input.inum = inum; retval = AspenRequest(slp->server_session, ASPEN_GetInstrumentInfo, &input, &contract); } retval = AspenDecodePrice(contract.open, contract.quantum, ASPEN_YES, priceBuffer, NULL, NULL, NULL); if (retval == ASPEN_OK) { strText.Format("OPEN price for %s (%s): %s", contract.description, contract.symbol, priceBuffer); m_HistoryEdit.AppendString(strText); } ... } | ||||
|
|
|
©2006 Aspen Research Group, Ltd. All rights reserved. Terms of Use.