13:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.130 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 13:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.1313:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.13

.

.

Wednesday, September 28, 2011

QuoteTracker - C# API Functions Source Code - ParseField

// Stores value from parsing bytes Data starting from position i to appropriate
// property in L1Quote, converting to appropriate type.
int ParseField(ref L1Quote L1Quote, short FieldID, ref byte[] Data, int i, ref string message)
{
try
{
switch (FieldID)
{
case 1: int i1 = IndexOf0( Data, i);
L1Quote.Symbol = Encoding.ASCII.GetString(Data, i, i1-i);
message = Environment.NewLine + Environment.NewLine + "Symbol=" + L1Quote.Symbol + " ";
i = i1 + 1;
break;

case 2: L1Quote.Bid = BitConverter.ToDouble(Data, i);
message = "Bid=" + L1Quote.Bid.ToString() + " ";
i += 8; //  Float (8 bytes)
break;

case 3: L1Quote.Ask = BitConverter.ToDouble(Data, i);
message = "Ask=" + L1Quote.Ask.ToString() + " ";
i += 8; //  Float (8 bytes)
break;

case 4: L1Quote.Last = BitConverter.ToDouble(Data, i);
message = "Last=" + L1Quote.Last.ToString() + " ";
i += 8; //  Float (8 bytes)
break;

case 5: L1Quote.Change = BitConverter.ToDouble(Data, i);
message = "Change=" + L1Quote.Change.ToString() + " ";
i += 8; //  Float (8 bytes)
break;

case 6: L1Quote.Volume = BitConverter.ToInt64(Data, i);
message = "Volume=" + L1Quote.Volume.ToString() + " ";
i += 8; //  Int (8 bytes)
break;

case 7: L1Quote.Open = BitConverter.ToDouble(Data, i);
message = "Open=" + L1Quote.Open.ToString() + " ";
i += 8; //  Float (8 bytes)
break;

case 8: L1Quote.PrevClose = BitConverter.ToDouble(Data, i);
message = "PrevClose=" + L1Quote.PrevClose.ToString() + " ";
i += 8; //  Float (8 bytes)
break;

case 9: L1Quote.BidSize = BitConverter.ToInt32(Data, i);
message = "BidSize=" + L1Quote.BidSize.ToString() + " ";
i += 4; //  Int (4 bytes)
break;

case 10: L1Quote.AskSize = BitConverter.ToInt32(Data, i);
message = "AskSize=" + L1Quote.AskSize.ToString() + " ";
i += 4; //  Int (4 bytes)
break;

case 11: L1Quote.LastSize = BitConverter.ToInt32(Data, i);
message = "LastSize=" + L1Quote.LastSize.ToString() + " ";
i += 4; //  Int (4 bytes)
break;

case 12: L1Quote.High = BitConverter.ToDouble(Data, i);
message = "High=" + L1Quote.High.ToString() + " ";
i += 8; //  Float (8 bytes)
break;

case 13: L1Quote.Low = BitConverter.ToDouble(Data, i);
message = "Low=" + L1Quote.Low.ToString() + " ";
i += 8; //  Float (8 bytes)
break;

case 14: L1Quote.Tick = BitConverter.ToChar(Data, i);
message = "Tick=" + L1Quote.Tick.ToString() + " ";
i += 1; // Char (1 byte)
break;

case 15: //int i1 = BinaryUtilities.IndexOf0( Data, i);
// QuoteField2.DateTime = Encoding.ASCII.GetString(Data, i, i1-i); i=i1+1; break; //   Text (14 bytes)
L1Quote.DateTime = Encoding.ASCII.GetString(Data, i, 14);
message = "DateTime=" + L1Quote.DateTime.ToString() + " ";
i += 14; //   Text (14 bytes)
break;

case 16: i += 8;
break;

case 17: i += 8;
break;

case 18: i1 = IndexOf0( Data, i); i = i1 + 1;
break;

case 19: i += 8;
break;

case 20: i += 4;
break;

case 21: i += 4;
break;

case 22: i += 8;
break;

case 23: i += 8;
break;

case 24: i += 8;
break;
case 25: i1 = IndexOf0( Data, i); i = i1 + 1;
break;

case 26: i1 = IndexOf0( Data, i); i = i1 + 1;
break;

case 27: i += 8;
break;

case 28: i += 4;
break;

case 29: i += 1;
break;

case 30: i += 8;
break;

default:
break;
}

return i;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return 0;
}
}