Table of Contents

Class StorageHelper

Namespace
StockSharp.Algo.Storages
Assembly
StockSharp.Algo.dll

Extension class for storage.

public static class StorageHelper
Inheritance
StorageHelper
Inherited Members

Fields

SecurityBackslashSeparator

The delimiter, replacing '\' in path for instruments with id like USD\EUR. Is equal to '##BS##'.

public const string SecurityBackslashSeparator = "##BS##"

Field Value

string

SecurityColonSeparator

The delimiter, replacing ':' in the path for instruments with id like AA-CA:SPB@SPBEX. Is equal to '##COLON##'.

public const string SecurityColonSeparator = "##COLON##"

Field Value

string

SecurityFirstDot

The delimiter, replacing first '.' in the path for instruments with id like .AA-CA@SPBEX. Is equal to '##DOT##'.

public const string SecurityFirstDot = "##DOT##"

Field Value

string

SecurityQuestionSeparator

The delimiter, replacing '?' in the path for instruments with id like AA-CA?SPB@SPBEX. Is equal to '##QSTN##'.

public const string SecurityQuestionSeparator = "##QSTN##"

Field Value

string

SecuritySlashSeparator

The delimiter, replacing '/' in path for instruments with id like USD/EUR. Is equal to '__'.

public const string SecuritySlashSeparator = "__"

Field Value

string

SecurityStarSeparator

The delimiter, replacing '' in the path for instruments with id like C.BPO-@CANADIAN. Is equal to '##STAR##'.

public const string SecurityStarSeparator = "##STAR##"

Field Value

string

SecurityVerticalBarSeparator

The delimiter, replacing '|' in the path for instruments with id like AA-CA|SPB@SPBEX. Is equal to '##VBAR##'.

public const string SecurityVerticalBarSeparator = "##VBAR##"

Field Value

string

Methods

ClearDatesCache(IEnumerable<IMarketDataDrive>, Action<int, int>, Func<bool>, ILogReceiver)

Clear dates cache for storages.

public static void ClearDatesCache(this IEnumerable<IMarketDataDrive> drives, Action<int, int> updateProgress, Func<bool> isCancelled, ILogReceiver logsReceiver)

Parameters

drives IEnumerable<IMarketDataDrive>

Storage drives.

updateProgress Action<int, int>

The handler through which a progress change will be passed.

isCancelled Func<bool>

The handler which returns an attribute of search cancel.

logsReceiver ILogReceiver

Logs receiver.

Delete(IMarketDataStorage, DateTimeOffset?, DateTimeOffset?)

To delete market data from the storage for the specified time period.

public static bool Delete(this IMarketDataStorage storage, DateTimeOffset? from = null, DateTimeOffset? to = null)

Parameters

storage IMarketDataStorage

Market-data storage.

from DateTimeOffset?

The start time for data deleting. If the value is not specified, the data will be deleted starting from the date GetFromDate(IMarketDataStorage).

to DateTimeOffset?

The end time, up to which the data shall be deleted. If the value is not specified, data will be deleted up to the end date GetToDate(IMarketDataStorage), inclusive.

Returns

bool

true if data was deleted, false data not exist for the specified period.

DeleteById(ISecurityStorage, SecurityId)

Delete instrument by identifier.

public static void DeleteById(this ISecurityStorage securityStorage, SecurityId securityId)

Parameters

securityStorage ISecurityStorage

Securities meta info storage.

securityId SecurityId

Identifier.

DeleteById(ISecurityStorage, string)

Delete instrument by identifier.

public static void DeleteById(this ISecurityStorage securityStorage, string securityId)

Parameters

securityStorage ISecurityStorage

Securities meta info storage.

securityId string

Identifier.

FolderNameToSecurityId(string)

The inverse conversion from the SecurityIdToFolderName(string) method.

public static string FolderNameToSecurityId(this string folderName)

Parameters

folderName string

Directory name.

Returns

string

Security ID.

GetCandleArgs(IMarketDataDrive, StorageFormats, Type, SecurityId, DateTimeOffset?, DateTimeOffset?)

Get possible args for the specified candle type and instrument.

public static IEnumerable<object> GetCandleArgs(this IMarketDataDrive drive, StorageFormats format, Type candleType, SecurityId securityId = default, DateTimeOffset? from = null, DateTimeOffset? to = null)

Parameters

drive IMarketDataDrive

The storage (database, file etc.).

format StorageFormats

Format type.

candleType Type

The type of the message CandleMessage.

securityId SecurityId

Security ID.

from DateTimeOffset?

The initial date from which you need to get data.

to DateTimeOffset?

The final date by which you need to get data.

Returns

IEnumerable<object>

Possible args.

GetCandleMessageBuildableStorage(CandleBuilderProvider, IStorageRegistry, SecurityId, TimeSpan, IMarketDataDrive, StorageFormats)

To get the candles storage for the specified instrument. The storage will build candles from smaller time-frames if original time-frames is not exist.

public static IMarketDataStorage<CandleMessage> GetCandleMessageBuildableStorage(this CandleBuilderProvider provider, IStorageRegistry registry, SecurityId securityId, TimeSpan timeFrame, IMarketDataDrive drive = null, StorageFormats format = StorageFormats.Binary)

Parameters

provider CandleBuilderProvider

Candle builders provider.

registry IStorageRegistry

Market-data storage.

securityId SecurityId

Security ID.

timeFrame TimeSpan

Time-frame.

drive IMarketDataDrive

The storage. If a value is null, DefaultDrive will be used.

format StorageFormats

The format type. By default Binary is passed.

Returns

IMarketDataStorage<CandleMessage>

The candles storage.

GetCandleMessageStorage(IMessageStorageRegistry, Subscription, IMarketDataDrive, StorageFormats)

To get the candles storage for the specified instrument.

public static IMarketDataStorage<CandleMessage> GetCandleMessageStorage(this IMessageStorageRegistry registry, Subscription subscription, IMarketDataDrive drive = null, StorageFormats format = StorageFormats.Binary)

Parameters

registry IMessageStorageRegistry

IMessageStorageRegistry.

subscription Subscription

Subscription.

drive IMarketDataDrive

The storage.

format StorageFormats

The format type.

Returns

IMarketDataStorage<CandleMessage>

The candles storage.

GetDates(IMarketDataStorage, DateTime?, DateTime?)

To get all dates for stored market data for the specified range.

public static IEnumerable<DateTime> GetDates(this IMarketDataStorage storage, DateTime? from, DateTime? to)

Parameters

storage IMarketDataStorage

Market-data storage.

from DateTime?

The range start time. If the value is not specified, data will be loaded from the start date GetFromDate(IMarketDataStorage).

to DateTime?

The range end time. If the value is not specified, data will be loaded up to the end date GetToDate(IMarketDataStorage), inclusive.

Returns

IEnumerable<DateTime>

All available data within the range.

GetFromDate(IMarketDataStorage)

To get the start date for market data, stored in the storage.

public static DateTime? GetFromDate(this IMarketDataStorage storage)

Parameters

storage IMarketDataStorage

Market-data storage.

Returns

DateTime?

The start date. If the value is not initialized, the storage is empty.

GetRange(IMarketDataStorage, DateTimeOffset?, DateTimeOffset?)

Get available date range for the specified storage.

public static Range<DateTimeOffset> GetRange(this IMarketDataStorage storage, DateTimeOffset? from, DateTimeOffset? to)

Parameters

storage IMarketDataStorage

Storage.

from DateTimeOffset?

The initial date from which you need to get data.

to DateTimeOffset?

The final date by which you need to get data.

Returns

Range<DateTimeOffset>

Date range

GetSnapshotStorage(SnapshotRegistry, DataType)

To get the snapshot storage.

public static ISnapshotStorage GetSnapshotStorage(this SnapshotRegistry registry, DataType dataType)

Parameters

registry SnapshotRegistry

Snapshot storage registry.

dataType DataType

Data type info.

Returns

ISnapshotStorage

The snapshot storage.

GetStorage(IStorageRegistry, Security, DataType, IMarketDataDrive, StorageFormats)

To get the market-data storage.

public static IMarketDataStorage GetStorage(this IStorageRegistry registry, Security security, DataType dataType, IMarketDataDrive drive = null, StorageFormats format = StorageFormats.Binary)

Parameters

registry IStorageRegistry

Market-data storage.

security Security

Security.

dataType DataType

Data type info.

drive IMarketDataDrive

The storage. If a value is null, DefaultDrive will be used.

format StorageFormats

The format type. By default Binary is passed.

Returns

IMarketDataStorage

Market-data storage.

GetStorage(IStorageRegistry, SecurityId, DataType, IMarketDataDrive, StorageFormats)

To get the market-data storage.

public static IMarketDataStorage GetStorage(this IStorageRegistry registry, SecurityId securityId, DataType dataType, IMarketDataDrive drive = null, StorageFormats format = StorageFormats.Binary)

Parameters

registry IStorageRegistry

Market-data storage.

securityId SecurityId

Security ID.

dataType DataType

Data type info.

drive IMarketDataDrive

The storage. If a value is null, DefaultDrive will be used.

format StorageFormats

The format type. By default Binary is passed.

Returns

IMarketDataStorage

Market-data storage.

GetTimeFrameCandleMessageStorage(IMessageStorageRegistry, SecurityId, TimeSpan, IMarketDataDrive, StorageFormats)

To get the candles storage for the specified instrument.

public static IMarketDataStorage<CandleMessage> GetTimeFrameCandleMessageStorage(this IMessageStorageRegistry registry, SecurityId securityId, TimeSpan arg, IMarketDataDrive drive = null, StorageFormats format = StorageFormats.Binary)

Parameters

registry IMessageStorageRegistry

IMessageStorageRegistry.

securityId SecurityId

Security ID.

arg TimeSpan

Candle arg.

drive IMarketDataDrive

The storage.

format StorageFormats

The format type.

Returns

IMarketDataStorage<CandleMessage>

The candles storage.

GetToDate(IMarketDataStorage)

To get the end date for market data, stored in the storage.

public static DateTime? GetToDate(this IMarketDataStorage storage)

Parameters

storage IMarketDataStorage

Market-data storage.

Returns

DateTime?

The end date. If the value is not initialized, the storage is empty.

IsNetworkPath(string)

Determines the specified path is network.

public static bool IsNetworkPath(this string path)

Parameters

path string

Path.

Returns

bool

Check result.

LoadMessages(StorageCoreSettings, CandleBuilderProvider, MarketDataMessage, Action<Message>)

Load messages.

public static DateTimeOffset? LoadMessages(this StorageCoreSettings settings, CandleBuilderProvider candleBuilderProvider, MarketDataMessage subscription, Action<Message> newOutMessage)

Parameters

settings StorageCoreSettings

Storage settings.

candleBuilderProvider CandleBuilderProvider

Candle builders provider.

subscription MarketDataMessage

Market-data message (uses as a subscribe/unsubscribe in outgoing case, confirmation event in incoming case).

newOutMessage Action<Message>

New message event.

Returns

DateTimeOffset?

Last date.

Load<TMessage>(IMarketDataStorage<TMessage>, DateTimeOffset?, DateTimeOffset?)

To create an iterative loader of market data for the time range.

public static IEnumerable<TMessage> Load<TMessage>(this IMarketDataStorage<TMessage> storage, DateTimeOffset? from = null, DateTimeOffset? to = null) where TMessage : Message

Parameters

storage IMarketDataStorage<TMessage>

Market-data storage.

from DateTimeOffset?

The start time for data loading. If the value is not specified, data will be loaded from the starting time GetFromDate(IMarketDataStorage).

to DateTimeOffset?

The end time for data loading. If the value is not specified, data will be loaded up to the GetToDate(IMarketDataStorage) date, inclusive.

Returns

IEnumerable<TMessage>

The iterative loader of market data.

Type Parameters

TMessage

Data type.

SecurityIdToFolderName(string)

To convert the instrument identifier into the folder name, replacing reserved symbols.

public static string SecurityIdToFolderName(this string id)

Parameters

id string

Security ID.

Returns

string

Directory name.

SetAdapter<TKey>(IMappingMessageAdapterProvider<TKey>, TKey, IMessageAdapter)

Make association with adapter.

public static bool SetAdapter<TKey>(this IMappingMessageAdapterProvider<TKey> provider, TKey key, IMessageAdapter adapter)

Parameters

provider IMappingMessageAdapterProvider<TKey>

Message adapter's provider interface.

key TKey

Key.

adapter IMessageAdapter

Adapter.

Returns

bool

true if the association is successfully changed, otherwise, false.

Type Parameters

TKey