Тиковые свечи в место кастомного таймфрейма.
Запрашиваю свечной таймфрейм 30 секунд, но приходят тики. Таймфрейм может быть любой с секундами. Может быть и 1минута 30 секунд(00:01:30) - так же приходят тики.
Кодnamespace ShowChart
{
/// <summary>
/// Логика взаимодействия для MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private QuikTrader _trader;
public static CandleManager CandleManager { get; private set; }
public static CandleSeries Series { get; private set; }
public CandleSeries CandleSeries { get; private set; }
public ChartArea Area { get; set; }
public bool IsRealtiem { get; set; }
public ChartCandleElement ChartCandleElement { get; private set; }
public MainWindow()
{
InitializeComponent();
Loaded += MainWindow_Loaded;
}
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
_trader = new QuikTrader()
{
LuaLogin = "Quik",
LuaPassword = "Quik".To<SecureString>(),
LuaFixServerAddress = "127.0.0.1:5001".To<EndPoint>(),
};
CandleManager = new CandleManager(_trader);
_trader.NewSecurity += security =>
{
if (security.Id == "SBER@QJSIM" && CandleSeries == null)
{
CandleSeries = new CandleSeries(typeof(TimeFrameCandle), security, TimeSpan.FromSeconds(30));
this.GuiAsync(InitCart);
}
};
_trader.Connect();
}
public void InitCart()
{
Chart.ClearAreas();
Area = new ChartArea();
var yAxis = Area.YAxises.First();
yAxis.AutoRange = true;
Chart.IsAutoScroll = true;
Chart.ShowOverview = true;
Chart.AddArea(Area);
ChartCandleElement = new ChartCandleElement();
Chart.AddElement(Area, ChartCandleElement, CandleSeries);
}
public void DisplayNewMarketData(CandleSeries candleSeries, Candle candle)
{
IsRealtiem = candle.CloseTime + TimeSpan.FromSeconds(5) > DateTimeOffset.Now || IsRealtiem;
var chartDrawData = new ChartDrawData();
var group = chartDrawData.Group(candle.OpenTime);
group.Add(ChartCandleElement, candle);
if (IsRealtiem || candle.State == CandleStates.Finished)
Chart.Draw(chartDrawData);
}
private void StartButton_Click(object sender, RoutedEventArgs e)
{
CandleManager.Processing += DisplayNewMarketData;
CandleManager.Start(CandleSeries);
}
private void StopButton_Click(object sender, RoutedEventArgs e)
{
CandleManager.Stop(CandleSeries);
CandleManager.Processing -= DisplayNewMarketData;
InitCart();
}
protected override void OnClosing(CancelEventArgs e)
{
_trader.Dispose();
base.OnClosing(e);
}
}
}