本文整理汇总了C#中StockSharp.Algo.Candles.CandleSeries类的典型用法代码示例。如果您正苦于以下问题:C# CandleSeries类的具体用法?C# CandleSeries怎么用?C# CandleSeries使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CandleSeries类属于StockSharp.Algo.Candles命名空间,在下文中一共展示了CandleSeries类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChartWindow
public ChartWindow(CandleSeries candleSeries, DateTime from, DateTime to)
{
InitializeComponent();
if (candleSeries == null)
throw new ArgumentNullException("candleSeries");
_candleSeries = candleSeries;
_trader = MainWindow.Instance.Trader;
Chart.ChartTheme = "ExpressionDark";
var area = new ChartArea();
Chart.Areas.Add(area);
_candleElem = new ChartCandleElement
{
Antialiasing = false,
UpFillColor = Colors.White,
UpBorderColor = Colors.Black,
DownFillColor = Colors.Black,
DownBorderColor = Colors.Black,
};
area.Elements.Add(_candleElem);
_trader.NewCandles += ProcessNewCandles;
_trader.SubscribeCandles(_candleSeries, from, to);
}
示例2: OnChartPanelSubscribeCandleElement
private void OnChartPanelSubscribeCandleElement(ChartCandleElement element, CandleSeries candleSeries)
{
_drawTimer.Cancel();
_elements.Add(new RefPair<IChartElement, int>(element, 0));
_drawTimer.Activate();
}
示例3: ChartWindow
public ChartWindow(CandleSeries candleSeries)
{
InitializeComponent();
if (candleSeries.IsNull())
throw new ArgumentNullException("candleSeries");
_candleSeries = candleSeries;
_trader = MainWindow.Instance.Trader;
Chart.ChartTheme = "ExpressionDark";
var area = new ChartArea();
Chart.Areas.Add(area);
_candleElem = new ChartCandleElement
{
Antialiasing = false,
UpFillColor = Colors.White,
UpBorderColor = Colors.Black,
DownFillColor = Colors.Black,
DownBorderColor = Colors.Black,
};
area.Elements.Add(_candleElem);
_trader.NewCandles += ProcessNewCandles;
_trader.SubscribeCandles(_candleSeries, DateTime.Today - TimeSpan.FromTicks(((TimeSpan)candleSeries.Arg).Ticks * 100), DateTimeOffset.MaxValue);
}
示例4: SubscribeCandles
/// <summary>
/// Subscribe to receive new candles.
/// </summary>
/// <param name="series">Candles series.</param>
/// <param name="from">The initial date from which you need to get data.</param>
/// <param name="to">The final date by which you need to get data.</param>
public void SubscribeCandles(CandleSeries series, DateTimeOffset from, DateTimeOffset to)
{
if (series == null)
throw new ArgumentNullException("series");
if (series.CandleType != typeof(TimeFrameCandle))
throw new ArgumentException(LocalizedStrings.NotSupportCandle.Put("OANDA", series.CandleType), "series");
if (!(series.Arg is TimeSpan))
throw new ArgumentException(LocalizedStrings.WrongCandleArg.Put(series.Arg), "series");
var transactionId = TransactionIdGenerator.GetNextId();
_series.Add(transactionId, series);
SendInMessage(new MarketDataMessage
{
TransactionId = transactionId,
DataType = MarketDataTypes.CandleTimeFrame,
//SecurityId = GetSecurityId(series.Security),
Arg = series.Arg,
IsSubscribe = true,
From = from,
To = to,
}.FillSecurityInfo(this, series.Security));
}
示例5: UnsubscribeCandles
public void UnsubscribeCandles(CandleSeries series)
{
var key = new SubscriptionKey(series.Security.Id, (TimeSpan) series.Arg);
var subscription = _candleSubscriptions.TryGetValue(key);
if(subscription == null)
return;
subscription.RemoveSubscriber(series);
if(subscription.NumSubscribers > 0)
return;
subscription.CandleBuilder.Candle -= CandleBuilderOnCandle;
_candleSubscriptions.Remove(key);
var msg = new MarketDataMessage().FillSecurityInfo(this, series.Security);
msg.TransactionId = TransactionIdGenerator.GetNextId();
msg.OriginalTransactionId = subscription.SubscribeTransactionId;
msg.SecurityId = GetSecurityId(series.Security);
msg.DataType = MarketDataTypes.CandleTimeFrame;
msg.IsSubscribe = false;
msg.From = subscription.From;
msg.Arg = subscription.TimeFrame;
SendInMessage(msg);
UnSubscribeMarketData(series.Security, MarketDataTypes.CandleTimeFrame);
}
示例6: SmaStrategy
public SmaStrategy(CandleSeries series, SimpleMovingAverage longSma, SimpleMovingAverage shortSma)
{
_series = series;
LongSma = longSma;
ShortSma = shortSma;
}
示例7: CandleSettingsEditorOnClosed
private void CandleSettingsEditorOnClosed(object sender, RoutedEventArgs routedEventArgs)
{
if (_tempCandleSeries == CandleSettingsEditor.Settings || _candleSeries == null)
return;
_tempCandleSeries = CandleSettingsEditor.Settings.Clone();
SecurityPicker_OnSecuritySelected(SecurityPicker.SelectedSecurity);
}
示例8: SmaStrategy
public SmaStrategy(ICandleManager candleManager, CandleSeries series, SimpleMovingAverage longSma, SimpleMovingAverage shortSma)
{
_candleManager = candleManager;
_series = series;
LongSma = longSma;
ShortSma = shortSma;
}
示例9: CandleSeriesIndicatorSource
/// <summary>
/// Создать <see cref="CandleManagerIndicatorSource"/>.
/// </summary>
/// <param name="series">Серия свечек.</param>
public CandleSeriesIndicatorSource(CandleSeries series)
{
if (series == null)
throw new ArgumentNullException("series");
_series = series;
_series.ProcessCandle += OnProcessCandle;
}
示例10: OnChartPanelSubscribeIndicatorElement
private void OnChartPanelSubscribeIndicatorElement(ChartIndicatorElement element, CandleSeries candleSeries, IIndicator indicator)
{
_drawTimer.Cancel();
_elements.Add(new RefPair<IChartElement, int>(element, 0));
_indicators.Add(element, indicator);
_drawTimer.Activate();
}
示例11: ProcessNewCandles
private void ProcessNewCandles(CandleSeries series, IEnumerable<Candle> candles)
{
if (series != _candleSeries)
return;
foreach (var timeFrameCandle in candles)
{
Chart.Draw(_candleElem, timeFrameCandle);
}
}
示例12:
IEnumerable<Range<DateTimeOffset>> IExternalCandleSource.GetSupportedRanges(CandleSeries series)
{
if (series.CandleType != typeof(TimeFrameCandle) || !(series.Arg is TimeSpan))
yield break;
var tf = (TimeSpan)series.Arg;
if (OandaMessageAdapter.TimeFrames.Contains(tf))
yield return new Range<DateTimeOffset>(DateTimeOffset.MinValue, CurrentTime);
}
示例13: SmaStrategy
public SmaStrategy(CandleSeries series, SimpleMovingAverage longSma, SimpleMovingAverage shortSma)
{
_series = series;
LongSma = longSma;
ShortSma = shortSma;
_longSmaPeriod = this.Param("LongSmaPeriod", longSma.Length);
_shortSmaPeriod = this.Param("ShortSmaPeriod", shortSma.Length);
}
示例14: Main
static void Main(string[] args)
{
_candleManager = new CandleManager();
if (!GetSetings())
return;
var storageRegistry = new StorageRegistry();
((LocalMarketDataDrive)storageRegistry.DefaultDrive).Path = _historyPath;
var cbs = new TradeStorageCandleBuilderSource { StorageRegistry = storageRegistry };
_candleManager.Sources.OfType<TimeFrameCandleBuilder>().Single().Sources.Add(cbs);
_candleManager.Processing += GetCandles;
foreach (var Sec in listOfName)
{
foreach (var timeFrame in listOfTimeFrame)
{
_series = new CandleSeries(typeof(TimeFrameCandle), Sec, timeFrame);
LisfStreamWriters.Add(_series.ToString(), new StreamWriter(GetFileName(_series), false));
_candleManager.Start(_series, _startTime, _endTime);
}
}
Console.ReadKey();
// Закроем все потоки которые мы записывали
foreach (var strim in LisfStreamWriters)
{
strim.Value.Close();
}
}
示例15: SubscribeCandleElementCommand
public SubscribeCandleElementCommand(ChartCandleElement element, CandleSeries candleSeries)
{
if (element == null)
throw new ArgumentNullException(nameof(element));
if (candleSeries == null)
throw new ArgumentNullException(nameof(candleSeries));
Element = element;
CandleSeries = candleSeries;
}