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 - API Functions Source Code - buttonRequestHistory_Click

// Requests a HISTORY TICK or HISTORY OHLC record by building up the appropriate // XML string and sending it to the QT Server


private void buttonRequestHistory_Click(object sender, System.EventArgs e)
{
try
{
FormGetHistory FormGetHistory = new FormGetHistory();
if (FormGetHistory.ShowDialog(this) == DialogResult.OK)
{
if (FormGetHistory.radioButtonTick.Checked == true)
mReqType = "TICK";
else
mReqType = "OHLC";

DateTime From = DateTime.Parse(FormGetHistory.dateTimePickerFrom.Text);
DateTime To = DateTime.Parse(FormGetHistory.dateTimePickerTo.Text);

string data = "<GetHistory><ReqType>" + mReqType + "</ReqType>";
data += "<Symbol>" + FormGetHistory.textBoxSymbol.Text + "</Symbol>";
data += "<FROM>" + From.ToString("yyyy/MM/dd HH:mm:ss") + "</FROM><TO>" + To.ToString("yyyy/MM/dd HH:mm:ss") + "</TO></GetHistory>";
byte[] byteData = Encoding.ASCII.GetBytes(data + "\0");
byteData[byteData.Length-1] = 255;

mClient.Send(byteData, 0, byteData.Length, SocketFlags.None);

StateObject state = new StateObject();
mClient.BeginReceive( state.buffer, 0, StateObject.BufferSize, 0,
new AsyncCallback(ReceiveCallback), state);

RichTextBoxAppendText(richTextBoxMessageToServer, data + Environment.NewLine);
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}