StorageHelper
Extension class for storage.
Methods
public static void ClearDatesCache(IMarketDataStorageDrive drive)
StorageHelper.ClearDatesCache(drive)
Synchronous wrapper for CancellationToken).
- drive
- Market data storage drive.
public static void Delete(ISecurityStorage storage, Security security)
StorageHelper.Delete(storage, security)
Synchronous wrapper for CancellationToken).
- storage
- Security storage.
- security
- Security.
public static void Delete(IMarketDataStorageDrive drive, DateTime date)
StorageHelper.Delete(drive, date)
Synchronous wrapper for CancellationToken).
- drive
- Market data storage drive.
- date
- Date, for which all data shall be deleted.
public static void Delete(IMarketDataStorage storage, IEnumerable<Message> data)
StorageHelper.Delete(storage, data)
Synchronous wrapper for CancellationToken).
- storage
- Market data storage.
- data
- Market data to be deleted.
public static void Delete(IMarketDataStorage storage, DateTime date)
StorageHelper.Delete(storage, date)
Synchronous wrapper for CancellationToken).
- storage
- Market data storage.
- date
- Date, for which all data shall be deleted.
public static bool Delete(IMarketDataStorage storage, DateTime? from, DateTime? to)
result = StorageHelper.Delete(storage, from, to)
To delete market data from the storage for the specified time period.
- storage
- Market-data storage.
- from
- The start time for data deleting. If the value is not specified, the data will be deleted starting from the date GetDatesAsync.
- to
- 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 GetDatesAsync, inclusive.
Returns: if data was deleted, data not exist for the specified period.
public static ValueTask<bool> DeleteAsync(IMarketDataStorage storage, DateTime? from, DateTime? to, CancellationToken cancellationToken)
result = StorageHelper.DeleteAsync(storage, from, to, cancellationToken)
To delete market data from the storage for the specified time period.
- storage
- Market-data storage.
- from
- The start time for data deleting. If the value is not specified, the data will be deleted starting from the date GetDatesAsync.
- to
- 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 GetDatesAsync, inclusive.
- cancellationToken
- CancellationToken
Returns: if data was deleted, data not exist for the specified period.
public static void DeleteBy(ISecurityStorage storage, SecurityLookupMessage criteria)
StorageHelper.DeleteBy(storage, criteria)
Synchronous wrapper for CancellationToken).
- storage
- Security storage.
- criteria
- The criterion.
public static ValueTask DeleteByIdAsync(ISecurityStorage securityStorage, string securityId, CancellationToken cancellationToken)
result = StorageHelper.DeleteByIdAsync(securityStorage, securityId, cancellationToken)
Delete instrument by identifier.
- securityStorage
- Securities meta info storage.
- securityId
- Identifier.
- cancellationToken
- CancellationToken
public static ValueTask DeleteByIdAsync(ISecurityStorage securityStorage, SecurityId securityId, CancellationToken cancellationToken)
result = StorageHelper.DeleteByIdAsync(securityStorage, securityId, cancellationToken)
Delete instrument by identifier.
- securityStorage
- Securities meta info storage.
- securityId
- Identifier.
- cancellationToken
- CancellationToken
public static void DeleteRange(ISecurityStorage storage, IEnumerable<Security> securities)
StorageHelper.DeleteRange(storage, securities)
Synchronous wrapper for CancellationToken).
- storage
- Security storage.
- securities
- Securities.
public static void Delete<TMessage>(IMarketDataStorage<TMessage> storage, IEnumerable<TMessage> data)
StorageHelper.Delete(storage, data)
Synchronous wrapper for CancellationToken).
- storage
- Market data storage.
- data
- Market data to be deleted.
public static string FolderNameToSecurityId(string folderName)
result = StorageHelper.FolderNameToSecurityId(folderName)
The inverse conversion from the String) method.
- folderName
- Directory name.
Returns: Security ID.
public static IEnumerable<DataType> GetAvailableDataTypes(IMarketDataDrive drive, SecurityId securityId, StorageFormats format)
result = StorageHelper.GetAvailableDataTypes(drive, securityId, format)
Get all available data types.
- drive
- IMarketDataDrive
- securityId
- Instrument identifier.
- format
- Format type.
Returns: Data types.
public static ValueTask<IMarketDataStorage<CandleMessage>> GetCandleMessageBuildableStorage(CandleBuilderProvider provider, IStorageRegistry registry, SecurityId securityId, TimeSpan timeFrame, IMarketDataDrive drive, StorageFormats format, CancellationToken cancellationToken)
result = StorageHelper.GetCandleMessageBuildableStorage(provider, registry, securityId, timeFrame, drive, format, cancellationToken)
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.
- provider
- Candle builders provider.
- registry
- Market-data storage.
- securityId
- Security ID.
- timeFrame
- Time-frame.
- drive
- The storage. If a value is , DefaultDrive will be used.
- format
- The format type. By default Binary is passed.
- cancellationToken
- CancellationToken
Returns: The candles storage.
public static IMarketDataStorage<CandleMessage> GetCandleMessageStorage(IStorageRegistry registry, Subscription subscription, IMarketDataDrive drive, StorageFormats format)
result = StorageHelper.GetCandleMessageStorage(registry, subscription, drive, format)
To get the candles storage for the specified instrument.
- registry
- IStorageRegistry.
- subscription
- Subscription.
- drive
- The storage.
- format
- The format type.
Returns: The candles storage.
public static IMarketDataStorage<CandleMessage> GetCandleMessageStorage(IStorageRegistry registry, Type candleMessageType, SecurityId securityId, object arg, IMarketDataDrive drive, StorageFormats format)
result = StorageHelper.GetCandleMessageStorage(registry, candleMessageType, securityId, arg, drive, format)
To get the candles storage for the specified instrument.
- registry
- IStorageRegistry
- candleMessageType
- The type of candle message.
- securityId
- Security ID.
- arg
- Candle arg.
- drive
- The storage.
- format
- The format type.
Returns: The candles storage.
public static IEnumerable<DateTime> GetDates(IMarketDataStorage storage, DateTime? from, DateTime? to)
result = StorageHelper.GetDates(storage, from, to)
To get all dates for stored market data for the specified range.
- storage
- Market-data storage.
- from
- The range start time. If the value is not specified, data will be loaded from the start date GetDatesAsync.
- to
- The range end time. If the value is not specified, data will be loaded up to the end date GetDatesAsync, inclusive.
Returns: All available data within the range.
public static IEnumerable<DateTime> GetDates(IMarketDataStorageDrive drive)
result = StorageHelper.GetDates(drive)
Synchronous wrapper for GetDatesAsync.
- drive
- Market data storage drive.
Returns: Available dates.
public static IEnumerable<DateTime> GetDates(IMarketDataStorage storage)
result = StorageHelper.GetDates(storage)
Synchronous wrapper for GetDatesAsync.
- storage
- Market data storage.
Returns: Available dates.
public static IAsyncEnumerable<DateTime> GetDatesAsync(IMarketDataStorage storage, DateTime? from, DateTime? to)
result = StorageHelper.GetDatesAsync(storage, from, to)
To get all dates for stored market data for the specified range.
- storage
- Market-data storage.
- from
- The range start time. If the value is not specified, data will be loaded from the start date GetDatesAsync.
- to
- The range end time. If the value is not specified, data will be loaded up to the end date GetDatesAsync, inclusive.
Returns: All available data within the range.
public static IMarketDataStorage<ExecutionMessage> GetExecutionMessageStorage(IStorageRegistry registry, SecurityId securityId, ExecutionTypes type, IMarketDataDrive drive, StorageFormats format)
result = StorageHelper.GetExecutionMessageStorage(registry, securityId, type, drive, format)
To get the ExecutionMessage storage for the specified instrument.
- registry
- IStorageRegistry
- securityId
- Security ID.
- type
- Data type, information about which is contained in the ExecutionMessage.
- drive
- The storage.
- format
- The format type.
Returns: The ExecutionMessage storage.
public static DateTime? GetFromDate(IMarketDataStorage storage)
result = StorageHelper.GetFromDate(storage)
To get the start date for market data, stored in the storage.
- storage
- Market-data storage.
Returns: The start date. If the value is not initialized, the storage is empty.
public static IMarketDataMetaInfo GetMetaInfo(IMarketDataStorage storage, DateTime date)
result = StorageHelper.GetMetaInfo(storage, date)
Synchronous wrapper for CancellationToken).
- storage
- Market data storage.
- date
- Date, for which meta-information on data shall be received.
Returns: Meta-information on data. If there is no such date in history, will be returned.
public static IRange<DateTime> GetRange(IMarketDataStorage storage, DateTime? from, DateTime? to)
result = StorageHelper.GetRange(storage, from, to)
Get available date range for the specified storage.
- storage
- Storage.
- from
- The initial date from which you need to get data.
- to
- The final date by which you need to get data.
Returns: Date range
public static ValueTask<IRange<DateTime>> GetRangeAsync(IMarketDataStorage storage, DateTime? from, DateTime? to, CancellationToken cancellationToken)
result = StorageHelper.GetRangeAsync(storage, from, to, cancellationToken)
Get available date range for the specified storage.
- storage
- Storage.
- from
- The initial date from which you need to get data.
- to
- The final date by which you need to get data.
- cancellationToken
- CancellationToken
Returns: Date range
public static ISnapshotStorage GetSnapshotStorage(ISnapshotRegistry registry, Type dataType, object arg)
result = StorageHelper.GetSnapshotStorage(registry, dataType, arg)
To get the snapshot storage.
- registry
- Snapshot storage registry.
- dataType
- Market data type.
- arg
- The parameter associated with the type. For example, candle arg.
Returns: The snapshot storage.
public static IMarketDataStorage GetStorage(IStorageRegistry registry, SecurityId securityId, Type dataType, object arg, IMarketDataDrive drive, StorageFormats format)
result = StorageHelper.GetStorage(registry, securityId, dataType, arg, drive, format)
To get the market-data storage.
- registry
- IStorageRegistry
- securityId
- Security ID.
- dataType
- Market data type.
- arg
- The parameter associated with the type. For example, candle arg.
- drive
- The storage.
- format
- The format type.
Returns: Market-data storage.
public static IMarketDataStorage GetStorage(IStorageRegistry registry, Security security, Type dataType, object arg, IMarketDataDrive drive, StorageFormats format)
result = StorageHelper.GetStorage(registry, security, dataType, arg, drive, format)
To get the market-data storage.
- registry
- IStorageRegistry
- security
- Security.
- dataType
- Market data type.
- arg
- The parameter associated with the type. For example, candle arg.
- drive
- The storage. If a value is , DefaultDrive will be used.
- format
- The format type. By default Binary is passed.
Returns: Market-data storage.
public static IMarketDataStorage GetStorage(IStorageRegistry registry, Security security, DataType dataType, IMarketDataDrive drive, StorageFormats format)
result = StorageHelper.GetStorage(registry, security, dataType, drive, format)
To get the market-data storage.
- registry
- Market-data storage.
- security
- Security.
- dataType
- Data type info.
- drive
- The storage. If a value is , DefaultDrive will be used.
- format
- The format type. By default Binary is passed.
Returns: Market-data storage.
public static IMarketDataStorage<CandleMessage> GetTimeFrameCandleMessageStorage(IStorageRegistry registry, SecurityId securityId, TimeSpan arg, IMarketDataDrive drive, StorageFormats format)
result = StorageHelper.GetTimeFrameCandleMessageStorage(registry, securityId, arg, drive, format)
To get the candles storage for the specified instrument.
- registry
- IStorageRegistry.
- securityId
- Security ID.
- arg
- Candle arg.
- drive
- The storage.
- format
- The format type.
Returns: The candles storage.
public static DateTime? GetToDate(IMarketDataStorage storage)
result = StorageHelper.GetToDate(storage)
To get the end date for market data, stored in the storage.
- storage
- Market-data storage.
Returns: The end date. If the value is not initialized, the storage is empty.
public static IEnumerable<Message> Load(IMarketDataStorage storage, DateTime date)
result = StorageHelper.Load(storage, date)
Synchronous wrapper for DateTime).
- storage
- Market data storage.
- date
- Date, for which data shall be loaded.
Returns: Data. If there is no data, the empty set will be returned.
public static IAsyncEnumerable<TMessage> LoadAsync<TMessage>(IMarketDataStorage<TMessage> storage, DateTime? from, DateTime? to)
result = StorageHelper.LoadAsync(storage, from, to)
To create an iterative loader of market data for the time range.
- storage
- Market-data storage.
- from
- The start time for data loading. If the value is not specified, data will be loaded from the starting time GetDatesAsync.
- to
- The end time for data loading. If the value is not specified, data will be loaded up to the GetDatesAsync date, inclusive.
Returns: The iterative loader of market data.
public static ValueTuple<DateTime?, long?>? LoadMessages(StorageCoreSettings settings, CandleBuilderProvider candleBuilderProvider, MarketDataMessage subscription, Action<Message> newOutMessage)
result = StorageHelper.LoadMessages(settings, candleBuilderProvider, subscription, newOutMessage)
Load messages.
- settings
- Storage settings.
- candleBuilderProvider
- Candle builders provider.
- subscription
- Market-data message (uses as a subscribe/unsubscribe in outgoing case, confirmation event in incoming case).
- newOutMessage
- New message event.
Returns: Last date.
public static IAsyncEnumerable<Message> LoadMessagesAsync(StorageCoreSettings settings, CandleBuilderProvider candleBuilderProvider, MarketDataMessage subscription, StorageLoadContext context, CancellationToken cancellationToken)
result = StorageHelper.LoadMessagesAsync(settings, candleBuilderProvider, subscription, context, cancellationToken)
Load history messages from storage as async stream.
- settings
- Storage settings.
- candleBuilderProvider
- Candle builders provider.
- subscription
- Market-data message (uses as a subscribe/unsubscribe in outgoing case, confirmation event in incoming case).
- context
- Context that will be populated with load result metadata after enumeration.
- cancellationToken
- Cancellation token.
Returns: Async stream of messages.
public static Stream LoadStream(IMarketDataStorageDrive drive, DateTime date, bool readOnly)
result = StorageHelper.LoadStream(drive, date, readOnly)
Synchronous wrapper for CancellationToken).
- drive
- Market data storage drive.
- date
- Date, for which data shall be loaded.
- readOnly
- Get stream in read mode only.
Returns: Data in the format of StockSharp storage. If no data exists, Null will be returned.
public static IEnumerable<TMessage> Load<TMessage>(IMarketDataStorage<TMessage> storage, DateTime date)
result = StorageHelper.Load(storage, date)
Synchronous wrapper for DateTime).
- storage
- Market data storage.
- date
- Date, for which data shall be loaded.
Returns: Data. If there is no data, the empty set will be returned.
public static IEnumerable<TMessage> Load<TMessage>(IMarketDataStorage<TMessage> storage, DateTime? from, DateTime? to)
result = StorageHelper.Load(storage, from, to)
To create an iterative loader of market data for the time range.
- storage
- Market-data storage.
- from
- The start time for data loading. If the value is not specified, data will be loaded from the starting time GetDatesAsync.
- to
- The end time for data loading. If the value is not specified, data will be loaded up to the GetDatesAsync date, inclusive.
Returns: The iterative loader of market data.
public static int Save(IMarketDataStorage storage, IEnumerable<Message> data)
result = StorageHelper.Save(storage, data)
Synchronous wrapper for CancellationToken).
- storage
- Market data storage.
- data
- Market data.
Returns: Count of saved data.
public static void Save(ISecurityStorage storage, Security security, bool forced)
StorageHelper.Save(storage, security, forced)
Synchronous wrapper for CancellationToken).
- storage
- Security storage.
- security
- Security.
- forced
- Forced update.
public static void SaveStream(IMarketDataStorageDrive drive, DateTime date, Stream stream)
StorageHelper.SaveStream(drive, date, stream)
Synchronous wrapper for CancellationToken).
- drive
- Market data storage drive.
- date
- The date, for which data shall be saved.
- stream
- Data in the format of StockSharp storage.
public static int Save<TMessage>(IMarketDataStorage<TMessage> storage, IEnumerable<TMessage> data)
result = StorageHelper.Save(storage, data)
Synchronous wrapper for CancellationToken).
- storage
- Market data storage.
- data
- Market data.
Returns: Count of saved data.
public static string SecurityIdToFolderName(string id)
result = StorageHelper.SecurityIdToFolderName(id)
To convert the instrument identifier into the folder name, replacing reserved symbols.
- id
- Security ID.
Returns: Directory name.
public static bool SetAdapter<TKey>(IMappingMessageAdapterProvider<TKey> provider, TKey key, IMessageAdapter adapter)
result = StorageHelper.SetAdapter(provider, key, adapter)
Make association with adapter.
- provider
- Message adapter's provider interface.
- key
- Key.
- adapter
- Adapter.
Returns: if the association is successfully changed, otherwise, .
Fields
public const string SecurityBackslashSeparator
value = StorageHelper.SecurityBackslashSeparator
The delimiter, replacing '\\' in path for instruments with id like USD\\EUR. Is equal to '##BS##'.
public const string SecurityColonSeparator
value = StorageHelper.SecurityColonSeparator
The delimiter, replacing ':' in the path for instruments with id like AA-CA:SPB@SPBEX. Is equal to '##COLON##'.
public const string SecurityFirstDot
value = StorageHelper.SecurityFirstDot
The delimiter, replacing first '.' in the path for instruments with id like .AA-CA@SPBEX. Is equal to '##DOT##'.
public const string SecurityQuestionSeparator
value = StorageHelper.SecurityQuestionSeparator
The delimiter, replacing '?' in the path for instruments with id like AA-CA?SPB@SPBEX. Is equal to '##QSTN##'.
public const string SecuritySlashSeparator
value = StorageHelper.SecuritySlashSeparator
The delimiter, replacing '/' in path for instruments with id like USD/EUR. Is equal to '__'.
public const string SecurityStarSeparator
value = StorageHelper.SecurityStarSeparator
The delimiter, replacing '*' in the path for instruments with id like C.BPO-*@CANADIAN. Is equal to '##STAR##'.
public const string SecurityVerticalBarSeparator
value = StorageHelper.SecurityVerticalBarSeparator
The delimiter, replacing '|' in the path for instruments with id like AA-CA|SPB@SPBEX. Is equal to '##VBAR##'.