← Zurück

Несколько ошибок

Версия S# 4.1.11

  1. Не работает переподключение. ReConnectionManager подписывается на событие ConnectionError. Но Директ при рассоединении это событие не выдает, ни после тайм-аута, при исчезновении инета, ни после отключения после вечерки. Сколько ни старался, получить его не удалось. Поэтому, думаю, можно добавить строку ошибки подключения в обработчике ConnectionChanged в AlfaWrapper.cs:

     case eConnectionState.Disconnected:
       Disconnected.SafeInvoke();
       <mark>ConnectionError.SafeInvoke(new Exception("Error eConnectionState: " + state));</mark>
       break;
    

    private void ConnectionChanged(eConnectionState state)
    {
      switch (state)
      {
        case eConnectionState.Connected:
          Connected.SafeInvoke();
          break;

        case eConnectionState.Disconnected:
          Disconnected.SafeInvoke();
          ConnectionError.SafeInvoke(new Exception("Error eConnectionState: " + state));
          break;

        default:
          ConnectionError.SafeInvoke(new Exception("Error eConnectionState: " + state));
          break;
      }
    }

Может не совсем корректно, но зато переподключение будет работать.

  1. При старте экспорта, сразу выходит исключение:

System.ArgumentNullException: Значение не может быть неопределенным.
Имя параметра: board
   в StockSharp.Algo.SecurityIdGenerator.GenerateId(String secCode, String secClass, ExchangeBoard board)
   в StockSharp.AlfaDirect.AlfaTrader.#=qTmHoaiW0DvdZTePTIZGmQ8DDHnYjgo8cP$cmsoi4fhs=.#=q_tiMlW0BJNgFwbvijs06AWdy2b_Pnki6x7YDYCvObJU=()
   в StockSharp.Algo.BaseTrader.ProcessEvents(Action handler)

Может не успевает к тому моменту заполниться поле ExchangeBoard у инструмента?

  1. Появляется исключение при остановке экспорта:

StockSharp.AlfaDirect.AlfaException не обработано
  Message=Код ошибки stcClientError Сообщение Table  not found in subscribed list
  Source=StockSharp.AlfaDirect
  StackTrace:
       в #=qAN7$6C1UJwE2Ht4z43DH6Od48Np58bQd2DF6YK82goHtiipqzCT80po2cMgH3GLR.#=qG9EtOYj8RDoYvpDK3iloH$6qMDpPyMK$77ZPyYIR6hY=(String #=qx0voBheG$Mkqo4H0CV7tqA==, String #=qPdOHw1mx2fSUNnuJYBvg5A==)
       в #=qAN7$6C1UJwE2Ht4z43DH6Od48Np58bQd2DF6YK82goHtiipqzCT80po2cMgH3GLR.#=qLvOfJKmTVJjBrdmpR$NYeAkX4UBSVudjn8RGel_2zro=()
       в StockSharp.AlfaDirect.AlfaTrader.StopExport()
       в StockSharp.Algo.Testing.RealTimeEmulationTrader`1.StopExport()
       в TrendWalker.MainWindow.Stop() в D:\WORK\PROG\Projects\StockSharp\TrendWalker\4.1.11\WithMarketOrders\TrendWalker\MainWindow.xaml.cs:строка 278
       в TrendWalker.MainWindow.Connect_Click(Object sender, RoutedEventArgs e) в D:\WORK\PROG\Projects\StockSharp\TrendWalker\4.1.11\WithMarketOrders\TrendWalker\MainWindow.xaml.cs:строка 379
       в 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)
       в MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       в System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       в MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       в MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       в System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       в System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       в System.Windows.Application.RunDispatcher(Object ignore)
       в System.Windows.Application.RunInternal(Window window)
       в System.Windows.Application.Run(Window window)
       в System.Windows.Application.Run()
       в TrendWalker.App.Main() в D:\WORK\PROG\Projects\StockSharp\TrendWalker\4.1.11\WithMarketOrders\TrendWalker\obj\Debug\App.g.cs:строка 0
       в System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       в System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       в Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       в System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       в System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Если в коде вызываю RegisterSecurity, то в окне Debug:


RegisterTable: fin_info. Fields: paper_no, ANSI_name, mat_date, status, p_code..........
RegisterTable: msg Table subscribed succesefully

UnRegisterTable: fin_info, where: 
UnRegisterTable: fin_info, where: 

Т.е. отписка от fin_info идет два раза, на второй раз выдается исключение. Если не подписываться на инструмент - RegisterSecurity, то идет отписка не зарегистрированного инструмента. В обоих случаях выпадает исключение тут (ф-я StopExport AlfaTrader.cs):


      if (_tradeSubscribers.IsEmpty())
      {
        Wrapper.UnRegisterSecurity();
      }

Первая отписка, как я понял, происходит в BaseTrader.cs в ф-ии StopExport. В нем идет вызов _subscriptionManager.Stop()


            public void Stop()
            {
                RegisteredSecurities.ForEach(_trader.UnRegisterSecurity);
                RegisteredMarketDepths.ForEach(_trader.UnRegisterMarketDepth);
                RegisteredOrderLogs.ForEach(_trader.UnRegisterOrderLog);
                RegisteredTrades.ForEach(_trader.UnRegisterTrades);
                RegisteredPortfolios.ForEach(_trader.UnRegisterPortfolio);
            }

Может тогда стоит убрать следующий код (ф-я StopExport AlfaTrader.cs):


      if(!_tradeSubscribers.IsEmpty())
      {
        Wrapper.UnRegisterTrades();
      }

      if (_tradeSubscribers.IsEmpty())
      {
        Wrapper.UnRegisterSecurity();
      }

Если, конечно, я правильно понимаю. Все равно в BaseTrader StopExport мы отписываемся от всего, на что были подписаны (стаканы, инструменты, ордер-лог, все сделки, портфели)

War dieses Thema hilfreich?

Thema teilen

Kommentare (0)

Anmelden oder Konto erstellen, Melden Sie sich an oder registrieren Sie sich, um einen Kommentar zu hinterlassen

Noch keine Kommentare. Seien Sie der Erste!