Click here to Skip to main content
15,896,063 members
Articles / Programming Languages / C# 4.0

An Introduction to Real-Time Stock Market Data Processing

Rate me:
Please Sign up or sign in to vote.
4.96/5 (64 votes)
20 May 2013CPOL24 min read 333K   57.7K   202  
Discusses how stock market trading works, the different types of market data available, and provides a code example with sample data that processes a market data feed
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SparkAPI.Data;

namespace SparkWinFormsGUI
{
    public partial class FormMain : Form
    {

        /// <summary>
        /// FormMain constructor
        /// </summary>
        public FormMain()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Display options form
        /// </summary>
        private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormOptions optionsForm = new FormOptions();
            optionsForm.ShowDialog(this);            
        }

        /// <summary>
        /// Close application
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {

            //Ensure disconnection from Spark API
            ApiFunctions.Disconnect();
            
            //Close main form
            Close();

        }

        /// <summary>
        /// Display live market security form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void securityLiveToolStripMenuItem_Click(object sender, EventArgs e)
        {

            //Check that user has setup Spark credentials
            ApiCredentials credentials = ApiCredentials.LoadFromFile();
            if ((credentials == null) || (!credentials.Validate()))
            {
                MessageBox.Show(this, "Connection to live market feed via the Spark API requires a valid username and password. " +
                                      "Please enter security credentials in the appliction options.",
                                "Authorisation", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                optionsToolStripMenuItem_Click(this, null);
                return;
            }

            //Display live market security form
            FormSecurity securityForm = new FormSecurity();
            securityForm.Show();

        }

        /// <summary>
        /// Display replay from file security form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void securityReplayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormSecurityReplay securityReplayForm = new FormSecurityReplay();
            securityReplayForm.Show();
        }

        /// <summary>
        /// Display the export security to file form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void exportToFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormExport exporForm = new FormExport();
            exporForm.ShowDialog(this);
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Australia Australia
Paul Francis currently works as a senior engineer at The Trade Desk.

He holds an undergraduate Honours degree in Finance, and is near completion of a Ph.D. in Market Microstructure, specialising in order flow modelling, and market data processing, reconstruction and analytics.

He is also the creator of Sharp Spark (Spark API SDK), an open source component designed to facilitate the processing of real-time market data from the Spark API: http://sourceforge.net/projects/sparkapi

Paul lives in Sydney, Australia.

Comments and Discussions