При построении ExpressionIndexSecurity и WeightedIndexSecurity вылетает ошибка
Код для WeightedIndexSecurity
Код
_indexInstr1 = new WeightedIndexSecurity() { Board = ExchangeBoard.Forts, Id = "IndexInstr" };
_indexInstr1.Weights.Add(_instr1.Id.ToSecurityId(), 1m);
_indexInstr1.Weights.Add(_instr2.Id.ToSecurityId(), -1m);
var series2 = new CandleSeries(typeof(TimeFrameCandle), _indexInstr1, TimeSpan.FromMinutes(5))
{
BuildCandlesMode = BuildCandlesModes.Build,
};
_candleManager.Start(series2);
Код для ExpressionIndexSecurity
Код
_indexInstr3 = new ExpressionIndexSecurity
{
Id = "IndexInstr@FORTS",
Expression = "SBER@QJSIM*2",
Board = ExchangeBoard.Forts,
};
var series3 = new CandleSeries(typeof(TimeFrameCandle), _indexInstr3, TimeSpan.FromMinutes(5))
{
BuildCandlesMode = BuildCandlesModes.Build
};
_candleManager.Start(series2);
Exception и StackTrace
Microsoft.Practices.ServiceLocation.ActivationException was unhandled by user code
HResult=-2146233088
Message=Activation error occurred while trying to get instance of type ISecurityProvider, key ""
Source=Ecng.Configuration
StackTrace:
в Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
в Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService]()
в Ecng.Configuration.ConfigManager.GetService[T]()
в StockSharp.Algo.Candles.CandleManager.Start(CandleSeries series, DateTimeOffset from, DateTimeOffset to)
в StockSharp.Algo.Candles.CandleHelper.Start(ICandleManager manager, CandleSeries series)
в SampleQuikCandles.MainWindow.ShowChartClick(Object sender, RoutedEventArgs e) в C:\Users\Ivan\Downloads\StockSharp_4.3.23_ru (2)\Samples\Quik\SampleQuikCandles\MainWindow.xaml.cs:строка 230
в System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
в System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
в System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
в System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
в System.Windows.Controls.Primitives.ButtonBase.OnClick()
в System.Windows.Controls.Button.OnClick()
в System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
в System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
в System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
в System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
в System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
в System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
в System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
в System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
в System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
в System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
в System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
в System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
в System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
в System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
в System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
в System.Windows.Input.InputManager.ProcessStagingArea()
в System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
в System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
в System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
в System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
в System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
в MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
в MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
в System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
InnerException:
HResult=-2146233088
Message=Resolution of the dependency failed, type = "StockSharp.BusinessEntities.ISecurityProvider", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, StockSharp.BusinessEntities.ISecurityProvider, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:
Resolving StockSharp.BusinessEntities.ISecurityProvider,(none)
Source=Ecng.Configuration
TypeRequested=ISecurityProvider
StackTrace:
в Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
в Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
в Microsoft.Practices.Unity.UnityServiceLocator.DoGetInstance(Type serviceType, String key)
в Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
InnerException:
HResult=-2146233079
Message=The current type, StockSharp.BusinessEntities.ISecurityProvider, is an interface and cannot be constructed. Are you missing a type mapping?
Source=Ecng.Configuration
StackTrace:
в Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForAttemptingToConstructInterface(IBuilderContext context)
в BuildUp_StockSharp.BusinessEntities.ISecurityProvider(IBuilderContext )
в Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
в Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
в Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
в Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
InnerException:
Все пробовал на примере SampleQuikCandles изменил метод ShowChartClick
Код
private void ShowChartClick(object sender, RoutedEventArgs e)
{
var security = SelectedSecurity;
Security _instr1 = _trader.Securities.FirstOrDefault((x) => x.Id == "SBER@QJSIM");
Security _instr2 = _trader.Securities.FirstOrDefault((x) => x.Id == "LKOH@QJSIM");
_indexInstr1 = new WeightedIndexSecurity() { Board = ExchangeBoard.Forts, Id = "IndexInstr" };
_indexInstr1.Weights.Add(_instr1.Id.ToSecurityId(), 1m);
_indexInstr1.Weights.Add(_instr2.Id.ToSecurityId(), -1m);
_indexInstr3 = new ExpressionIndexSecurity
{
Id = "IndexInstr@FORTS",
Expression = "SBER@QJSIM*2",
Board = ExchangeBoard.Forts,
};
var series1 = new CandleSeries(typeof(TimeFrameCandle), security, TimeSpan.FromMinutes(5))
{
BuildCandlesMode = BuildCandlesModes.Build,
};
var series2 = new CandleSeries(typeof(TimeFrameCandle), _indexInstr1, TimeSpan.FromMinutes(5))
{
BuildCandlesMode = BuildCandlesModes.Build,
};
var series3 = new CandleSeries(typeof(TimeFrameCandle), _indexInstr3, TimeSpan.FromMinutes(5))
{
BuildCandlesMode = BuildCandlesModes.Build
};
_chartWindows.SafeAdd(series1, key =>
{
var wnd = new ChartWindow();
wnd.MakeHideable();
var area = new ChartArea();
wnd.Chart.Areas.Add(area);
var candlesElem = new ChartCandleElement();
area.Elements.Add(candlesElem);
return wnd;
}).Show();
_candleManager.Start(series2);
}
Как правильно построить индекс?