Instrument lookups, configuration, credentials, CSV entities, snapshots and the alert processing service are read and written asynchronously; the blocking synchronous forms are obsolete wrappers. IAsyncPersistable replaces IPersistable: every type that saves and loads its settings has LoadAsync and SaveAsync only, and nested objects are read with GetValueAsync, LoadEntireAsync and LoadAllAsync. The synchronous Load and Save are the obsolete Ecng extensions. The MultiConnect sample keeps IPersistable for two settings classes, because the settings window of the published StockSharp.Xaml package takes it. Copies that were made by saving and loading are made asynchronously. IMessageAdapter, IIndicator, the risk, commission, PnL, latency, slippage and position managers, IStorageBuffer, Strategy, DiagramElement, ICompositionModel and its nodes get CloneAsync and no longer implement ICloneable; Clone is an obsolete blocking wrapper. A strategy copy keeps every security and portfolio parameter the original holds. Messages, FieldMapping, BankDetails and WithdrawInfo are copied in memory. A CommissionRuleMessage shares its rule and the emulator takes a copy of it. Envelope gets a constructor that takes all three lines and CreateAsync. ToBruteForce and ToBruteForceRandom become ToBruteForceAsync and ToBruteForceRandomAsync and return IAsyncEnumerable; BruteForceOptimizer runs over it and takes the next strategy through an asynchronous delegate. Diagram elements keep their own state in SaveState, OnLoading and LoadState. Undo restores an in-memory snapshot; a chart element holds its series and axes in it by reference. An alert rule keeps its value in the form a message carries it. A diagram strategy applies composition settings that were loaded before the composition was set in SetCompositionAsync or at the start, and saves them while they wait. Strategies get an OnStartedAsync hook; diagram strategies resolve securities, underlyings and strikes before the start so value processing never looks up instruments. Paths.Serialize, SerializeInvariant, AppStartSettings.TrySave, ICredentialsProvider.Save, ISnapshotSerializer.Serialize and the composition registry gain async forms. ICredentialsProvider.Delete becomes DeleteAsync, so loading, saving and deleting the credentials wait for one another. Paths.InstalledVersion and AppNameWithVersion are obsolete in favour of GetInstalledVersionAsync and GetAppNameWithVersionAsync. A file is opened for writing only after the last cancellation check, because opening it empties it; a cancelled read reports the cancellation instead of an empty result. A snapshot flush that failed leaves what it took due for the next one. The indicator templates for C#, F# and Python override LoadAsync and SaveAsync.
S#.Algo.Export
S#.Algo.Export is a module of the StockSharp trading platform responsible for exporting market data and trading information to a variety of external formats. The library converts incoming Message based data structures into files or databases so it can be consumed by third‑party tools.
Features
- Multiple output formats: export can be performed to Excel spreadsheets, text files, JSON or XML documents, databases via LinqToDB, and to StockSharp's own storage format.
- Data type agnostic: any message type from
StockSharp.Messagescan be exported (ticks, order books, level1, candles, transactions, etc.). The target data type is described byDataTypeand handled in the base exporter logic. - Extensible Excel engine: the
IExcelWorkerProviderinterface abstracts work with Excel files.DevExpExcelWorkerProviderimplements this interface via DevExpress components and allows both creation of new documents and update of existing ones. - Template based text export: the
TemplateTxtRegistryclass stores default line templates for various message types which are used byTextExporterwhen writing text or CSV files. - Database integration:
DatabaseExporterusesLinqToDBto create tables on the fly and write messages in batches. The exporter can automatically map message fields and manage data uniqueness checking. - StockSharp storage:
StockSharpExporterwrites messages to the native persistent storage usingIStorageRegistryandIMarketDataDrive. - Progress control: every exporter accepts a
Func<int,bool>delegate used to report element count and abort processing if required.
Usage
Below is a simplified example of exporting trades to JSON:
var exporter = new JsonExporter(DataType.Ticks, i => false, "trades.json")
{
Indent = true
};
var result = exporter.Export(tradeMessages);
Console.WriteLine($"Saved {result.Item1} trades up to {result.Item2}");
Other exporters (ExcelExporter, XmlExporter, TextExporter, DatabaseExporter, StockSharpExporter) expose the same Export method but write to their respective targets. Creation parameters vary according to the destination (file name, Excel provider, database connection, etc.).
Text Templates
TemplateTxtRegistry defines a set of default string templates which can be customized. They describe how message fields are converted to text. For instance, TemplateTxtTick controls how each trade is written to a text file. See the source for the full list of templates and examples.