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


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


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

Цитата:
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=(SynchronizedDictionary`2 #=qA5mbLCf6AEYY2ZjSKZfmqw==)
at Ecng.Collections.CollectionHelper.SyncDo[TCollection](TCollection collection, Action`1 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()

Теги:


Спасибо:


esper

Фотография
Дата: 11.04.2013
Ответить


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

zhuravl

Фотография
Дата: 11.04.2013
Ответить


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

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

zhuravl

Фотография
Дата: 11.04.2013
Ответить


к удивлению код:
Цитата:
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

Фотография
Дата: 11.04.2013
Ответить


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


Добавить файлы через драг-н-дроп, , или вставить из буфера обмена.

loading
clippy