using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
namespace Infragistics.Models
{
// TODO add data model
// TODO add data source
}
This topic provides sample data and data models for use with the XamDataChart™ control and its Financial Series and Financial Indicators types.
This topic contains the following sections:
In C#:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
namespace Infragistics.Models
{
// TODO add data model
// TODO add data source
}
In Visual Basic:
Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.Linq
Namespace Infragistics.Models
' TODO add sample data model
' TODO add sample data source
End Namespace
In C#:
public class StockPriceItem
{
public double Volume { get; set; }
public double Open { get; set; }
public double Close { get; set; }
public double High { get; set; }
public double Low { get; set; }
public DateTime Date { get; set; }
}
In Visual Basic:
Public Class StockPriceItem
Public Property Volume As Double
Public Property Open As Double
Public Property Close As Double
Public Property High As Double
Public Property Low As Double
Public Property Date As DateTime
End Class
In C#:
public class StockPriceData : List<StockPriceItem>
{
protected internal Random Rand = new Random();
public StockPriceData()
{
double open = 500, close, low, high, mod;
double volume = 10000;
var total = 100;
var range = 5;
var date = DateTime.Now.AddDays(-total);
for (var i = 0; i < total; i++)
{
low = open - (Rand.NextDouble() * range);
high = open + (Rand.NextDouble() * range);
mod = Rand.NextDouble() - 0.4;
close = open + (mod * range);
var item = new StockPriceItem();
item.Volume = volume;
item.Open = open;
item.Close = close;
item.High = high;
item.Low = low;
item.Volume = volume;
item.Date = date;
this.Add(item);
open = open + (mod * range * 2);
volume = volume + (mod * range * 100 );
date = date.AddDays(1);
}
}
}
In Visual Basic:
Public Class StockPriceData Inherits ist(Of StockPriceItem)
Protected Rand As Random = New Random
Public Sub New()
MyBase.New
Dim mod As Double
Dim open As Double = 500
Dim close As Double
Dim low As Double
Dim high As Double
Dim volume As Double = 10000
Dim total As var = 100
Dim range As var = 5
Dim date As var = DateTime.Now.AddDays((total * -1))
Dim i As var = 0
Do While (i < total)
low = (open - (Rand.NextDouble * range))
high = (open + (Rand.NextDouble * range))
mod = (Rand.NextDouble - 0.4)
close = (open + (mod * range))
Dim item As var = New StockPriceItem
item.Volume = volume
item.Open = open
item.Close = close
item.High = high
item.Low = low
item.Volume = volume
item.Date = date
Me.Add(item)
open = (open + (mod * (range * 2)))
volume = (volume + (mod * (range * 100)))
date = date.AddDays(1)
i = (i + 1)
Loop
End Sub
End Class