バージョン

サンプル株価データ

目的

このトピックでは、UltraDataChart™ コントロールおよびその散布シリーズおよび財務指標タイプで使用するサンプル データおよびデータ モデルを提供します。

このトピックの内容

このトピックは、以下のセクションで構成されます。

必須の名前空間

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
}

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

データ モデル

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; }
}

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

データ ソース

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);
        }
    }
}

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