When getting some securities in RFA we are getting the price reflected back in decimal value and in EMA we get it Fractional. Example TNU26 It there a way to make EMA requests price display in decimal?
@MM
Thank you for reaching out to us.
The data type is Real which supports both decimal and fractional. The raw data could be fractional so EMA will display it as fractional. You can convert it to decimal by using the following code. I uses EMA C++.
void AppClient::decode( const FieldList& fl ) { while ( fl.forth() ) if (fl.getEntry().getLoadType() == DataType::RealEnum && fl.getEntry().getCode() != Data::BlankEnum) { cout << "Real Fid: " << fl.getEntry().getFieldId() << " Name: " << fl.getEntry().getName() << " value: " << fl.getEntry().getReal().getAsDouble() << endl; } else { cout << "Fid: " << fl.getEntry().getFieldId() << " Name: " << fl.getEntry().getName() << " value: " << fl.getEntry().getLoad().toString() << endl; } }
I call the fl.getEntry().getReal().getAsDouble() method to convert the real to double. However, the code needs to check if the data is blank before accessing the real data type.
The code to iterate all fields is in 120 example.
sorry I wrote ema but we actually use ETA API can you provide the logic for that
In ETA C, you can call the rsslRealToDouble to convert Real to Double.
RsslDouble fidDoubleValue = 0; … case RSSL_DT_REAL: if ((ret = rsslDecodeReal(dIter, &fidRealValue)) == RSSL_RET_SUCCESS) { fidRealBuf.data = (char*)alloca(35); fidRealBuf.length = 35; rsslRealToString(&fidRealBuf, &fidRealValue); rsslRealToDouble(&fidDoubleValue, &fidRealValue); printf("%s (%f)\n", fidRealBuf.data, fidDoubleValue); }
You can check the code on GitHub.