StockSharp.Algo
5.0.230
Prefix Reserved
See the version list below for details.
dotnet add package StockSharp.Algo --version 5.0.230
NuGet\Install-Package StockSharp.Algo -Version 5.0.230
<PackageReference Include="StockSharp.Algo" Version="5.0.230" />
<PackageVersion Include="StockSharp.Algo" Version="5.0.230" />
<PackageReference Include="StockSharp.Algo" />
paket add StockSharp.Algo --version 5.0.230
#r "nuget: StockSharp.Algo, 5.0.230"
#:package StockSharp.Algo@5.0.230
#addin nuget:?package=StockSharp.Algo&version=5.0.230
#tool nuget:?package=StockSharp.Algo&version=5.0.230
StockSharp Algo Library
Overview
StockSharp.Algo is the core algorithmic trading library used throughout the StockSharp platform. It provides the building blocks for creating trading bots, managing market data, handling order routing, and simulating strategies against historical data. The library targets .NET 6.0 and can be used in desktop, server, or cloud applications.
Features
- Connectors and Message Adapters – unified infrastructure for connecting to exchanges and data feeds. Includes offline adapters for simulation and adapters for incremental order books, snapshots, and extended order information.
- Strategy Framework – base classes for building algorithmic strategies with built‑in event model, parameter system, and rule management. Strategies can be composed and executed in parallel or as baskets.
- Market Data Storages – tools for storing quotes, trades, candles, and order books in various formats (binary, CSV) with caching and synchronization support.
- Risk and PnL – modules for risk management, slippage modeling, commission calculation, and real‑time profit‑and‑loss tracking.
- Testing and Emulation – historical emulation connectors and market data generators for backtesting strategies under conditions close to real trading.
- Services Registry – helper class to access common services (exchanges, securities, storages) across the application.
Getting Started
Prerequisites
- .NET SDK 6.0 or later.
- Visual Studio 2022 or any compatible IDE.
Basic Usage
The typical entry point for working with the library is the Connector class. Below is a very simplified example that demonstrates how to run a custom strategy using historical data:
using StockSharp.Algo;
using StockSharp.Algo.Strategies;
using StockSharp.Algo.Testing;
var connector = new HistoryEmulationConnector(securityProvider, portfolioProvider, storageRegistry);
var myStrategy = new MyStrategy { Connector = connector, Portfolio = myPortfolio, Security = mySecurity };
connector.NewStrategy += strategy => strategy.Start();
connector.Connect();
A full‑fledged application will include market data subscriptions, order registration, and more advanced strategy logic.
Documentation
Comprehensive documentation for the API and subsystems is available at the StockSharp documentation website.
Support
Questions and discussions are welcome in the community chat.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Ecng.Compilation (>= 1.0.319)
- Ecng.IO.Compression (>= 1.0.40)
- Ecng.Linq (>= 1.0.177)
- Ecng.Net (>= 1.0.527)
- Ecng.StringSearch (>= 1.0.255)
- MathNet.Numerics (>= 6.0.0-beta2)
- StockSharp.Charting.Interfaces (>= 5.0.101)
- StockSharp.Configuration (>= 5.0.221)
- StockSharp.Reporting (>= 5.0.0)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on StockSharp.Algo:
| Package | Downloads |
|---|---|
|
StockSharp.Studio.Core
Core types for UI applications. More info on web site https://stocksharp.com/store/ |
|
|
StockSharp.Xaml.Diagram
Visual designer to create trading strategies. More info on web site https://stocksharp.com/store/ |
|
|
StockSharp.CSV
CSV connector. More info on web site https://stocksharp.com/store/ |
|
|
StockSharp.QuikLua
Trading and algorithmic trading platform (stock markets, forex, bitcoins and options). .NET API for InteractiveBrokers, GainCapital, OANDA, FIX/FAST, Binance etc. More info on web site https://stocksharp.com/products/api/ |
|
|
StockSharp.Algo.Indicators
Technical indicators. More info on web site https://stocksharp.com/store/ |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.0.231 | 77 | 7/30/2026 |
| 5.0.230 | 163 | 7/28/2026 |
| 5.0.229 | 5,200 | 9/11/2025 |
| 5.0.228 | 642 | 9/1/2025 |
| 5.0.227 | 573 | 8/30/2025 |
| 5.0.226 | 746 | 8/10/2025 |
| 5.0.225 | 1,138 | 7/23/2025 |
| 5.0.224 | 830 | 7/22/2025 |
| 5.0.223 | 715 | 7/20/2025 |
| 5.0.222 | 1,363 | 7/14/2025 |
| 5.0.221 | 544 | 7/8/2025 |
| 5.0.220 | 500 | 7/4/2025 |
| 5.0.219 | 534 | 6/30/2025 |
| 5.0.218 | 751 | 6/24/2025 |
| 5.0.217 | 488 | 6/20/2025 |
| 5.0.216 | 581 | 6/18/2025 |
| 5.0.215 | 659 | 6/2/2025 |
| 5.0.214 | 785 | 5/14/2025 |
| 5.0.213 | 1,159 | 4/1/2025 |
| 5.0.212 | 486 | 3/29/2025 |
Migrate core APIs to async equivalents
Update README links and English wording
Storages: reject a default(DateTime) time bound instead of masking it
Storages: support loading the last Count records when From is not set
Basket: surface a single subscription error instead of wrapping it
Storages: tolerate reversed meta-info bounds when loading a range
Candles: do not suppress messages after a user unsubscribe
Candles: flush partial big-timeframe candle and resume build at the slot boundary
OrderBook: forward truncate manager out-messages from the adapter
OrderBook: remove subscription id from non-online builder and dedup all-security ids
Offline: address synthetic Done of replaced order to the original transaction
Candles: reset open interest and price levels in value transform
Basket: clean up parent subscription, child mappings and request after aggregated unsubscribe
Candles: bound volume-profile levels by snapping prices to the instrument price step
Convert security access to async (SaveAsync/GetSecurityAsync) end to end
Fix subscription online joined routing
Fix position storage buffer gating
Fix commission statistic updates
Fix transaction snapshot string parameters
Security lookup: apply Skip in paging and honor the forced save flag
Fix remote storage cache and ownership
Fix market position cancel completion
Fix order log tick subscription ids
Fix level1 depth subscription stripping
Fix CSV import roundtrips
Fix candle volume profile boundaries
Fix renko and heikin ashi candle output
Fix candle builder count completion
Fix volume continuous rollover state
Fix basket pinned subscription forwarding
Fix fill gaps adapter ownership
Algo: emulate trade side from spread-middle direction for the volume profile
Algo: add missing XML docs on spread wideners; fix Collapse paramref
Algo: add Level1SpreadWidener + OrderBookSpreadWidener helpers
TraderHelper.CreateCsvReader: don't wrap StreamReader
SubscriptionOnlineManager: skip TryAddOrderTransaction when statusInfo is a linked view
LoopBackMessageAdapter: re-inject IsBack messages emitted by inner pipeline
Connector: set SubscriptionId on locally-generated order messages
OrderBookIncrementManager: RemoveSubscription returns bool, log only on actual removal
BasketMessageAdapter: add SuppressOrderBookIncrements pipeline option
Use Ecng Common extensions across codebase
Remove IBinaryAdapter interface and IsBinaryEnabled from RemoteMarketDataDrive
Fix CompileAsync race condition in expression cache
Fix Level1ExtendBuilderAdapter candle conversion DataType mismatch
Rename Level1 storage file from security.bin to level1.bin
Fix BuildFrom=Ticks order time mismatch in history backtesting
RemoteMarketDataDrive. Lazy adapter creation to avoid requiring IMessageAdapterProvider at construction time.
Fix ALL-security subscriptions returning wrong SecurityId in OrderBookIncrementManager
Fix OrderBookIncrementManagerState dropping ALL@ALL QuoteChange messages
Fix live candle subscription leak on unsubscribe
Fix hist+live subscription bugs in SubscriptionOnlineManager and CandleBuilderManager
Fix BasketRoutingManager TransactionIdGenerator desync
Fix late SecurityAll subscribers not receiving cached order books.
Add GrossLoss, GrossProfit and MaxProfitPercent statistic parameters
SubscriptionSecurityAllMessage removed.
PositionLifecycleTracker fixes.
More tests.
WorkingTime moved to Ecng.
OfflineManager fixes
TransactionOrderingManager fixes
Fix ConnectMessage not emitted on mixed success/fail.
Fix OrderCancel portfolio fallback routing.
BasketMessageAdapter. Fix data forwarding after unsubscribe.
SubscriptionOnlineManager. Fix data forwarding after unsubscribe.
ConnectorSubscriptionManager. Fix re-subscribe and unsubscribe handling.
Connector. Fix call ValuesChanged for online marked data only.
Ecng.MathLight replaced by MathNet.Numerics
IEmulationConnector removed.
PositionManagement
BasketMessageAdapter fixes.
GetAvailableSecuritiesAsync deduplicate via HashSet instead of yield break.
BasketMessageAdapter fixes.
BasketMessageAdapter. Fix apply parent trans id for ticks
PositionLifecycleTracker
IMessageAdapter. GetSupportedDataTypes -> GetSupportedDataTypesAsync
Connector. UpdateSecurityByLevel1, UpdateSecurityLastQuotes turned off and marked as obsolete.
Removed sync NewOutMessage event, migrated to NewOutMessageAsync
BasketRoutingManager
IAdapterWrapperPipelineBuilder.
IAdapterRouter
Unify MarketData subscription path through ToChild/ParentChildMap
Add IsAllDownloadingSupported filtering for OrderStatus and PortfolioLookup
More tests.
OrderBookIncrementManagerState fix.
BasketMessageAdapter refactoring.
Managers states.
SlippageManagerState. Time tracking.
Managers. Clone implementations.
ExecMsg. MarketPrice property.
Subscription managers do not pass through unknown messages.
AutoConnectMessageAdapter removed.
Managers state.
RemoteStorageClient fix
Added Yield field support for tick storage (version 62)
OrderBookTruncateManager: fix null supportedDepth handling
OrderBookIncrementManager: fix subscription merge and remove
Level1DepthBuilderManager: fix subscription merge and remove
AsyncDisposable
IMessageTransport
RemoteStorageClient. Removed inner timeout
Remove Cloneable from MarketDataStorageCache
RemoteStorageCache removed.
RemoteStorageClient: add LookupBoardsAsync and fix archive extraction
RemoteStorageClient: refactor to use IMessageAdapter directly
Ecng.Excel
Indicators, Algo.Testing, Algo.Strategies separated projects.
Remove V1/V2 version references from comments
MarketEmulator V2: add candle matching support like V1
Storages: convert to async serialization API
MarketEmulator fixes.
IRandomProvider
MarketEmulator renaming.
MarketEmulator2: implement RealizedPnL, Commission, BlockedValue, Position tracking
MarketEmulator2
ITradingTimeLineGenerator.cs
IHistoryMarketDataManager
Testings.Generation
Market data generator fixes.
IBasketSecurityProcessorProvider. Get -> TryGet
CandleBuilderManager fixes
CandleBuilderManager fixes.
IFitnessFormulaProvider
OfflineManager fix.
OptimizationBatchManager
StrategyParamHelper. Optimization values generation.
Import, Export separated projects.
BasketMarketDataStorage fix
BasketPortfolio, BasketSecurityBaseProcessor fixes.
OL->Ticks fix handling. Reduced old code.
Analytics supported IAsyncEnumerable
BasketSecurityProcessorTests more tests.
LatencyManager. OrderReplaceMessage handling fix
CacheableMarketDataStorage support modification.
EntityCache. Validate negative and zero prices and volumes.
Basket entities fixes.
MarketTimer avoid dead lock
PortfolioPnLManager race condition fix.
CSV reader writer dispose fixes.
Strategy. ToReportValue
CollectionSecurityProvider, InMemorySecurityStorage fixes.
SecurityProvider. DeleteRangeAsync fixes.
OptionTests more tests.
IStatisticParameter implemented IDisposable
EntityCache fix order state update.
EntityCache cleanup fix.
RiskCommissionRule ignores zero level.
CommissionRule. EnterScope method.
RiskTransactionCommissionRule ignore zero commission level.
IRiskRule removed ILogSource inheritance.
TickCandleBuilderValueTransform fix handle null price.
RiskPositionSizeRule, RiskSlippageRule. Ignore zero levels.
RiskRuleProvider race condition fixes.
ICustomProvider<T> interface.
Reporting -> Reporting.
Fix resource cleanup.
IMessageAdapter. HeartbeatBeforConnect -> HeartbeatBeforeConnect
create separate Algo.Reporting project
make EntityCache public with XML documentation
add IReportSource interface to decouple reports from Strategy
refactor ISecurityMappingStorage to use provider/storage pattern
refactor: ExcelReportGenerator accept Stream instead of template file path
fix OfflineManager OrderCancel handling when offline
fix TransactionOrderingManager trade suspension bug
refactor Connector subscription manager
refactor CandleBuilder manager
refactor Subscription manager
refactor TransactionOrdering manager
refactor SnapshotHolder manager
refactor SecurityNativeId manager
refactor SecurityMapping manager
refactor OrderBookTruncate manager
refactor OrderBookIncrement manager
refactor Offline manager
refactor Level1DepthBuilder manager
refactor subscription managers
refactor candle builder manager
refactor connector subscription manager
IFileSystem abstraction for storage classes.
Refactored NativeIdStorage to use provider pattern
Fixed CsvNativeIdStorage shared buffer bug causing data to be written to wrong files
Fixed IFileSystem usage in CsvEntityRegistry.InitAsync and added long-lived TransactionFileStream tests
Refactored CSV storage to use IAsyncDisposable
CsvEntityList/CsvEntityRegistry: IFileSystem support + cleanup
CSV storages: IFileSystem support + writer flush fix
INativeIdStorage. Async model.
IMessageChannel. SendInMessage -> SendInMessageAsync
Returns message to send outside lock
IMessageAdapter. NewOutMessageAsync
IAsyncEnu->IEnu converter usage.
IFillGapsBehaviour. TryGetNextGapAsync
StorageHelper_Obsolete
StorageHelper. GetDates marked as obsolete.
IAsyncEnumerable<T> impl refactoring.
ToBasket supported IAsyncEnumerable.
StorageHelper. LoadMessagesAsync
IStorageProcessor. ProcessMarketData returns IAsyncEnumerable.
Candles compression supported IAsyncEnumerable.
BaseExporter. Supported IAsyncEnumerable
GetDatesAsync.
OrderBookTruncateMessageAdapter. Fix processing subscription request.
StorageBuffer. Fix skip generated messages.
IStorageBuffer, IStorageProcessor, ISnapshotRegistry
Storages. Init -> InitAsync.
Derivatives refactoring.
NumericCircularBufferEx
IMessageAdapter. SendInMessage fully replaced by SendInMessageAsync
CandleBuilderMessageAdapter. Fix calc stop subscriptions.
IAsyncMessageAdapter merged with IMessageAdapter.
SyncMessageAdapter.
IAsyncMessageAdapter. ProcessMessageAsync -> SendInMessageAsync
IMessageAdapter. Removed IMessageChannel inheritance.
UnitTypes. Limit made obsolete.
MarketRule fixes.
MarketRule fixes.
Lock usage.
MarketRule fixes.
MarketRule fixes.
StorageHelper. GetFromDate, GetToDate marked as obsolete.
DelayAction -> ChannelExecutor
.net 10 supported
ISecurityStorage. Async mode.
ISecurityProvider. Async mode.
DateTimeOffset -> DateTime UTC
MarketEmulator. Fix PortfolioLookupMessage
CSV Import depth. Timestamp has milliseconds.
Risk management. Block trading until release state.
OrderGroupCancelModes
SecurityMappingMessageAdapter, SecurityNativeIdMessageAdapter. Ignores SecId.IsSpecial
CsvImporter refactoring.
FieldMapping. Uses UTC
CsvImporter. Fix progress
PnLQueue. Fix reset last trade price.
RiskCommissionRule, RuskPnLRule fixes.
IMarketDataDrive uses async mode.
IMessageAdapter. SendOutMessage
Fix stale price bug in PnL calculation
CsvParser. TimeZone removed.
CsvParser uses async model.
BaseExporter uses async model.
BaseExporter. Uses Stream.
IReportGenerator. Encoding property.
IReportGenerator. Generate accepts Stream.
CsvParser. file name -> stream
ExcelExporter fixes.
Fix corrupted comment encoding in CandleHelper.cs
Fix critical bugs in Algo/Candles volume profile calculations
IMarketDataStorageInfo removed as obsolete.
IMessageStorageRegistry removed as obsolete.
Position. ServerTime made as primary.
StrategyPositionManager fixes.
StrategyPositionManager fixes.
StrategyPositionManager fixes.
StrategyPositionManager fixes.
StrategyPositionManager fixes.
StrategyPositionManager fixes.
StrategyPositionManager fixes.
StrategyPositionManager fixes.
ExecutionTypes made as internal only.
Storage. Usage DataType overload as primary.
StrategyPositionManager fixes.
StrategyPositionManager fixes.
IConnector. MarketTimeChanged removed as obsolete.
Subscription. CandleSeries removed as obsolete.
CsvEntityRegistry. Storage removed as obsolete.
BatchEmulation removed as obsolete.
IMarketDataProvider. SessionStateChanged, LookupBoardsResult, LookupTimeFramesResult removed as obsolete.
ITransactionProvider. OrderStatusFailed2 removed as obsolete.
StrategyParam. SetRange, SetStep for TimeSpan, Unit and decimal fixes.
Strategy. Removed obsolete methods.
IEntityFactory removed as obsolete.
BasketStrategy removed as obsolete.
LocalMarketDataDrive. GetAvailableSecurities removed as obsolete.
Entity storages support removed.
ServicesRegistry. IConnector removed as obsolete.
MyTrade. Trade is ITickTradeMessage
IndicatorValue. ValuesAsDecimal removed as obsolete.
StorageMetaInfoMessageAdapter. Load removed as obsolete.
IEntityRegistry as obsolete.
UnitRangeAttribute
LocalMarketDataDrive. Index made public and covered by tests.
RelativeStrengthIndex fix.
MoneyFlowIndex. Fix overflow
ConstanceBrownCompositeIndex fixes.
IIndicatorValue. Fix restore state.
ICandleMessage. GetTypicalPrice, GetMedianPrice extensions.
IComplexIndicatorValue inheritance.
Strategy. IndicatorSource
StrategyTradingModes. LongOnly
Strategy. CreateTimer, StartTimer methods. TimeFrameStrategy made obsolete.
IIndicator. Preload values.
StrategyPositionManager moved into separated file.
PercentagePriceOscillator fixes.
PercentagePriceOscillatorSignal
PercentagePriceOscillatorHistogram
Strategy_HighLevel. More Bind overloads.
IIndicator. Source property.
StrategyParam. SetPositive removed. SetStep fixes. UnitValidationAttributes
StrategyParam. SetStep
StrategyParam. SetPositive method.
ISubscriptionHandler non generic version. ISubscriptionHandler. Stop method.
RankCorrelationIndex
Median
TrueStrengthIndex
Shift indicator.
DeMarker
ElderRay
BullPower
BearPower
AroonOscillator
Fix ALL subscriptions.