25 public static partial class Field
27 private readonly
static Func<IBaseData, decimal> _high = DataTypePropertyOrValue<IBaseDataBar>(x => x.High);
28 private readonly
static Func<IBaseData, decimal> _low = DataTypePropertyOrValue<IBaseDataBar>(x => x.Low);
29 private readonly
static Func<IBaseData, decimal> _open = DataTypePropertyOrValue<IBaseDataBar>(x => x.Open);
30 private readonly
static Func<IBaseData, decimal> _bidClose = DataTypePropertyOrValue<QuoteBar>(x => ((
QuoteBar)x).Bid.Close);
31 private readonly
static Func<IBaseData, decimal> _bidOpen = DataTypePropertyOrValue<QuoteBar>(x => ((
QuoteBar)x).Bid.
Open);
32 private readonly
static Func<IBaseData, decimal> _bidLow = DataTypePropertyOrValue<QuoteBar>(x => ((
QuoteBar)x).Bid.
Low);
33 private readonly
static Func<IBaseData, decimal> _bidHigh = DataTypePropertyOrValue<QuoteBar>(x => ((
QuoteBar)x).Bid.
High);
34 private readonly
static Func<IBaseData, decimal> _askClose = DataTypePropertyOrValue<QuoteBar>(x => ((
QuoteBar)x).Ask.
Close);
35 private readonly
static Func<IBaseData, decimal> _askOpen = DataTypePropertyOrValue<QuoteBar>(x => ((
QuoteBar)x).Ask.
Open);
36 private readonly
static Func<IBaseData, decimal> _askLow = DataTypePropertyOrValue<QuoteBar>(x => ((
QuoteBar)x).Ask.
Low);
37 private readonly
static Func<IBaseData, decimal> _askHigh = DataTypePropertyOrValue<QuoteBar>(x => ((
QuoteBar)x).Ask.
High);
38 private readonly
static Func<IBaseData, decimal> _bidPrice = DataTypePropertyOrValue<Tick>(x => ((
Tick)x).
BidPrice, defaultQuoteSelector: x => ((
QuoteBar)x).Bid.Close);
39 private readonly
static Func<IBaseData, decimal> _askPrice = DataTypePropertyOrValue<Tick>(x => ((
Tick)x).
AskPrice, defaultQuoteSelector: x => ((
QuoteBar)x).Ask.Close);
40 private readonly
static Func<IBaseData, decimal> _volume = DataTypePropertyOrValue<TradeBar>(x => ((
TradeBar)x).
Volume, x => ((
Tick)x).Quantity);
41 private readonly
static Func<IBaseData, decimal> _average = DataTypePropertyOrValue<IBaseDataBar>(x => (x.Open + x.High + x.Low + x.Close) / 4m);
42 private readonly
static Func<IBaseData, decimal> _median = DataTypePropertyOrValue<IBaseDataBar>(x => (x.High + x.Low) / 2m);
43 private readonly
static Func<IBaseData, decimal> _typical = DataTypePropertyOrValue<IBaseDataBar>(x => (x.High + x.Low + x.Close) / 3m);
44 private readonly
static Func<IBaseData, decimal> _weighted = DataTypePropertyOrValue<IBaseDataBar>(x => (x.High + x.Low + 2 * x.Close) / 4m);
45 private readonly
static Func<IBaseData, decimal> _sevenBar = DataTypePropertyOrValue<IBaseDataBar>(x => (2 * x.Open + x.High + x.Low + 3 * x.Close) / 7m);
50 public static Func<IBaseData, decimal>
BidClose
52 get {
return _bidClose; }
58 public static Func<IBaseData, decimal>
BidOpen
60 get {
return _bidOpen; }
66 public static Func<IBaseData, decimal>
BidLow
68 get {
return _bidLow; }
74 public static Func<IBaseData, decimal>
BidHigh
76 get {
return _bidHigh; }
82 public static Func<IBaseData, decimal>
AskClose
84 get {
return _askClose; }
90 public static Func<IBaseData, decimal>
AskOpen
92 get {
return _askOpen; }
98 public static Func<IBaseData, decimal>
AskLow
100 get {
return _askLow; }
106 public static Func<IBaseData, decimal>
AskHigh
108 get {
return _askHigh; }
114 public static Func<IBaseData, decimal>
AskPrice
116 get {
return _askPrice; }
122 public static Func<IBaseData, decimal>
BidPrice
124 get {
return _bidPrice; }
130 public static Func<IBaseData, decimal>
Open
132 get {
return _open; }
138 public static Func<IBaseData, decimal>
High
140 get {
return _high; }
146 public static Func<IBaseData, decimal>
Low
154 public static Func<IBaseData, decimal>
Close
156 get {
return x => x.
Value; }
162 public static Func<IBaseData, decimal>
Average
164 get {
return _average; }
170 public static Func<IBaseData, decimal>
Median
172 get {
return _median; }
178 public static Func<IBaseData, decimal>
Typical
180 get {
return _typical; }
186 public static Func<IBaseData, decimal>
Weighted
188 get {
return _weighted; }
194 public static Func<IBaseData, decimal>
SevenBar
196 get {
return _sevenBar; }
202 public static Func<IBaseData, decimal>
Volume
204 get {
return _volume; }
207 private static Func<IBaseData, decimal> DataTypePropertyOrValue<T>(Func<T, decimal> selector,
208 Func<IBaseData, decimal> defaultTickSelector =
null,
209 Func<IBaseData, decimal> defaultQuoteSelector =
null)
214 var dataType = x as T;
215 if (dataType !=
null)
217 return selector(dataType);
220 var tick = x as
Tick;
221 if (tick !=
null && defaultTickSelector !=
null)
223 return defaultTickSelector(x as
Tick);
227 if (quoteBar !=
null && defaultQuoteSelector !=
null)
229 return defaultQuoteSelector(x as
QuoteBar);
232 var defaultSelector =
new Func<IBaseData, decimal>(data => data.Value);
233 return defaultSelector(x);