Skip to content

Commit

Permalink
C# 7.0 features.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikasoukhov committed Jun 3, 2018
1 parent 3c8f3b5 commit eebb78a
Show file tree
Hide file tree
Showing 89 changed files with 191 additions and 817 deletions.
5 changes: 1 addition & 4 deletions Algo/BasketMessageAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,7 @@ private void ProcessPortfolioMessage(string portfolioName, Message message)
{
var a = _hearbeatAdapters.TryGetValue(adapter);

if (a == null)
throw new InvalidOperationException(LocalizedStrings.Str1838Params.Put(adapter.GetType()));

adapter = a;
adapter = a ?? throw new InvalidOperationException(LocalizedStrings.Str1838Params.Put(adapter.GetType()));
}

adapter.SendInMessage(message);
Expand Down
10 changes: 2 additions & 8 deletions Algo/BasketPortfolio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ private sealed class WeightedPosition : BasketPosition
{
public WeightedPosition(WeightedPortfolio portfolio, IEnumerable<Position> innerPositions)
{
if (innerPositions == null)
throw new ArgumentNullException(nameof(innerPositions));

_innerPositions = innerPositions;
_innerPositions = innerPositions ?? throw new ArgumentNullException(nameof(innerPositions));

decimal? beginValue = null;
decimal? currentValue = null;
Expand Down Expand Up @@ -99,10 +96,7 @@ public WeightedPosition(WeightedPortfolio portfolio, IEnumerable<Position> inner

public WeightsDictionary(WeightedPortfolio parent, IConnector connector)
{
if (parent == null)
throw new ArgumentNullException(nameof(parent));

_parent = parent;
_parent = parent ?? throw new ArgumentNullException(nameof(parent));
_connector = connector;
}

Expand Down
20 changes: 4 additions & 16 deletions Algo/Candles/CandleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ private sealed class SourceInfo : Disposable

public SourceInfo(ICandleSource<Candle> source, CandleManager manager)
{
if (source == null)
throw new ArgumentNullException(nameof(source));

_source = source;
_source = source ?? throw new ArgumentNullException(nameof(source));
_manager = manager;

_source.Processing += OnProcessing;
Expand Down Expand Up @@ -81,10 +78,7 @@ protected override void DisposeManaged()

public CandleManagerSourceList(CandleManager manager)
{
if (manager == null)
throw new ArgumentNullException(nameof(manager));

_manager = manager;
_manager = manager ?? throw new ArgumentNullException(nameof(manager));
}

protected override void OnAdded(ICandleSource<Candle> item)
Expand Down Expand Up @@ -136,10 +130,7 @@ private sealed class ExternalCandleSource : Disposable, ICandleSource<Candle>

public ExternalCandleSource(IExternalCandleSource source)
{
if (source == null)
throw new ArgumentNullException(nameof(source));

_source = source;
_source = source ?? throw new ArgumentNullException(nameof(source));
_source.NewCandles += OnNewCandles;
_source.Stopped += OnStopped;
}
Expand Down Expand Up @@ -222,10 +213,7 @@ private sealed class ConnectorCandleSource : Disposable, ICandleSource<Candle>

public ConnectorCandleSource(Connector connector)
{
if (connector == null)
throw new ArgumentNullException(nameof(connector));

_connector = connector;
_connector = connector ?? throw new ArgumentNullException(nameof(connector));
_connector.CandleSeriesProcessing += OnConnectorProcessingCandle;
_connector.CandleSeriesStopped += OnConnectorCandleSeriesStopped;
}
Expand Down
5 changes: 1 addition & 4 deletions Algo/Candles/CandleManagerContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ private sealed class SeriesInfo

public SeriesInfo(CandleManagerContainer container)
{
if (container == null)
throw new ArgumentNullException(nameof(container));

_container = container;
_container = container ?? throw new ArgumentNullException(nameof(container));
}

public int CandleCount => _allCandles.Count;
Expand Down
5 changes: 1 addition & 4 deletions Algo/Candles/CandlesHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ private class CandlesSeriesHolder
/// <param name="series">Candles series.</param>
public CandlesSeriesHolder(CandleSeries series)
{
if (series == null)
throw new ArgumentNullException(nameof(series));

Series = series;
Series = series ?? throw new ArgumentNullException(nameof(series));
}

/// <summary>
Expand Down
10 changes: 2 additions & 8 deletions Algo/Candles/IndexCandleBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,8 @@ private Candle CreateFilledCandle(Candle candle)

public IndexCandleBuilder(IndexSecurity security, Type candleType)
{
if (security == null)
throw new ArgumentNullException(nameof(security));

if (candleType == null)
throw new ArgumentNullException(nameof(candleType));

_security = security;
_candleType = candleType;
_security = security ?? throw new ArgumentNullException(nameof(security));
_candleType = candleType ?? throw new ArgumentNullException(nameof(candleType));
FillSecurityIndecies(_security);
_bufferSize = _securityIndecies.Values.Distinct().Count();
}
Expand Down
25 changes: 5 additions & 20 deletions Algo/Candles/IndexSecurityCandleManagerSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,18 @@ private sealed class IndexSeriesInfo : Disposable

public IndexSeriesInfo(ICandleManager candleManager, Type candleType, IEnumerable<CandleSeries> innerSeries, DateTimeOffset? from, DateTimeOffset? to, IndexSecurity security, Action<Candle> processing, Action stopped)
{
if (candleManager == null)
throw new ArgumentNullException(nameof(candleManager));

if (innerSeries == null)
throw new ArgumentNullException(nameof(innerSeries));

if (security == null)
throw new ArgumentNullException(nameof(security));

if (processing == null)
throw new ArgumentNullException(nameof(processing));

if (stopped == null)
throw new ArgumentNullException(nameof(stopped));

_candleManager = candleManager;
_candleManager = candleManager ?? throw new ArgumentNullException(nameof(candleManager));
_innerSeries = innerSeries.ToHashSet();
_from = from;
_to = to;
_processing = processing;
_stopped = stopped;
_processing = processing ?? throw new ArgumentNullException(nameof(processing));
_stopped = stopped ?? throw new ArgumentNullException(nameof(stopped));

candleManager.Processing += OnInnerSourceProcessCandle;
candleManager.Stopped += OnInnerSourceStopped;
Expand Down Expand Up @@ -153,16 +144,10 @@ protected override void DisposeManaged()

public IndexSecurityCandleManagerSource(ICandleManager candleManager, ISecurityProvider securityProvider, DateTimeOffset? from, DateTimeOffset? to)
{
if (candleManager == null)
throw new ArgumentNullException(nameof(candleManager));

if (securityProvider == null)
throw new ArgumentNullException(nameof(securityProvider));

_securityProvider = securityProvider;
_securityProvider = securityProvider ?? throw new ArgumentNullException(nameof(securityProvider));
_from = from;
_to = to;
_candleManager = candleManager;
_candleManager = candleManager ?? throw new ArgumentNullException(nameof(candleManager));
}

public int SpeedPriority => 2;
Expand Down
8 changes: 1 addition & 7 deletions Algo/Commissions/CommissionMessageAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ public CommissionMessageAdapter(IMessageAdapter innerAdapter)
public ICommissionManager CommissionManager
{
get => _commissionManager;
set
{
if (value == null)
throw new ArgumentNullException(nameof(value));

_commissionManager = value;
}
set => _commissionManager = value ?? throw new ArgumentNullException(nameof(value));
}

/// <summary>
Expand Down
5 changes: 1 addition & 4 deletions Algo/Connector_Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ private sealed class SubscriptionManager

public SubscriptionManager(Connector connector)
{
if (connector == null)
throw new ArgumentNullException(nameof(connector));

_connector = connector;
_connector = connector ?? throw new ArgumentNullException(nameof(connector));
}

public void ClearCache()
Expand Down
15 changes: 3 additions & 12 deletions Algo/Derivatives/BasketBlackScholes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ private sealed class InnerModelList : CachedSynchronizedList<BlackScholes>, IInn

public InnerModelList(BasketBlackScholes parent)
{
if (parent == null)
throw new ArgumentNullException(nameof(parent));

_parent = parent;
_parent = parent ?? throw new ArgumentNullException(nameof(parent));
}

BlackScholes IInnerModelList.this[Security option]
Expand Down Expand Up @@ -87,11 +84,8 @@ protected override bool OnInserting(int index, BlackScholes item)
public BasketBlackScholes(ISecurityProvider securityProvider, IMarketDataProvider dataProvider, IPositionProvider positionProvider)
: base(securityProvider, dataProvider)
{
if (positionProvider == null)
throw new ArgumentNullException(nameof(positionProvider));

_innerModels = new InnerModelList(this);
PositionProvider = positionProvider;
PositionProvider = positionProvider ?? throw new ArgumentNullException(nameof(positionProvider));
}

/// <summary>
Expand All @@ -103,12 +97,9 @@ public BasketBlackScholes(ISecurityProvider securityProvider, IMarketDataProvide
public BasketBlackScholes(Security underlyingAsset, IMarketDataProvider dataProvider, IPositionProvider positionProvider)
: base(underlyingAsset, dataProvider)
{
if (positionProvider == null)
throw new ArgumentNullException(nameof(positionProvider));

_innerModels = new InnerModelList(this);
UnderlyingAsset = underlyingAsset;
PositionProvider = positionProvider;
PositionProvider = positionProvider ?? throw new ArgumentNullException(nameof(positionProvider));
}

/// <summary>
Expand Down
25 changes: 5 additions & 20 deletions Algo/Derivatives/BasketStrike.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,9 @@ public abstract class BasketStrike : BasketSecurity
/// <param name="dataProvider">The market data provider.</param>
protected BasketStrike(Security underlyingAsset, ISecurityProvider securityProvider, IMarketDataProvider dataProvider)
{
if (underlyingAsset == null)
throw new ArgumentNullException(nameof(underlyingAsset));

if (securityProvider == null)
throw new ArgumentNullException(nameof(securityProvider));

if (dataProvider == null)
throw new ArgumentNullException(nameof(dataProvider));

UnderlyingAsset = underlyingAsset;
SecurityProvider = securityProvider;
DataProvider = dataProvider;
UnderlyingAsset = underlyingAsset ?? throw new ArgumentNullException(nameof(underlyingAsset));
SecurityProvider = securityProvider ?? throw new ArgumentNullException(nameof(securityProvider));
DataProvider = dataProvider ?? throw new ArgumentNullException(nameof(dataProvider));
}

/// <summary>
Expand Down Expand Up @@ -110,10 +101,7 @@ public class OffsetBasketStrike : BasketStrike
public OffsetBasketStrike(Security underlyingSecurity, ISecurityProvider securityProvider, IMarketDataProvider dataProvider, Range<int> strikeOffset)
: base(underlyingSecurity, securityProvider, dataProvider)
{
if (strikeOffset == null)
throw new ArgumentNullException(nameof(strikeOffset));

_strikeOffset = strikeOffset;
_strikeOffset = strikeOffset ?? throw new ArgumentNullException(nameof(strikeOffset));
}

/// <summary>
Expand Down Expand Up @@ -180,10 +168,7 @@ public class VolatilityBasketStrike : BasketStrike
public VolatilityBasketStrike(Security underlyingAsset, ISecurityProvider securityProvider, IMarketDataProvider dataProvider, Range<decimal> volatilityRange)
: base(underlyingAsset, securityProvider, dataProvider)
{
if (volatilityRange == null)
throw new ArgumentNullException(nameof(volatilityRange));

_volatilityRange = volatilityRange;
_volatilityRange = volatilityRange ?? throw new ArgumentNullException(nameof(volatilityRange));
}

/// <summary>
Expand Down
30 changes: 6 additions & 24 deletions Algo/Derivatives/BlackScholes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,8 @@ public class BlackScholes : IBlackScholes
/// <param name="dataProvider">The market data provider.</param>
protected BlackScholes(ISecurityProvider securityProvider, IMarketDataProvider dataProvider)
{
if (securityProvider == null)
throw new ArgumentNullException(nameof(securityProvider));

if (dataProvider == null)
throw new ArgumentNullException(nameof(dataProvider));

SecurityProvider = securityProvider;
DataProvider = dataProvider;
SecurityProvider = securityProvider ?? throw new ArgumentNullException(nameof(securityProvider));
DataProvider = dataProvider ?? throw new ArgumentNullException(nameof(dataProvider));
}

/// <summary>
Expand All @@ -54,10 +48,7 @@ protected BlackScholes(ISecurityProvider securityProvider, IMarketDataProvider d
public BlackScholes(Security option, ISecurityProvider securityProvider, IMarketDataProvider dataProvider)
: this(securityProvider, dataProvider)
{
if (option == null)
throw new ArgumentNullException(nameof(option));

Option = option;
Option = option ?? throw new ArgumentNullException(nameof(option));
}

/// <summary>
Expand All @@ -67,14 +58,8 @@ public BlackScholes(Security option, ISecurityProvider securityProvider, IMarket
/// <param name="dataProvider">The market data provider.</param>
protected BlackScholes(Security underlyingAsset, IMarketDataProvider dataProvider)
{
if (underlyingAsset == null)
throw new ArgumentNullException(nameof(underlyingAsset));

if (dataProvider == null)
throw new ArgumentNullException(nameof(dataProvider));

_underlyingAsset = underlyingAsset;
DataProvider = dataProvider;
_underlyingAsset = underlyingAsset ?? throw new ArgumentNullException(nameof(underlyingAsset));
DataProvider = dataProvider ?? throw new ArgumentNullException(nameof(dataProvider));
}

/// <summary>
Expand All @@ -86,10 +71,7 @@ protected BlackScholes(Security underlyingAsset, IMarketDataProvider dataProvide
public BlackScholes(Security option, Security underlyingAsset, IMarketDataProvider dataProvider)
: this(underlyingAsset, dataProvider)
{
if (option == null)
throw new ArgumentNullException(nameof(option));

Option = option;
Option = option ?? throw new ArgumentNullException(nameof(option));
}

/// <summary>
Expand Down
10 changes: 2 additions & 8 deletions Algo/Derivatives/Synthetic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,8 @@ public class Synthetic
/// <param name="provider">The provider of information about instruments.</param>
public Synthetic(Security security, ISecurityProvider provider)
{
if (security == null)
throw new ArgumentNullException(nameof(security));

if (provider == null)
throw new ArgumentNullException(nameof(provider));

_security = security;
_provider = provider;
_security = security ?? throw new ArgumentNullException(nameof(security));
_provider = provider ?? throw new ArgumentNullException(nameof(provider));
}

private Security Option
Expand Down
Loading

0 comments on commit eebb78a

Please sign in to comment.