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
drivesIEnumerable<IMarketDataDrive>Storage drives.
updateProgressAction<int, int>The handler through which a progress change will be passed.
isCancelledFunc<bool>The handler which returns an attribute of search cancel.
logsReceiverILogReceiverLogs 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
storageIMarketDataStorageMarket-data storage.
fromDateTimeOffset?The start time for data deleting. If the value is not specified, the data will be deleted starting from the date GetFromDate(IMarketDataStorage).
toDateTimeOffset?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
securityStorageISecurityStorageSecurities meta info storage.
securityIdSecurityIdIdentifier.
DeleteById(ISecurityStorage, string)
Delete instrument by identifier.
public static void DeleteById(this ISecurityStorage securityStorage, string securityId)
Parameters
securityStorageISecurityStorageSecurities meta info storage.
securityIdstringIdentifier.
FolderNameToSecurityId(string)
The inverse conversion from the SecurityIdToFolderName(string) method.
public static string FolderNameToSecurityId(this string folderName)
Parameters
folderNamestringDirectory name.
Returns
- string
Security ID.
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
providerCandleBuilderProviderCandle builders provider.
registryIStorageRegistryMarket-data storage.
securityIdSecurityIdSecurity ID.
timeFrameTimeSpanTime-frame.
driveIMarketDataDriveThe storage. If a value is null, DefaultDrive will be used.
formatStorageFormatsThe 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
registryIMessageStorageRegistrysubscriptionSubscriptiondriveIMarketDataDriveThe storage.
formatStorageFormatsThe 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
storageIMarketDataStorageMarket-data storage.
fromDateTime?The range start time. If the value is not specified, data will be loaded from the start date GetFromDate(IMarketDataStorage).
toDateTime?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
storageIMarketDataStorageMarket-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
storageIMarketDataStorageStorage.
fromDateTimeOffset?The initial date from which you need to get data.
toDateTimeOffset?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
registrySnapshotRegistrySnapshot storage registry.
dataTypeDataTypeData 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
registryIStorageRegistryMarket-data storage.
securitySecuritySecurity.
dataTypeDataTypeData type info.
driveIMarketDataDriveThe storage. If a value is null, DefaultDrive will be used.
formatStorageFormatsThe 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
registryIStorageRegistryMarket-data storage.
securityIdSecurityIdSecurity ID.
dataTypeDataTypeData type info.
driveIMarketDataDriveThe storage. If a value is null, DefaultDrive will be used.
formatStorageFormatsThe 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
registryIMessageStorageRegistrysecurityIdSecurityIdSecurity ID.
argTimeSpanCandle arg.
driveIMarketDataDriveThe storage.
formatStorageFormatsThe 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
storageIMarketDataStorageMarket-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
pathstringPath.
Returns
- bool
Check result.
LoadMessages(StorageCoreSettings, CandleBuilderProvider, MarketDataMessage, Action<Message>)
Load messages.
public static (DateTimeOffset lastDate, long? left)? LoadMessages(this StorageCoreSettings settings, CandleBuilderProvider candleBuilderProvider, MarketDataMessage subscription, Action<Message> newOutMessage)
Parameters
settingsStorageCoreSettingsStorage settings.
candleBuilderProviderCandleBuilderProviderCandle builders provider.
subscriptionMarketDataMessageMarket-data message (uses as a subscribe/unsubscribe in outgoing case, confirmation event in incoming case).
newOutMessageAction<Message>New message event.
Returns
- (DateTimeOffset lastDate, long? left)?
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
storageIMarketDataStorage<TMessage>Market-data storage.
fromDateTimeOffset?The start time for data loading. If the value is not specified, data will be loaded from the starting time GetFromDate(IMarketDataStorage).
toDateTimeOffset?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
TMessageData type.
SecurityIdToFolderName(string)
To convert the instrument identifier into the folder name, replacing reserved symbols.
public static string SecurityIdToFolderName(this string id)
Parameters
idstringSecurity 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
providerIMappingMessageAdapterProvider<TKey>Message adapter's provider interface.
keyTKeyKey.
adapterIMessageAdapterAdapter.
Returns
Type Parameters
TKey