← Zurück

Проблема преобразования TimeSpan - AlfaTimeFrames

Программный код:

public void Test() { CandleManager candleManager = new CandleManager(trader);

        // 5 minute candles
        CandleSeries series = new CandleSeries(typeof(TimeFrameCandle), security, TimeSpan.FromMinutes(5));
        series.ProcessCandle += series_ProcessCandle;
        candleManager.Processing += candleManager_Processing;

        candleManager.Start(series);
    }

    void series_ProcessCandle(Candle obj)
    {
        Logger.WriteLine("Process candle");
    }

    void candleManager_Processing(CandleSeries arg1, Candle arg2)
    {
        Logger.WriteLine("Received Processing event");
    }

Код ошибки:

Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'System.TimeSpan' to type 'StockSharp.AlfaDirect.AlfaTimeFrames'. at StockSharp.AlfaDirect.AlfaTrader.#=qjbXuGHh73XvrWZicy6gOKXr2Dom0efIFR9MSjpJMLe0=(SynchronizedDictionary2 #=qA5mbLCf6AEYY2ZjSKZfmqw==) at Ecng.Collections.CollectionHelper.SyncDo[TCollection](TCollection collection, Action1 action) at StockSharp.AlfaDirect.AlfaTrader.#=qC5NNrqRcgxVSSeVdRzYPn46I7MwkMp1XS5d1hUpptZw=() at Ecng.Common.ThreadingHelper.<>c__DisplayClass1.<Timer>b__0(Object s) at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserv eSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx ) at System.Threading.TimerQueueTimer.CallCallback() at System.Threading.TimerQueueTimer.Fire() at System.Threading.TimerQueue.FireNextTimers() at System.Threading.TimerQueue.AppDomainTimerCallback()

War dieses Thema hilfreich?

Thema teilen

Kommentare (4)

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

esper
esper

Чтобы указать таймфрейм для альфы, необходимо использовать AlfaTimeFrames.

zhuravl
zhuravl Autor

В этом случае выдается

Unhandled Exception: System.ArgumentException: Параметр свечки 00:05:00 не правильный.

zhuravl
zhuravl Autor

к удивлению код:

TimeSpan span = TimeSpan.FromMinutes(5); StockSharp.AlfaDirect.AlfaTimeFrames frame = (AlfaTimeFrames)span; TimeSpan span2 = (TimeSpan)frame;

Console.WriteLine(span); Console.WriteLine(frame); Console.WriteLine(span2); работает нормально

esper
esper

Напишите мне в скайп, который в профиле.