private QuoteTick parseQuoteStrYahoo(string symbol) { // sorted by price, for calculate mean List<QuoteTick> tmpQuoteLst = new List<QuoteTick>(); for (int i = 0; i < TMP_QUOTE_SIZE; i++) { string stkQuote = YahooAPI.getQuote(symbol); stkQuote = Regex.Replace(stkQuote, "[\"]|[\r]|[\n]", ""); string[] entries = stkQuote.Replace("\r", "").Split(','); QuoteTick tmpQuote = new QuoteTick(); tmpQuote.QtTime = Convert.ToDateTime(entries[1]); // why data magically appeared? TODO: figure it out after 12am someday tmpQuote.QtLastPrice = Convert.ToDouble(entries[2]); tmpQuote.QtLastSize = Convert.ToInt64(entries[3]); tmpQuoteLst.Add(tmpQuote); } List<QuoteTick> SortedList = tmpQuoteLst.OrderBy(o => o.QtLastPrice).ToList(); // calculate average double avgPrice = 0; for (int i = 1; i < TMP_QUOTE_SIZE - 1; i++) { avgPrice += SortedList[i].QtLastPrice; } avgPrice /= TMP_QUOTE_SIZE - 2; QuoteTick qtick = new QuoteTick(); qtick = tmpQuoteLst[TMP_QUOTE_SIZE - 1]; qtick.QtLastPrice = avgPrice; return qtick; }
public double unrealizedPNL(QuoteTick lastQuote) { return 0; }