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
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
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
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
SecuritySlashSeparator
The delimiter, replacing '/' in path for instruments with id like USD/EUR. Is equal to '__'.
public const string SecuritySlashSeparator = "__"
Field Value
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
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
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
ILogReceiverLogs 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
IMarketDataStorageMarket-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
DeleteById(ISecurityStorage, SecurityId)
Delete instrument by identifier.
public static void DeleteById(this ISecurityStorage securityStorage, SecurityId securityId)
Parameters
securityStorage
ISecurityStorageSecurities meta info storage.
securityId
SecurityIdIdentifier.
DeleteById(ISecurityStorage, string)
Delete instrument by identifier.
public static void DeleteById(this ISecurityStorage securityStorage, string securityId)
Parameters
securityStorage
ISecurityStorageSecurities meta info storage.
securityId
stringIdentifier.
FolderNameToSecurityId(string)
The inverse conversion from the SecurityIdToFolderName(string) method.
public static string FolderNameToSecurityId(this string folderName)
Parameters
folderName
stringDirectory 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
IMarketDataDriveThe storage (database, file etc.).
format
StorageFormatsFormat type.
candleType
TypeThe type of the message CandleMessage.
securityId
SecurityIdSecurity 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
CandleBuilderProviderCandle builders provider.
registry
IStorageRegistryMarket-data storage.
securityId
SecurityIdSecurity ID.
timeFrame
TimeSpanTime-frame.
drive
IMarketDataDriveThe storage. If a value is null, DefaultDrive will be used.
format
StorageFormatsThe 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
IMessageStorageRegistrysubscription
Subscriptiondrive
IMarketDataDriveThe storage.
format
StorageFormatsThe 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
IMarketDataStorageMarket-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
IMarketDataStorageMarket-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
IMarketDataStorageStorage.
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
SnapshotRegistrySnapshot storage registry.
dataType
DataTypeData 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
IStorageRegistryMarket-data storage.
security
SecuritySecurity.
dataType
DataTypeData type info.
drive
IMarketDataDriveThe storage. If a value is null, DefaultDrive will be used.
format
StorageFormatsThe 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
IStorageRegistryMarket-data storage.
securityId
SecurityIdSecurity ID.
dataType
DataTypeData type info.
drive
IMarketDataDriveThe storage. If a value is null, DefaultDrive will be used.
format
StorageFormatsThe 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
IMessageStorageRegistrysecurityId
SecurityIdSecurity ID.
arg
TimeSpanCandle arg.
drive
IMarketDataDriveThe storage.
format
StorageFormatsThe 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
IMarketDataStorageMarket-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
stringPath.
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
StorageCoreSettingsStorage settings.
candleBuilderProvider
CandleBuilderProviderCandle builders provider.
subscription
MarketDataMessageMarket-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
stringSecurity 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
TKeyKey.
adapter
IMessageAdapterAdapter.
Returns
Type Parameters
TKey