using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace CryptoExchange.Net.SharedApis
{
///
/// Symbol request
///
public record SharedSymbolRequest : SharedRequest
{
///
/// Trading mode
///
public TradingMode TradingMode { get; }
///
/// The symbol
///
public SharedSymbol? Symbol { get; set; }
///
/// Symbols
///
public SharedSymbol[]? Symbols { get; set; }
///
/// ctor
///
public SharedSymbolRequest(SharedSymbol symbol, ExchangeParameters? exchangeParameters = null) : base(exchangeParameters)
{
Symbol = symbol;
TradingMode = symbol.TradingMode;
}
///
/// ctor
///
public SharedSymbolRequest(IEnumerable symbols, ExchangeParameters? exchangeParameters = null) : base(exchangeParameters)
{
if (!symbols.Any())
throw new ArgumentException("Empty symbol list");
if (symbols.GroupBy(x => x.TradingMode).Count() > 1)
throw new ArgumentException("All symbols in the symbol list should have the same trading mode");
Symbols = symbols.ToArray();
TradingMode = Symbols.First().TradingMode;
}
}
}