using System;
using System.Collections.Generic;
using TradeIdeas.MiscSupport;
namespace TIWebApi.Clients.MarketData
{
///
/// Combined Trade and Quote Object
/// The Quote Data is at the time of the Trade
///
public class TradeQuote
{
public TradeQuote(List data)
{
Symbol = data[0].ToString();
TradeTime = DateTime.SpecifyKind(Convert.ToDateTime(data[1]), DateTimeKind.Unspecified);
TradeSize = Convert.ToInt32(data[2]);
TradePrice = Convert.ToDecimal(data[3]);
QuoteTime = DateTime.SpecifyKind(Convert.ToDateTime(data[4]), DateTimeKind.Unspecified);
BidSize = Convert.ToInt32(data[5]);
Bid = Convert.ToDecimal(data[6]);
AskSize = Convert.ToInt32(data[7]);
Ask = Convert.ToDecimal(data[8]);
//Will remove this check after this new field has been deployed on all the servers
if (data.Count >= 12)
{
TradeTimeUTC = DateTime.SpecifyKind(Convert.ToDateTime(data[11]), DateTimeKind.Utc);
if( data.Count >= 13)
{
PreviousClosePrice = Convert.ToDecimal(data[12]);
if( PreviousClosePrice != 0)
{
DollarChange = TradePrice - PreviousClosePrice;
PercentChange = (DollarChange / PreviousClosePrice) * 100;
}
}
if (data.Count >= 14)
{
if (data[13] != null)
HaltResumeStatus = data[13].ToString();
if (data[14] != null && DateTime.TryParse(data[14].ToString(), out DateTime parsedDate))
{
HaltResumeTime = ServerFormats.FromUtc(parsedDate);
//HaltResumeTime = DateTime.SpecifyKind(parsedDate, DateTimeKind.Utc).ToLocalTime();
}
}
}
}
///
/// The Symbol of the Financial Instrument
///
public string Symbol { get; set; }
///
/// The Time of this Trade in Eastern Time
///
public DateTime TradeTime { get; set; }
///
/// The Time of this Trade in UTC Time
///
public DateTime TradeTimeUTC { get; set; }
///
/// The actual number of shares traded, it is not divided by 100.
///
public int TradeSize { get; set; }
///
/// The Price of the Last Trade
///
public decimal TradePrice { get; set; }
///
/// The time of the Quote
///
public DateTime QuoteTime { get; set; }
///
/// The number of shares investors are willing to buy at the bid price
///
public int BidSize { get; set; }
///
/// The higest price someone is willing to pay for the stock.
///
public decimal Bid { get; set; }
///
/// The number of shares a market maker is offering to sell at the ask price
///
public int AskSize { get; set; }
///
/// The minimum price a seller will take for a security
///
public decimal Ask { get; set; }
public decimal PreviousClosePrice { get; set; }
public decimal DollarChange { get; set; }
public decimal PercentChange { get; set; }
public decimal Volume{ get; set; }
public string HaltResumeStatus { get; set; }
public DateTime? HaltResumeTime { get; set; }
}
}