using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//----------------------------------------------------------------
//Module Name: $safeprojectname$
//Purpose:
//CopyRight: Muchinfo
//History:
//----------------------------------------------------------------
//DateTime 2016/6/8 14:26:19
//Author
//Description Create
//----------------------------------------------------------------
using System.Windows.Media;
using Muchinfo.MTPClient.Data.Helper;
namespace Muchinfo.MTPClient.Data.Quote
{
public class OHLCDataPoints
{
public OHLCDataPoints()
{
}
///
/// 开高低收量,总额
///
/// 时间
/// 开盘价
/// 最高
/// 最低
/// 平仓价
/// 量
/// 总额
public OHLCDataPoints(double date, double open, double high, double low, double close, double volume, double totleTurnovers)
{
Date = date;
Open = open;
High = high;
Low = low;
Close = close;
Volume = volume;
TotleTurnovers = totleTurnovers;
}
public OHLCDataPoints(double close,double date)
{
Close = close;
Open = close;
High = close;
Low = close;
Date = date;
}
///
/// 高开低收
///
///
///
///
///
public OHLCDataPoints(double close, double date, double volume, double turnovers)
{
Close = close;
Open = close;
High = close;
Low = close;
Volume = volume;
Date = date;
TotleTurnovers = turnovers;
}
///
/// 收盘价
///
public double Close { get; set; }
///
/// 开盘价
///
public double Open { get; set; }
///
/// 最高价
///
public double High { get; set; }
///
/// 最低价
///
public double Low { get; set; }
///
/// 成交量
///
public double Volume { get; set; }
///
/// 时间
///
public double Date { get; set; }
///
/// 上一周期的收盘
///
public double PreClose { get; set; }
///
/// 成交金额
///
public double TotleTurnovers { get; set; }
public double CloseAvg { get; set; }
///
/// 涨跌幅
///
public string IncreasePercent
{
get
{
if (Close <= 0 || PreClose <= 0)
{
return "--";
}
return ((Close - PreClose)/PreClose).ToString("p2");
}
}
///
/// 涨跌
///
public string Increase
{
get
{
if (Close <= 0 || PreClose <= 0)
{
return "--";
}
return (Close - PreClose).ToString("f2");
}
}
///
/// 振 幅
///
public string Amplitude
{
get
{
if (PreClose > 0)
{
return ((High - Low) / PreClose).ToString("p2");
}
return "--";
}
}
public string PriceFormat { get; set; }
public DateTime DateTime
{
get
{
return DateTime.FromOADate(Date);
}
}
public Brush OpenBrush
{
get
{
return GetBrush(Open, PreClose);
}
}
public Brush CloseBrush
{
get
{
return GetBrush(Close, PreClose);
}
}
///
/// 最高
///
public Brush HighBrush
{
get
{
return GetBrush(High, PreClose);
}
}
///
/// 最低颜色
///
public Brush LowBrush
{
get
{
return GetBrush(Close, PreClose);
}
}
///
/// 涨跌颜色
///
public Brush IncreaseBrush
{
get
{
return GetBrush(Close, PreClose);
}
}
private Brush AscBrush
{
get
{
return ResourceHelper.GetFromResource("QuoteAscBrush");
}
}
private Brush DecBrush
{
get
{
return ResourceHelper.GetFromResource("QuoteDecBrush");
}
}
private Brush DefaultBrush
{
get
{
return ResourceHelper.GetFromResource("DataGridForeground");
}
}
///
/// Gets the brush.
///
/// The source.
/// The destination.
/// Brush.
private Brush GetBrush(double source, double destination)
{
if (source == 0)
{
return DefaultBrush;
}
if (source > destination)
{
return AscBrush;
}
if (source < destination)
{
return DecBrush;
}
return DefaultBrush;
}
}
}