Financial Application Sample > Generating the data |
Our financial application uses a data source that simulates an actual server providing dynamic data with constant updates.
Not being finance professionals ourselves, we got some inspiration from WikiPedia (http://en.wikipedia.org/wiki/Market_data).
Our data source consists of FinancialData objects that represent typical equity market data message or business objects furnished from NYSE, TSX, or Nasdaq. Each FinancialData object contains information such as this:
Ticker Symbol | IBM |
---|---|
Bid | 89.02 |
Ask | 89.08 |
Bid size | 300 |
Ask size | 1000 |
Last sale | 89.06 |
Last size | 200 |
Quote time | 14:32:45 |
Trade time | 14.32.44 |
Volume | 7808 |
In actuality, this information is usually an aggregation of different sources of data, as quote data (bid, ask, bid size, ask size) and trade data (last sale, last size, volume) are often generated over different data feeds.
To capture the dynamic nature of the data, our data source object provides a FinancialDataList with about 4,000 FinancialData objects and a timer that modifies the objects according to a given schedule. The caller can determine how often the values update and how many update at a time.
Binding the FinancialDataList to a grid and changing the update parameters while the program runs allows us to check how well the grid performs by keeping up with the data updates.
To check the details of the data source implementation, please see the FinancialData.cs file in the sample source.
Binding the grid to the financial data source is straightforward. Instead of binding the grid directly to our FinancialDataList, we create a PagedCollectionView to serve as a broker and provide the usual currency, sorting, grouping, and filtering services for us. Here is the code:
C# |
Copy Code
|
---|---|
// create data source var list = FinancialData.GetFinancialData(); var view = new PagedCollectionView(list); // bind data source to the grid _flexFinancial.ItemsSource = view; |
As in the previous sample, we set the AutoGenerateColumns property to false and use XAML to create the grid columns:
XAML |
Copy Code
|
---|---|
<fg:C1FlexGrid x:Name="_flexFinancial" MinColumnWidth="10" MaxColumnWidth="300" AutoGenerateColumns="False" > <fg:C1FlexGrid.Columns> <fg:Column Binding="{Binding Symbol}" Width="100" /> <fg:Column Binding="{Binding Name}" Width="250" /> <fg:Column Binding="{Binding Bid}" Width="150" Format="n2" HorizontalAlignment="Right" /> <fg:Column Binding="{Binding Ask}" Width="150" Format="n2" HorizontalAlignment="Right" /> <fg:Column Binding="{Binding LastSale}" Width="150" Format="n2" HorizontalAlignment="Right" /> <fg:Column Binding="{Binding BidSize}" Width="100" Format="n0" HorizontalAlignment="Right" /> <fg:Column Binding="{Binding AskSize}" Width="100" Format="n0" HorizontalAlignment="Right" /> <fg:Column Binding="{Binding LastSize}" Width="100" Format="n0" HorizontalAlignment="Right" /> <fg:Column Binding="{Binding Volume}" Width="100" Format="n0" HorizontalAlignment="Right" /> <fg:Column Binding="{Binding QuoteTime}" Width="100" Format="hh:mm:ss" HorizontalAlignment="Center" /> <fg:Column Binding="{Binding TradeTime}" Width="100" Format="hh:mm:ss" HorizontalAlignment="Center" /> </fg:C1FlexGrid.Columns> </fg:C1FlexGrid> |