Table of Contents

Class BaseHydraTask

Namespace
StockSharp.Hydra.Core
Assembly
StockSharp.Hydra.Core.dll

Base class for a Hydra task.

public abstract class BaseHydraTask : BaseLogReceiver, IHydraTask, ILogReceiver, ILogSource, IDisposable, ICloneable<IHydraTask>, ICloneable, IPersistable, INotifyPropertyChanged, IScheduledTask
Inheritance
BaseHydraTask
Implements
Derived
Inherited Members
Extension Methods

Remarks

Initializes BaseHydraTask.

Constructors

BaseHydraTask(Hydra)

Base class for a Hydra task.

protected BaseHydraTask(Hydra hydra)

Parameters

hydra Hydra

Hydra instance.

Remarks

Initializes BaseHydraTask.

Properties

AllSecurity

Special "All securities" entry.

[Browsable(false)]
public HydraTaskSecurity AllSecurity { get; }

Property Value

HydraTaskSecurity

CanTestConnect

[Browsable(false)]
public virtual bool CanTestConnect { get; }

Property Value

bool

CandlesBuildFrom

Supported Level1 fields that can be used as candles build source.

[Browsable(false)]
public virtual IEnumerable<Level1Fields> CandlesBuildFrom { get; }

Property Value

IEnumerable<Level1Fields>

DependFrom

Task that must be executed before the current one starts.

[Display(ResourceType = typeof(LocalizedStrings), Name = "Dependency", Description = "DependencyDesc", GroupName = "General", Order = 105)]
[Browsable(false)]
public IHydraTask DependFrom { get; set; }

Property Value

IHydraTask

Drive

Market data drive where final files in StockSharp format will be stored.

[Display(ResourceType = typeof(LocalizedStrings), Name = "DataDirectory", Description = "DataDirectoryDesc", GroupName = "General", Order = 103)]
public IMarketDataDrive Drive { get; set; }

Property Value

IMarketDataDrive

EntityRegistry

Trading objects storage.

protected static IEntityRegistry EntityRegistry { get; }

Property Value

IEntityRegistry

ExchangeInfoProvider

Exchanges and boards provider.

protected static IExchangeInfoProvider ExchangeInfoProvider { get; }

Property Value

IExchangeInfoProvider

Hydra

Hydra instance.

[Browsable(false)]
protected Hydra Hydra { get; }

Property Value

Hydra

Icon

Icon URI for visual representation.

[Browsable(false)]
public Uri Icon { get; }

Property Value

Uri

InStopMode

State in stop mode.

protected bool InStopMode { get; }

Property Value

bool

Interval

Work interval.

[Display(ResourceType = typeof(LocalizedStrings), Name = "WorkInterval", Description = "WorkIntervalDot", GroupName = "General", Order = 102)]
[TimeSpanEditor(Mask = TimeSpanEditorMask.Days|TimeSpanEditorMask.Hours|TimeSpanEditorMask.Minutes|TimeSpanEditorMask.Seconds)]
[BasicSetting]
public TimeSpan Interval { get; set; }

Property Value

TimeSpan

IsDefault

Does settings contain default values.

[Browsable(false)]
public bool IsDefault { get; set; }

Property Value

bool

IsEnabled

Is task enabled.

[Display(ResourceType = typeof(LocalizedStrings), Name = "Active", Description = "TaskOn", GroupName = "General", Order = 100)]
[Browsable(false)]
public bool IsEnabled { get; set; }

Property Value

bool

MaxErrorCount

Maximum number of errors after which the task will be stopped. By default equals 0 meaning the count is ignored.

[Display(ResourceType = typeof(LocalizedStrings), Name = "MaxErrors", Description = "MaxErrorsDesc", GroupName = "General", Order = 106)]
public int MaxErrorCount { get; set; }

Property Value

int

Name

The source name.

[Browsable(false)]
public override string Name { get; }

Property Value

string

NativeIdStorage

System identifiers storage.

protected static INativeIdStorage NativeIdStorage { get; }

Property Value

INativeIdStorage

RemoteChannel

Remote channel where notifications will be sent.

[Display(ResourceType = typeof(LocalizedStrings), Name = "Notification", Description = "NotificationChannel", GroupName = "Remotely", Order = 1001)]
public ITelegramChannel RemoteChannel { get; set; }

Property Value

ITelegramChannel

RemoteControl

Allow remote control for the task.

[Display(ResourceType = typeof(LocalizedStrings), Name = "Enabled", Description = "RemoteControl", GroupName = "Remotely", Order = 1000)]
public bool RemoteControl { get; set; }

Property Value

bool

RemoteLogLevel

Remote log levels translated into RemoteChannel.

[Display(ResourceType = typeof(LocalizedStrings), Name = "LogLevel", Description = "LogLevelDot", GroupName = "Remotely", Order = 1002)]
public LogLevels RemoteLogLevel { get; set; }

Property Value

LogLevels

Resume

Resume from last timestamp.

[Display(ResourceType = typeof(LocalizedStrings), Name = "Continue", Description = "ResumeFromLastDate", GroupName = "General", Order = 100)]
[BasicSetting]
public bool Resume { get; set; }

Property Value

bool

Securities

Securities associated with the task.

[Browsable(false)]
public HydraTaskSecurity[] Securities { get; set; }

Property Value

HydraTaskSecurity[]

SecurityLookupSupportType

Security lookup support type.

[Browsable(false)]
public virtual SecurityLookupSupportTypes SecurityLookupSupportType { get; }

Property Value

SecurityLookupSupportTypes

State

Current task state.

[Browsable(false)]
public TaskStates State { get; }

Property Value

TaskStates

StorageFormat

Storage format.

[Display(ResourceType = typeof(LocalizedStrings), Name = "Format", Description = "DataFormat", GroupName = "General", Order = 104)]
public StorageFormats StorageFormat { get; set; }

Property Value

StorageFormats

StorageRegistry

Market data storage.

protected static IStorageRegistry StorageRegistry { get; }

Property Value

IStorageRegistry

SupportedDataTypes

Supported data types.

[Browsable(false)]
public abstract IEnumerable<DataType> SupportedDataTypes { get; }

Property Value

IEnumerable<DataType>

SupportedDepths

Supported order book depths.

[Browsable(false)]
public virtual IEnumerable<int> SupportedDepths { get; }

Property Value

IEnumerable<int>

SupportedLevel1Fields

Supported Level1 fields.

[Browsable(false)]
[Display(ResourceType = typeof(LocalizedStrings), Name = "Level1", Description = "Level1FieldsDesc", GroupName = "General", Order = 107)]
[ItemsSource(typeof(Level1Fields))]
[EditorExtension(ShowSelectedItemsCount = true)]
public virtual IEnumerable<Level1Fields> SupportedLevel1Fields { get; set; }

Property Value

IEnumerable<Level1Fields>

Title

Task title.

[Display(ResourceType = typeof(LocalizedStrings), Name = "Header", Description = "TeskHeader", GroupName = "General", Order = 108)]
[BasicSetting]
public string Title { get; set; }

Property Value

string

Validation

Validation behavior.

[Display(ResourceType = typeof(LocalizedStrings), Name = "Validation", Description = "Validation", GroupName = "General", Order = 110)]
public TaskValidations Validation { get; set; }

Property Value

TaskValidations

WorkingTime

Working schedule.

[Display(ResourceType = typeof(LocalizedStrings), Name = "WorkingTime", Description = "WorkingHours", GroupName = "General", Order = 110)]
public WorkingTime WorkingTime { get; set; }

Property Value

WorkingTime

Methods

CanProcess()

Determines whether task can continue in OnProcess().

protected bool CanProcess()

Returns

bool

True if continue; otherwise false.

Clone()

Create a copy.

public IHydraTask Clone()

Returns

IHydraTask

Copy.

FinalizeTask()

Handle task finalization.

protected virtual void FinalizeTask()

GetSecurity(SecurityId)

Get security by identifier.

protected Security GetSecurity(SecurityId securityId)

Parameters

securityId SecurityId

Security identifier.

Returns

Security

Security.

GetWorkingSecurities(IMarketDataDrive)

Get the list of securities that the source will work with.

protected IEnumerable<HydraTaskSecurity> GetWorkingSecurities(IMarketDataDrive drive)

Parameters

drive IMarketDataDrive

Returns

IEnumerable<HydraTaskSecurity>

Securities.

HandleError(Exception)

Handle error.

protected void HandleError(Exception error)

Parameters

error Exception

Error.

Init(Guid)

Initialize task.

public void Init(Guid id)

Parameters

id Guid

Task identifier.

IsAllDownloadingSupported(DataType)

Determines whether downloading for all securities is supported for the specified dataType.

public virtual bool IsAllDownloadingSupported(DataType dataType)

Parameters

dataType DataType

Data type info.

Returns

bool

Check result.

Load(SettingsStorage)

Load settings.

public override void Load(SettingsStorage storage)

Parameters

storage SettingsStorage

Settings storage.

NotifyPropertyChanged(string)

Invoke PropertyChanged event.

protected void NotifyPropertyChanged(string name = null)

Parameters

name string

Property name

OnProcess()

Perform task work.

protected virtual TimeSpan OnProcess()

Returns

TimeSpan

The minimum interval after which the task should run again.

OnStarting()

Action on starting the data loading.

protected virtual void OnStarting()

OnStopped()

Action on stopping the data loading.

protected virtual void OnStopped()

RaiseDataLoaded(HydraTaskSecurity, DataType, DateTimeOffset?, int)

Raise DataLoaded with one timestamp and count.

protected void RaiseDataLoaded(HydraTaskSecurity security, DataType dataType, DateTimeOffset? time, int count)

Parameters

security HydraTaskSecurity

Security.

dataType DataType

Data type.

time DateTimeOffset?

Last data time.

count int

Items count.

RaiseStarted()

Raise Started event.

protected void RaiseStarted()

RaiseStopped()

Raise Stopped event.

protected void RaiseStopped()

Refresh(ISecurityStorage, SecurityLookupMessage, Action<Security>, Action<Exception>, Func<bool>)

Download new securities.

public virtual void Refresh(ISecurityStorage securityStorage, SecurityLookupMessage criteria, Action<Security> newSecurity, Action<Exception> lookupError, Func<bool> isCancelled)

Parameters

securityStorage ISecurityStorage

Securities meta info storage.

criteria SecurityLookupMessage

Message security lookup for specified criteria.

newSecurity Action<Security>

The handler through which a new instrument will be passed.

lookupError Action<Exception>

Lookup error handler.

isCancelled Func<bool>

The handler returning whether to cancel the search.

Save(SettingsStorage)

Save settings.

public override void Save(SettingsStorage storage)

Parameters

storage SettingsStorage

Settings storage.

SaveBoardStates(IEnumerable<BoardStateMessage>)

Save boards state to storage.

protected void SaveBoardStates(IEnumerable<BoardStateMessage> states)

Parameters

states IEnumerable<BoardStateMessage>

Boards state.

SaveCandles(Security, IEnumerable<CandleMessage>)

Save candles to storage.

protected void SaveCandles(Security security, IEnumerable<CandleMessage> candles)

Parameters

security Security

Security.

candles IEnumerable<CandleMessage>

Candles.

SaveDepths(Security, IEnumerable<QuoteChangeMessage>)

Save order books to storage.

protected void SaveDepths(Security security, IEnumerable<QuoteChangeMessage> depths)

Parameters

security Security

Security.

depths IEnumerable<QuoteChangeMessage>

Order books.

SaveLevel1Changes(Security, IEnumerable<Level1ChangeMessage>)

Save Level1 changes to storage.

protected void SaveLevel1Changes(Security security, IEnumerable<Level1ChangeMessage> messages)

Parameters

security Security

Security.

messages IEnumerable<Level1ChangeMessage>

Changes.

SaveNews(IEnumerable<NewsMessage>)

Save news to storage.

protected void SaveNews(IEnumerable<NewsMessage> news)

Parameters

news IEnumerable<NewsMessage>

News messages.

SaveOrderLog(Security, IEnumerable<ExecutionMessage>)

Save order log to storage.

protected void SaveOrderLog(Security security, IEnumerable<ExecutionMessage> items)

Parameters

security Security

Security.

items IEnumerable<ExecutionMessage>

Order log.

SavePositionChanges(Security, IEnumerable<PositionChangeMessage>)

Save position changes to storage.

protected void SavePositionChanges(Security security, IEnumerable<PositionChangeMessage> messages)

Parameters

security Security

Security.

messages IEnumerable<PositionChangeMessage>

Changes.

SaveSecurity(Security)

Save security if it is absent in Securities.

protected void SaveSecurity(Security security)

Parameters

security Security

Security.

SaveTicks(Security, IEnumerable<ExecutionMessage>)

Save tick trades to storage.

protected void SaveTicks(Security security, IEnumerable<ExecutionMessage> ticks)

Parameters

security Security

Security.

ticks IEnumerable<ExecutionMessage>

Tick trades.

SaveTransactions(Security, IEnumerable<ExecutionMessage>)

Save transactions to storage.

protected void SaveTransactions(Security security, IEnumerable<ExecutionMessage> transactions)

Parameters

security Security

Security.

transactions IEnumerable<ExecutionMessage>

Transactions.

Start()

Start.

public void Start()

Stop()

Stop.

public void Stop()

StopSubscription(Security, DataType)

Stop subscription for the specified Security and DataType.

protected virtual void StopSubscription(Security security, DataType dataType)

Parameters

security Security

Security

dataType DataType

DataType

TestConnect(Action<Exception>)

Verify connection.

public virtual void TestConnect(Action<Exception> connectionChanged)

Parameters

connectionChanged Action<Exception>

Connection changed callback.

Events

DataLoaded

Raised when market data has been loaded.

public event Action<HydraTaskSecurity, DataType, DateTimeOffset?, int, IEnumerable<Message>> DataLoaded

Event Type

Action<HydraTaskSecurity, DataType, DateTimeOffset?, int, IEnumerable<Message>>

PropertyChanged

public event PropertyChangedEventHandler PropertyChanged

Event Type

PropertyChangedEventHandler

SecuritySaved

Raised when a Security is saved.

public event Action<Security> SecuritySaved

Event Type

Action<Security>

Started

Raised when the task is started.

public event Action<IHydraTask> Started

Event Type

Action<IHydraTask>

Stopped

Raised when the task is stopped.

public event Action<IHydraTask> Stopped

Event Type

Action<IHydraTask>