MarySun wrote:
Anton,
TT has a box called Time & Sales, which in the API returns the object Trade. That object contains also the "direction" of the trade, which can either be buy or sell. As a trader I can tell you that is very usefull to have a clear view regards the market, if people are hitting the bid or lifting the offer. I've seen an implementation on TT API developer's forum, and I think it shouldn't be too complicated to have also this property in OQ.
Regards
/// <summary>
/// This function is called when an instrument udpate
/// occurs, however, this data is not coalesced.
///
/// NOTE: Fired when DeliverAllPriceUpdates is enabled.
/// </summary>
/// <param name="pNotify">TTInstrNotify object</param>
private void m_TTInstrNotify_OnPriceListUpdate(XTAPI.TTInstrNotify pNotify)
{
try
{
if (pNotify != null)
{
//Set variables
string sMsg = null;
string direction = null;
double ltp = 0.0f;
int ltq = 0;
foreach (XTAPI.ITTPriceUpdate priceUpdate in pNotify.PriceList)
{
//Loop through PriceEntries in PriceUpdate
foreach (XTAPI.ITTPriceEntry priceEntry in priceUpdate)
{
switch (priceEntry.PriceID)
{
//Calculate Last Traded Price
case XTAPI.enumPriceID.ttLastTradedPrice:
ltp = priceEntry.toDouble();
break;
//Calculate Last Traded Quantity
case XTAPI.enumPriceID.ttLastTradedQty:
ltq = (int)priceEntry.toDouble();
break;
//Calculate Hit or Take
case XTAPI.enumPriceID.ttHitTake:
if (priceEntry.toDouble() == Convert.ToDouble(XTAPI.enumTradeIndicator.TRADE_INDICATOR_HIT))
{
direction = "Hit"; //Sell
}
else if (priceEntry.toDouble() == Convert.ToDouble(XTAPI.enumTradeIndicator.TRADE_INDICATOR_TAKE))
{
direction = "Take"; //Buy
}
else if (priceEntry.toDouble() == Convert.ToDouble(XTAPI.enumTradeIndicator.TRADE_INDICATOR_UNKNOWN))
{
direction = "Indeterminate"; //Indeterminate
}
break;
}
}
//Get timestamp of PriceUpdate
string timestamp = priceUpdate.TimeStamp.Substring(0,8);
//Write message
sMsg = m_Cnt + "," + timestamp + "," + priceUpdate.Instrument.Exchange + "," + priceUpdate.Instrument.Product + "," + priceUpdate.Instrument.get_Get("Expiry") + "," + direction + "," + ltp + "," + ltq;
//Add sMsg to ListBox
lboPriceList.Items.Add(sMsg);
//Increase count
m_Cnt = m_Cnt + 1;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "," + ex.StackTrace);
}
}
This is the TT Code, as you can see is just a comparison between quotes side and where the trade hit the book. It shouldn't be so difficult to implement. Anyway I can write a DLL to add this feature if anyone is interested!
Regards