A connector that authorizes through OAuth (Alor, Tradier, cTrader and others)
asks ConfigManager for an IOAuthProvider when it connects, and the sample never
registered one, so such a connector could not connect from it. The sample now
registers the WPF OAuthProvider, as the WPF programs do in RegisterUIServices:
the token is taken through the site the sample has already signed in to.
The applications moved every host into a folder of its own, so the projects the from-source samples reference
are under Xaml\Avalonia and Xaml\Wpf now, and the FIX connector they named lives in the public connectors
repository. Nine WPF samples still named Xaml and Xaml.Charting where they were before: a missing project
reference is only a warning, so they failed later, at the first DevExpress or StockSharp tag of their markup.
The MultiConnect samples sign in through the window the WPF head has. That head keeps the credentials window
in Studio.WebApi.UI, taking the site's client service; the samples asked StockSharp.Xaml for one taking a
fetcher, which the head does not have, and did not compile from sources. The published UI packages are far
behind the sources and are not what the samples are kept in step with: the package-based projects of these
samples compile once the WPF packages built from that head are published.
The WPF samples await the connector's settings window, which the WPF library offers as ConfigureAsync only,
and the active-orders sample awaits the chart's save instead of the obsolete blocking wrapper. The
package-based projects of the same samples compile once a StockSharp.Xaml package that has ConfigureAsync is
published.
The Avalonia samples keep the connection settings through the awaited store: IConnectorSettingsStore reads
and writes through awaited members now, so the sample store reads or writes its file when it is asked instead
of reading both files up front and queueing its writes. The chart sample saves and loads its chart the same
way.
Eight Avalonia samples put the wheel date picker into columns of 150-170 pixels. It does not get narrower
than about three hundred, so the two of them ran over each other and over the Start and Stop buttons. They
take the compact calendar editor now, which the history testing sample already had.
"Mark the blocking wrappers obsolete" left several callers of those wrappers
under #pragma, because a property, a parameter handler or a state setter could
not wait, and a few places that blocked without a wrapper. Each of those
chains now runs through callers that can await.
The emulation connector. A state change collects what its handlers throw and
sends it out once the state lock is released; the disconnect that follows
Stopping is awaited there as well. The change to Stopped moved from a handler
of Disconnected into OnDisconnectedAsync, a step the connector now awaits
before it raises that event.
ExpressionIndexSecurity. Expression records the text and reads the instruments
it names, which needs no compiler. The formula is compiled by GetFormulaAsync;
Formula is an obsolete blocking wrapper over it. IBasketSecurityProcessor gets
InitAsync, where the expression processor takes its formula, and
CreateProcessorAsync creates a processor and prepares it; CreateProcessor and
the IEnumerable ToBasket are obsolete wrappers, and the tests of ToBasket go
through the IAsyncEnumerable overload. The index diagram element builds its
index in OnPrepareAsync.
MathDiagramElement. The inputs are named by the text of the formula; the
formula and its validation are compiled in OnPrepareAsync. An element that was
reset therefore compiles again at the next start instead of refusing to start.
An input that is wired stays while the text is not known to compile, and goes
at the preparation if the compiled formula does not name it. A text replaced
under a running element is an error on every value until the element is
prepared again.
Candle patterns. A CandleExpressionCondition compiled its formula in the
constructor or, for the registry, at the first evaluation. The formula is now
compiled by PrepareAsync: on the condition, on ICandlePattern and, through the
new IIndicator.PrepareAsync, on the indicator that holds a pattern. A pattern
that was not prepared refuses to recognize instead of compiling on the spot.
The checks of a pattern as a whole - a formula reaching outside it, no
formulas at all - moved from the first Recognize to the preparation, and a
failed check no longer leaves the pattern marked as checked. Whoever feeds an
indicator prepares it first: IndicatorDiagramElement in OnPrepareAsync, a
strategy for the indicators its start registered, the chart samples when an
indicator is added. ICandlePatternProvider.Save became SaveAsync and prepares
the pattern before it stores it. The compileOnDemand constructor is gone: no
constructor compiles.
Stopping a strategy from code that cannot wait. When an element was entered
deeper than the overflow limit, DiagramElement.Process stopped the strategy
through AsyncHelper.Run. Strategy gets RequestStop for such code: it reports
the error, refuses new orders at once and leaves the stop itself to
OnNewMessage, which carries it out when the connector hands over the next
message.
Releasing a connector. Connector.DisposeManaged waited for the disconnect, and
for the message that takes the adapters apart, through AsyncHelper.Run. The
release is now DisposeManagedAsync, a virtual chain that the connectors
derived from Connector override. DisposeAsync awaits it, and the sealed
DisposeManaged is the same chain with the caller blocked, as IDisposable
requires. IConnector is IAsyncDisposable, so code that holds a connector by
its interface releases it by await as well.
Diagram elements that waited for their type. A composition read before one of
its element types was registered keeps an empty node for each such element.
Registering the type started their load unawaited, and a failure lost the
settings at the next save. ICompositionRegistry gets
LoadNotLoadedElementsAsync, to be awaited by whoever registered the types. It
loads what waits in the given composition and in the compositions nested in
it, one call at a time. The settings of an element that waits are kept by its
node (ICompositionModelNode.ElementSettings). A loaded element joins its
model: it is announced as an added one and the links of its node are
connected.
The sample windows. CombineHistoryRealtime, LiveTerminal and StoreDataLocal,
WPF and Avalonia, flushed the storage executor, released the CSV registries
and read them at startup through AsyncHelper.Run. A window now refuses the
first attempt to close it, awaits the release and closes itself once the
queued writes are on the disk. A shutdown that does not honour the refusal -
the end of the Windows session, Application.Shutdown - is not waited for: what
is still queued then is lost. LiveOptionsQuoting and MultiConnect called the
blocking Strategy.Start, Stop and GetTimeFrames under a suppressed obsolete
warning; they await the async ones now.
What the rework uncovered:
- Pausing the optimizer. An iteration that had passed the pause gate but
whose connector had not started replaying yet ran to its end through the
pause; cloning the strategy asynchronously made that window long enough for
PauseHaltsBruteForce to see it on CI. An iteration now waits for its
connector to come up and suspends it if the optimizer is paused by then.
- Undo of diagram elements. An undo scope opened with no undo manager in
sight took the element's level down when it closed, so the level was
negative by the time the element reached a composition and no edit was ever
reported. The scope remembers whether it was counted.
- Undo of a chart panel. A snapshot keeps the series and axes of a panel by
reference, since a part can only be saved asynchronously, so undo did not
put back what a part was set to. IChartSnapshotPart is an optional interface
for a part that can copy its settings in memory; the panel captures and
gives back the settings of such parts. No chart part implements it yet -
that is for the chart packages to do.
- The dummy indicator wrapper was left without a chart element, so indicator
values could not be wired into the panel that a run without a window uses.
- Settings loaded before a composition existed are applied when the strategy
starts; a test pins it.
- AsyncMessageChannel looked at its state once per wake-up and then went
through the queue until it was empty, so a message sent right after Suspend
returned could still be started, and Suspend_PausesProcessing was red from
time to time. The state is now read under the queue lock, where the next
message is picked; a channel that is being closed stops starting what is
queued the same way.
DiagramElementParamTests no longer declares a value that persists itself
through the obsolete IPersistable: declaring one needs a suppressed warning,
and for that contract the parameter relies on SaveEntireAsync and
LoadEntireAsync of Ecng, which are tested there.
Connector.SendOutError, StrategyEngine.OnMessage, CodeInfo.Compile and both
TraderHelper.Compile overloads only wait for their async forms, so they are
obsolete in favour of SendOutErrorAsync, OnMessageAsync and CompileAsync.
IFitnessFormulaProvider compiles through CompileAsync and the genetic
optimizer awaits it; Compile stays as an obsolete extension.
A state property, an expression property, two formula parameters and a
lazily compiled candle condition cannot wait, so they call the obsolete forms
under a pragma. The MultiConnect sample awaits its storages instead of
blocking on them.
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.
Two of them call CancellationToken.None without importing System.Threading. The third names EventSubscription without importing StockSharp.Xaml, and inside a window that name then binds to the nested type a window inherits from Avalonia Interactive, which is not accessible; every other sample that uses it imports the namespace. None of the three built.
THE NAME. A strategy saved under a name its caller gave came back under a different one: Strategy.Save
writes its parameters, its risk manager and its statistics, and not its name, so a restored strategy
was nameless and the name generator then named it after whatever instrument and portfolio it was
given - "Overnight carry" coming back as "MTS_AAPL@NASDAQ".
Save now writes the name down, but only when a caller set one by hand. NameGenerator turns
auto-generation off the moment Name is assigned, and that flag is the record of whose name it is: a
strategy nobody named saves no name and goes on generating its own after the round trip, which is the
other half of the promise and has a test of its own. Both live beside the rest of the naming contract
in StrategyNameGeneratorTests.
THE SAMPLES SUITE GOES. SamplesAvalonia.Tests held four test classes over two internal helpers inside
two sample applications - code nothing ships and nothing references. A sample is documentation that
has to compile; what it demonstrates is the library, and the library has a suite of its own. The
project belonged to no solution.
The promise about the name was found there, which is how it got here; the suite's other red test
asked that a failed load dispose the instance it never returned, and that is a preference rather than
a broken promise - the object holds nothing but its own parts and is collected like any other garbage.
AND THE README WITH IT. Samples/README_Avalonia.md described a finished migration rather than the
samples: a "Stage 18 completion gate", a count of 72 passing contract tests, a note that package
publication is release work and not a remaining gap. It had also stopped being true. Every one of its
twenty-one dotnet build lines named a path that does not exist - it says
01_Basic/01_ConnectAndDownloadInstruments, the folder is 01_Basic/01_ConnectAndDownloadInstruments_Avalonia.
It promised a package head and a _fromsrc head per sample; the tree holds twenty-eight _fromsrc heads
and no package head. Its "targeted validation" listed eight test classes that exist nowhere here.
Anyone following it would have run twenty-one commands and had twenty-one failures.
Claude-Session: https://claude.ai/code/session_01LjT4RKLsz3vBd8eSERZTde
Every test written during the coverage review, in one commit: 105 files, about 32,000 lines added.
No product code is touched here - what the tests found is repaired in the commit that follows.
WHERE THEY CAME FROM. Three audits read the core and its suite side by side and filed 295 findings.
Each was taken as a claim to be disproved rather than believed: of the defects claimed, most did not
survive a second reading - an unreachable trigger, a promise nobody ever made, behaviour already
covered, and in one case a property the model no longer has, so the test could not be written at all.
What survived is here.
WHAT THE TESTS ARE. Three kinds, and the difference matters.
A hole: behaviour the core has and nothing checked. Most of the new files are this - the adapters
that filter a depth, hold a candle, track a lookup, associate a security or loop a message back; the
message clone that must not share state with its original; the generators behind localized strings
and media names; the round trip of a diagram strategy and of a FIX data type.
A test that proved nothing: a name that promised one thing while the assertion checked another, an
assertion that could not fail, an expected value copied from whatever the code returned that day.
Those were rewritten in place to say what they were named for, and several of them go red doing it.
A defect: a promise the core makes and does not keep. Those tests are red, and they stay red until
the next commit repairs them - a red test is the record of the defect, and there is nowhere else the
record would be read.
HOW THEY ARE WRITTEN. From the promise, not from the implementation: the expected value is what the
caller is owed, never what the method happens to return. Every assertion carries a message saying
what was owed to whom, so a failure reads as a sentence rather than as two numbers that differ.
Claude-Session: https://claude.ai/code/session_01LjT4RKLsz3vBd8eSERZTde
The Avalonia samples were written before the shared Avalonia stack existed and
had grown their own copies of what it already does: connector setup, event
routing to the UI thread, dispatcher plumbing. Each copy was a second answer to
a question the library had answered, and the two drifted. They use the library
now, and where a sample needed something the library did not expose - a
UI-thread event subscription, a connector-settings store - that piece moved into
the shared layer rather than staying a sample's private helper, so an
application gets it too.
They also lived in a tree of their own, SamplesAvalonia, mirroring the folder
names of Samples exactly. A reader who wanted to compare the two versions of one
example had to know that the trees mirrored each other and navigate both, and
nothing in either tree said the other existed. It is one tree now: each example's
Avalonia version sits in the same area folder as its WPF version, next to it.
The WPF samples keep the names and folders they have always had, so every link
and path that points at them still resolves. It is the Avalonia version that
says which head it is - 01_HistorySMA_Avalonia beside 01_HistorySMA, and
01_Strategies.HistorySMA_Avalonia beside 01_Strategies.HistorySMA, with the
source-built twins following as _Avalonia_fromsrc.
That suffix reaches the assembly name, which is what makes the two builds
distinguishable, but not the root namespace: the sources and their x:Class
declarations keep the namespace they have, so nothing inside the samples had to
change. The namespaces do follow the rename that separated assembly names from
namespaces, and the history samples ask for a UTC day instead of the machine's,
which is what the storage is keyed by - a sample run west of UTC asked for the
wrong day.
All 63 examples - 35 WPF and 28 Avalonia - are now in Samples.slnx and in
StockSharp.slnx, and in StockSharp_CI.slnx, which is the solution the Windows CI
job builds: the Avalonia samples were in no solution at all, so nothing ever
checked that they still compiled.
The tests that read the sample sources - counting files, matching strings in
markup, asserting a project reference exists - are gone. They restated the tree
rather than running anything in it, so they passed for samples that could not
start and failed for edits that changed nothing.
Twelve common_*.props files sat in the repository root, mixed in with the
solutions and the READMEs. They are build configuration and now live in props/,
and every import that reaches them carries the folder: 59 imports across this
repository, Connectors and StockSharpApps, the F# analytics project included.
common_meta.props derived the repository location from its own directory, so it
now normalizes one level up. RepoGitHubPath and everything built on it -
RepoAppsPath, RepoWebPath, ConnectorsGitHubPath, ConnectorsAppsPath - evaluate
to exactly the paths they did before.
The folder is props/ and not build/, which .gitignore excludes.
IClientService.GetCurrentAsync gained two optional flags before the cancellation
token, so the positional call in the sample's ICurrentClientFetcher handed the
token to a bool? and stopped compiling. It names the token now, as the rest of
the repository does, so a further optional parameter cannot move it again.
The solution file also had forty-four connector entries indented with a tab while
their neighbours use four spaces, which made the list look ragged wherever one of
them fell.
Strategy.Start/Stop are obsolete in favour of StartAsync/StopAsync. Where the
caller was already async it now awaits. Where it is a click handler or a
void-returning event delegate it cannot await, so the call follows the pattern
BaseOptimizer already uses for the same situation: launch the task and report
only its failure, rather than blocking the caller or turning it into async void.
SmaServerStopStrategy declared a private OnOrderChanged that hid the virtual hook
of the same name, then subscribed to OrderReceived by hand to reach it - so the
framework hook sat dead. It is an override now and the manual subscription is
gone. The Designer template copy had the same defect.
MarketQuotingStrategy is obsolete in favour of QuotingProcessor, which is not a
Strategy and so cannot be handed to the sample's strategy editor. The terminal
sample gets a small strategy of its own that drives the processor.
The RemoteSource sample was the only one still using Finam, and it did so
through a NuGet package. That package - like every published connector - is
built against a StockSharp.Messages that still had HistoricalAsyncMessageAdapter,
a type this repository removed, so the sample no longer compiled against its own
sources.
BinanceHistory replaces it. Being open, it is referenced as a project the way the
other samples reference connectors, which also ends the package-versus-sources
mismatch. It is free and keyless, so the web-api token prompt and the
IInstrumentInfoService registration are gone - nothing resolved that service
here, and demanding a token to download public data made no sense. The security
lookup now derives its code from Paths.HistoryDefaultSecurity instead of asking
for BTCUSD while fetching BTCUSDT@BNBFT.
The samples were pointed at published packages that no longer match the sources
next to them, and at one package they had no business referencing at all.
Connectors come from the sibling checkout rather than from NuGet. The published
connector packages were compiled against a StockSharp.Messages that still had
AsyncMessageAdapter; the source has since dropped it, so a package built against
the old base type fails with CS7069 the moment the local Messages project is in
the graph - which it always is inside this solution. FIX is among them now: it
has moved out of the closed repository and is a project like the others, so the
two Hydra samples that used its package take the project too.
Indicators, strategies and the testing stack used to ship inside StockSharp.Algo
and are separate projects now, so referencing Algo alone left every sample
without SimpleMovingAverage, Strategy and RandomWalkTradeGenerator. Two
references cover it: Algo.Strategies reaches Algo.Testing and Algo transitively,
while Algo.Indicators is not reachable from that chain and has to be named.
01_MultiConnect and 02_StoreDataLocal additionally referenced
StockSharp.Studio.WebApi.UI for exactly one type, CredentialsWindow, and got
Studio.Core and Studio.WebApi with it. That type now lives in StockSharp.Xaml,
so the reference goes - from the package projects and the _fromsrc ones alike.
The dialog takes an ICurrentClientFetcher rather than the web API's client
service, and the sample supplies its own: it already registers an
IApiServiceProvider, the same object Studio's registry reads, so the anonymous
lookup is the call it always was, made directly. Web.Api reached those samples
transitively through the Studio package and is named explicitly now;
StockSharp.Web.DomainModel is aliased rather than imported wholesale, since it
also defines Subscription and DataType, which that file uses from
BusinessEntities and Messages.
Both _fromsrc samples build. The package-based pair does not yet: it takes
StockSharp.Xaml transitively from the published StockSharp.Xaml.Charting, and the
published Xaml has no ICurrentClientFetcher. They compile as soon as
StockSharp.Xaml is republished.
Two samples are left failing rather than papered over: 09_Advanced needs the
republished Xaml above, and 03_Storage/03_RemoteSource uses StockSharp.Finam,
stale in the same way the connector packages were, with no Finam project in the
Connectors checkout to point at instead.
ConnectorsGitHubPath still pointed at Samples\Connectors (where the connectors used
to live inside this repo); after the connectors moved to the sibling StockSharp/
Connectors repo it resolved to a non-existent folder. The CrossPlatform ConsoleApp
sample referenced Binance via ConnectorsAppsPath (StockSharpApps\Connectors, which
holds only the private connectors), so the public Binance connector was not found
(CS0246).
Repoint ConnectorsGitHubPath at ..\Connectors\ (the connectors' new home, same as
StockSharp.slnx's ../Connectors/ references) and switch the sample to it. The
sample now builds.
Switching the codebase to Ecng.Common extensions (Math.Abs(x) -> x.Abs(), and
string.To<T>()) left these sample files calling the extensions without a
using Ecng.Common. The libraries get it via a global using in their
Properties/usings.cs, but the samples have no such file, so on the current SDK
these stopped compiling: decimal.Abs(decimal) now exists as a static, so x.Abs()
with no extension in scope bound to it and failed with CS7036 (and .To<T>() with
CS1061). Add the using to the 12 affected sample files.
Localize the community links to the per-language site URLs — chat
(stocksharp.com/<lang>/chat/), documentation (doc.stocksharp.com/<lang>/...)
and the main-site links (stocksharp.com/<lang>/...), and point the old
stocksharp.ru links at stocksharp.com/ru — with <lang> matching the language
each README is written in. Also fix the grammatical errors in the English
README (introduction and the Designer/Terminal/Shell/API blurbs).
The security get-or-create path was bridged to the async storage through a
blocking AsyncHelper.Run, turning SaveAsync into a sync-over-async call inside
the hot message-processing path. Propagate real async up the whole chain.
TraderHelper:
- Add GetOrCreateAsync that awaits ISecurityStorage.SaveAsync. It does not hold
the storage Lock.Scope across the await (the lock is monitor based and thread
affine); SaveAsync(forced: false) is an atomic add-if-absent, and the
canonical stored instance is re-resolved to stay correct under concurrent
creation.
- Mark the sync GetOrCreate(out bool) obsolete; it bridges to the async variant
and has no internal callers left.
Connector / Connector_ProcessMessage:
- Add GetSecurityAsync/EnsureGetSecurityAsync and route the message-processing
handlers (Security, Level1, News, Quotes, Trade, Transaction, PositionChange,
Execution) through them; the already-async dispatcher awaits them. No blocking
Run remains on this path.
- TryGetSecurity (entity cache snapshot delegate) becomes a pure LookupById: a
snapshot lookup must not create or persist a security.
IConnector:
- Add GetSecurityAsync(SecurityId, CancellationToken) and mark the sync
GetSecurity(SecurityId) obsolete. The sync method stays as a deprecated bridge
for external callers only.
Migrate the in-repo callers (tests and the RemoteSource sample) to the async API.
When starting the optimization SetIsEnabled was called with canSuspend=false, so
the Pause button stayed disabled for the whole run even though BaseOptimizer
supports Pause/Resume (the click handler was already wired). Pass canSuspend=true
so the button is active while the optimization is running.
The result panel was driven in the wrong order: AddStrategy was called only at
100% (end of each iteration) while UpdateProgress was called for 1..99%.
StrategiesStatisticsPanel both registers the strategy in its lookup map and
subscribes to the strategy PnL feed inside AddStrategy. Calling it last meant
UpdateProgress had no row to update (so Progress stayed 0) and the PnL
subscription was attached only after the backtest had already finished (so the
equity sparkline stayed empty).
Register the strategy on its first progress event (deduped by Strategy.Id) and
only update progress afterwards, matching how the Designer optimizer panel uses
the control. Now the Progress column climbs to 100% and the P&L chart is filled
while the run is in progress.
- Renamed INativeIdStorage to INativeIdStorageProvider
- Created new INativeIdStorage interface for single isolated storage
- Provider pattern: GetStorage(storageName) returns isolated storage with own buffer
- INativeIdStorageProvider implements IAsyncDisposable
- Each CsvNativeIdStorage instance has isolated buffer and file access
- Updated SecurityNativeIdMessageAdapter, BasketMessageAdapter, TraderHelper, ServicesRegistry