本文整理匯總了C#中OpenQuant.API.BarSeries類的典型用法代碼示例。如果您正苦於以下問題:C# BarSeries類的具體用法?C# BarSeries怎麽用?C# BarSeries使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BarSeries類屬於OpenQuant.API命名空間,在下文中一共展示了BarSeries類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SpiderVwapBand
public SpiderVwapBand(BarSeries input, double factor, InstrumentType instrumentType)
: base(input)
{
_factor = factor;
_instrumentType = instrumentType;
this.Name = string.Format("SpiderVwapBand ({0:N4})", factor);
}
示例2: OnBar
/*
按照股指的時間要求,時間劃分是這樣的
9:15
9:45
10:15
10:45
11:15-11:30 13:00-13:15 兩個15分鍾被午休隔開了
13:45
14:15
14:45
15:15 交割日時隻到15:00,已經到最後一天了,少15分鍾也沒什麽
*/
public override void OnBar(Bar bar)
{
//隻處理15分鍾的
if (900 == bar.Size)
{
if (bars == null)
bars = new BarSeries();
bars.Add(bar);
//在處理11:15-11:30 13:00-13:15這兩個15分鍾時會合並成一個
if (bars.Count == 2) // 2 * 15min = 30 min
{
// get OHLC values for 30min bar
double open = bars[0].Open;
double high = bars.HighestHigh();
double low = bars.LowestLow();
double close = bars[1].Close;
long volume = bars[0].Volume + bars[1].Volume;
// todo something
Bar b = new Bar(bars[0].DateTime, open, high, low, close, volume, 900 * 2);
bars30min.Add(b);
Console.WriteLine(b);
// reset 15min bar series
bars = null;
}
}
}
示例3: BIAS
protected BIAS(BarSeries series, SMA sma, int length, BarData barData)
: base(series)
{
this.length = length;
this.sma = sma;
this.barData = barData;
this.Name = "BIAS";
}
示例4: DynamicBBU
public DynamicBBU(ISeries series, BarSeries bars, double k, BarData barData)
: base(series)
{
this.k = k;
this.bars = bars;
this.barData = barData;
this.Name = "DynamicBBU";
}
示例5: KDJ
protected KDJ(BarSeries series, K_Fast rsv, int length)
: base(series)
{
this.length = length;
this.rsv = rsv;
this.K = new TimeSeries("K");
this.D = new TimeSeries("D");
this.Name = "KDJ(" + length + ")";
}
示例6: Compress
public BarSeries Compress(DataEntryEnumerator enumerator)
{
BarSeries series = new BarSeries();
this.NewCompressedBar += (sender, args) => series.Add(args.Bar);
while (enumerator.MoveNext())
this.Add(enumerator.Current);
this.Flush();
return series;
}
示例7: SpiderVwapBandOld
public SpiderVwapBandOld(ISeries input, double factor, BarSeries priceBarSeries, int barSize, InstrumentType instrumentType)
: base(input)
{
_factor = factor;
_priceBarSeries = priceBarSeries;
_barSize = barSize;
_instrumentType = instrumentType;
this.Name = string.Format("SpiderVwapBand ({0:N4})", factor);
}
示例8: GetHistoricalBars
public static BarSeries GetHistoricalBars(string provider, Instrument instrument, DateTime begin, DateTime end, int size)
{
BarSeries barSeries = new BarSeries();
if (FreeQuant.Providers.ProviderManager.HistoricalDataProviders.Contains(provider))
{
IHistoricalDataProvider provider1 = FreeQuant.Providers.ProviderManager.HistoricalDataProviders[provider];
foreach (FreeQuant.Data.Bar bar in size != 86400 ? (FreeQuant.Series.TimeSeries) FreeQuant.Instruments.DataManager.GetHistoricalBars(provider1, instrument.instrument, begin, end, (long) size) : (FreeQuant.Series.TimeSeries) FreeQuant.Instruments.DataManager.GetHistoricalDailies(provider1, instrument.instrument, begin, end))
barSeries.series.Add(bar);
}
return barSeries;
}
示例9: OnStrategyStart
public override void OnStrategyStart()
{
if (Instrument1 == Instrument)
{
//Strategy1 = this;
BarSeries1 = GetBars(BarType.Time, barSize);
}
else if (Instrument2 == Instrument)
{
//Strategy2 = this;
BarSeries2 = GetBars(BarType.Time, barSize);
}
else
{
Console.WriteLine("合約錯誤!" + Instrument);
}
sma = new SMA(spreadSeries, Length);
Draw(spreadSeries, 2);
Draw(sma, 2);
}
示例10: GetHistoricalBars
public static BarSeries GetHistoricalBars(string provider, Instrument instrument, DateTime begin, DateTime end, int size)
{
BarSeries barSeries = new BarSeries();
if (SmartQuant.Providers.ProviderManager.HistoricalDataProviders.Contains(provider))
{
IHistoricalDataProvider provider2 = SmartQuant.Providers.ProviderManager.HistoricalDataProviders[provider];
SmartQuant.Series.BarSeries barSeries2;
if (size == 86400)
{
barSeries2 = SmartQuant.Instruments.DataManager.GetHistoricalDailies(provider2, instrument.instrument, begin, end);
}
else
{
barSeries2 = SmartQuant.Instruments.DataManager.GetHistoricalBars(provider2, instrument.instrument, begin, end, (long)size);
}
foreach (SmartQuant.Data.Bar bar in barSeries2)
{
barSeries.series.Add(bar);
}
}
return barSeries;
}
示例11: PreLoadHistoricalData
private void PreLoadHistoricalData(DateTime startDate, int barSize, BarSeries barsToAppendTo)
{
Stopwatch watch = new Stopwatch();
watch.Start();
string barName = BarNameManager.GetBarName(barSize);
LoggingUtility.WriteInfo(this, string.Format("Trying to retrieve {0} data starting from {1} from IB", barName, startDate.ToShortDateString()));
BarSeries historicalData = GetHistoricalBars("IB", Instrument,
startDate,
Clock.Now,
barSize);
watch.Stop();
int retrievedBarCount = historicalData.Count;
LoggingUtility.WriteInfo(this,
string.Format("Took {0}ms to retrieve data from IB for {1} period data. Total bars retrieved: {2}",
watch.ElapsedMilliseconds, barName, retrievedBarCount));
watch.Reset();
watch.Start();
foreach (Bar currentBar in historicalData)
{
barsToAppendTo.Add(currentBar);
SaveData(currentBar);
OnBar(currentBar);
}
watch.Stop();
LoggingUtility.WriteInfo(this,
string.Format("Took {0}ms to load data into memory for {1} data", watch.ElapsedMilliseconds, barName));
}
示例12: MDM
public MDM(BarSeries series, Color color)
{
this.indicator = new FreeQuant.Indicators.MDM(series.series, color);
}
示例13: MOM
public MOM(BarSeries series, int length, BarData option)
{
this.indicator = new FreeQuant.Indicators.MOM(series.series, length, EnumConverter.Convert(option));
}
示例14: VROC
public VROC(BarSeries series, int length, Color color)
{
this.indicator = new FreeQuant.Indicators.VROC(series.series, length, color);
}
示例15: K_Slow
public K_Slow(BarSeries series, int length, int order, Color color)
{
this.indicator = new FreeQuant.Indicators.K_Slow(series.series, length, order, color);
}