check pt: misc changes
This commit is contained in:
1 parent
bb7f16089f
commit
a020c2c97e
13 files changed
+375
-331
No files matched your search
@@ -25,9 +25,15 @@ namespace BCG {
|
||||
|
||||
public static bool isAllowedType(Type type) =>
|
||||
type == typeof(bool) ||
|
||||
type == typeof(sbyte) ||
|
||||
type == typeof(byte) ||
|
||||
type == typeof(short) ||
|
||||
type == typeof(int) ||
|
||||
type == typeof(long) ||
|
||||
type == typeof(ushort) ||
|
||||
type == typeof(uint) ||
|
||||
type == typeof(ulong) ||
|
||||
type == typeof(float) ||
|
||||
type == typeof(double) ||
|
||||
type == typeof(string) ||
|
||||
type == typeof(DateTime) ||
|
||||
|
||||
+49
-31
@@ -2,49 +2,67 @@ namespace Bts.SharedStreams.MarketData;
|
||||
|
||||
using bts.api;
|
||||
|
||||
using Bts.DataStreamCore;
|
||||
using Bts.DataStreamCore.StreamFactories;
|
||||
|
||||
public class HistoricBboParams {
|
||||
[StreamArgumentConstructor(false)]
|
||||
public HistoricBboParams() { }
|
||||
|
||||
public HistoricBboParams(string venueStr, string asset)
|
||||
: this(MarketDataArgStore.ParseVenue(venueStr), asset, null) { }
|
||||
|
||||
public HistoricBboParams(string venueStr, string asset, string typeStr)
|
||||
: this(MarketDataArgStore.ParseVenue(venueStr), asset, MarketDataArgStore.ParseSecurityType(typeStr)) { }
|
||||
|
||||
public HistoricBboParams(string venueStr, string asset, string typeStr, DateTime date)
|
||||
: this(MarketDataArgStore.ParseVenue(venueStr), asset, MarketDataArgStore.ParseSecurityType(typeStr), date) { }
|
||||
|
||||
public HistoricBboParams(string venueStr, string asset, string typeStr, DateTime beginDate, DateTime endDate)
|
||||
: this(MarketDataArgStore.ParseVenue(venueStr), asset, MarketDataArgStore.ParseSecurityType(typeStr), beginDate, endDate) { }
|
||||
|
||||
public HistoricBboParams(string venueStr, string asset, DateTime date)
|
||||
: this(MarketDataArgStore.ParseVenue(venueStr), asset, date) { }
|
||||
|
||||
public HistoricBboParams(Venue venue, string asset, DateTime date)
|
||||
: this(venue, asset, null, date) { }
|
||||
|
||||
public HistoricBboParams(Venue venue, string asset, DateTime beginDate, DateTime endDate)
|
||||
: this(venue, asset, null, beginDate, endDate) { }
|
||||
|
||||
public HistoricBboParams(Venue venue, string asset, SecurityType? type) {
|
||||
Venue = venue;
|
||||
Asset = asset;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public HistoricBboParams(Venue venue, string asset, SecurityType? type, DateTime date)
|
||||
: this(venue, asset, type, date, date.AddDays(1)) { }
|
||||
|
||||
public HistoricBboParams(Venue venue, string asset, SecurityType? type, DateTime beginDate, DateTime endDate) {
|
||||
public HistoricBboParams(
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.VenueRegex }, ParserType = typeof(VenueArgumentParser), DefaultValue = null)] Venue? venue,
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.AssetRegex }, DefaultValue = null)] string? asset,
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.TypeRegex }, ParserType = typeof(SecurityTypeArgumentParser), DefaultValue = null)] SecurityType? type,
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.SecurityNameRegex }, DefaultValue = null)] string? name,
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.BeginDateRegex}, ParserType = typeof(DateTimeArgumentParser), DefaultValue = null)] DateTime? beginDate,
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.BeginDateRegex}, ParserType = typeof(DateTimeArgumentParser), DefaultValue = null)] DateTime? endDate
|
||||
) {
|
||||
Venue = venue;
|
||||
Asset = asset;
|
||||
Type = type;
|
||||
Name = name;
|
||||
BeginDate = beginDate;
|
||||
EndDate = endDate;
|
||||
}
|
||||
|
||||
// public HistoricBboParams(string venueStr, string asset)
|
||||
// : this(MarketDataArgStore.ParseVenue(venueStr), asset, null) { }
|
||||
|
||||
// public HistoricBboParams(string venueStr, string asset, string typeStr)
|
||||
// : this(MarketDataArgStore.ParseVenue(venueStr), asset, MarketDataArgStore.ParseSecurityType(typeStr)) { }
|
||||
|
||||
// public HistoricBboParams(string venueStr, string asset, string typeStr, DateTime date)
|
||||
// : this(MarketDataArgStore.ParseVenue(venueStr), asset, MarketDataArgStore.ParseSecurityType(typeStr), date) { }
|
||||
|
||||
// public HistoricBboParams(string venueStr, string asset, string typeStr, DateTime beginDate, DateTime endDate)
|
||||
// : this(MarketDataArgStore.ParseVenue(venueStr), asset, MarketDataArgStore.ParseSecurityType(typeStr), beginDate, endDate) { }
|
||||
|
||||
// public HistoricBboParams(string venueStr, string asset, DateTime date)
|
||||
// : this(MarketDataArgStore.ParseVenue(venueStr), asset, date) { }
|
||||
|
||||
// public HistoricBboParams(Venue venue, string asset, DateTime date)
|
||||
// : this(venue, asset, null, date) { }
|
||||
|
||||
// public HistoricBboParams(Venue venue, string asset, DateTime beginDate, DateTime endDate)
|
||||
// : this(venue, asset, null, beginDate, endDate) { }
|
||||
|
||||
// public HistoricBboParams(Venue venue, string asset, SecurityType? type) {
|
||||
// Venue = venue;
|
||||
// Asset = asset;
|
||||
// Type = type;
|
||||
// }
|
||||
|
||||
// public HistoricBboParams(Venue venue, string asset, SecurityType? type, DateTime date)
|
||||
// : this(venue, asset, type, date, date.AddDays(1)) { }
|
||||
|
||||
// public HistoricBboParams(Venue venue, string asset, SecurityType? type, DateTime beginDate, DateTime endDate) {
|
||||
// Venue = venue;
|
||||
// Asset = asset;
|
||||
// Type = type;
|
||||
// BeginDate = beginDate;
|
||||
// EndDate = endDate;
|
||||
// }
|
||||
|
||||
public Venue? Venue { get; set; }
|
||||
public string? Asset { get; set; }
|
||||
public SecurityType? Type { get; set; }
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
namespace Bts.SharedStreams.MarketData;
|
||||
|
||||
using BCG;
|
||||
|
||||
using bts.api;
|
||||
|
||||
using Bts.DataStreamCore;
|
||||
using Bts.SharedStreams.StreamFactories;
|
||||
|
||||
public class InstrumentSchemaBuilder {
|
||||
public bool ShowVenue { get; set; } = true;
|
||||
public bool ShowAsset { get; set; } = true;
|
||||
public bool ShowType { get; set; } = true;
|
||||
public bool ShowName { get; set; } = true;
|
||||
public bool ShowId { get; set; } = true;
|
||||
public bool ShowCashPerPoint { get; set; } = true;
|
||||
public bool ShowLegId { get; set; } = true;
|
||||
public bool ShowLegVenue { get; set; }
|
||||
public bool ShowLegAsset { get; set; }
|
||||
public bool ShowLegType { get; set; }
|
||||
public bool ShowLegName { get; set; } = true;
|
||||
public bool ShowLegCashPerPoint { get; set; }
|
||||
public int NumLegs { get; set; } = 2;
|
||||
public string TableName { get; set; } = "Instrument";
|
||||
|
||||
public BlueTableSchemaAdapter<SecurityImmutable> SecurityAdapter() {
|
||||
var adapter = new BlueTableSchemaAdapter<SecurityImmutable>(TableName);
|
||||
adapter.AddColumn("id", r => (int)r.Id);
|
||||
if (ShowVenue) {
|
||||
adapter.AddColumn(WellKnownColumns.Venue.Name, b => b.Exchange.ToString());
|
||||
}
|
||||
if (ShowType) {
|
||||
adapter.AddColumn(WellKnownColumns.SecurityType.Name, b => b.security_type().ToString());
|
||||
}
|
||||
if (ShowAsset) {
|
||||
adapter.AddColumn(WellKnownColumns.Asset.Name, b => b.Symbol);
|
||||
}
|
||||
if (ShowName) {
|
||||
adapter.AddColumn(WellKnownColumns.SecurityName.Name, b => b.ToString());
|
||||
}
|
||||
if (ShowId) {
|
||||
adapter.AddColumn(WellKnownColumns.SecurityId.Name, b => b.Id);
|
||||
}
|
||||
if (ShowCashPerPoint) {
|
||||
adapter.AddColumn(WellKnownColumns.CashPerPoint.Name, b => b.ContractSpec.CashPerPoint);
|
||||
}
|
||||
for (int i = 0; i < NumLegs; i++) {
|
||||
if (ShowLegVenue) {
|
||||
adapter.AddColumn(WellKnownColumns.LegVenue(i).Name, Get(l => l.Security.Exchange.ToString(), null));
|
||||
}
|
||||
if (ShowLegType) {
|
||||
adapter.AddColumn(WellKnownColumns.LegSecurityType(i).Name, Get(l => l.Security.security_type().ToString(), null));
|
||||
}
|
||||
if (ShowLegAsset) {
|
||||
adapter.AddColumn(WellKnownColumns.LegAsset(i).Name, Get(l => l.Security.Symbol, null));
|
||||
}
|
||||
if (ShowLegName) {
|
||||
adapter.AddColumn(WellKnownColumns.LegSecurityName(i).Name, Get(l => l.Security.ToString(), null));
|
||||
}
|
||||
if (ShowLegId) {
|
||||
adapter.AddColumn(WellKnownColumns.LegSecurityId(i).Name, Get(l => (int)l.Security.Id, 0));
|
||||
}
|
||||
if (ShowLegCashPerPoint) {
|
||||
adapter.AddColumn(WellKnownColumns.LegCashPerPoint(i).Name, Get(l => l.Security.ContractSpec.CashPerPoint, double.NaN));
|
||||
}
|
||||
|
||||
Func<SecurityImmutable, T> Get<T>(Func<ContractLegImmutable, T> getValue, T defaultValue) =>
|
||||
s => {
|
||||
ContractLegImmutable? leg = s.ContractCase switch {
|
||||
Security.ContractOneofCase.Spread => s.Spread.Legs.Skip(i).TryGetFirst(out var l) ? l : null,
|
||||
Security.ContractOneofCase.Synthetic => s.Synthetic.Legs.Skip(i).TryGetFirst(out var l) ? l : null,
|
||||
_ => null,
|
||||
};
|
||||
return leg.HasValue ? getValue(leg.Value) : defaultValue;
|
||||
};
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
namespace Bts.SharedStreams.MarketData;
|
||||
|
||||
using bts.api;
|
||||
|
||||
using Bts.DataStreamCore;
|
||||
|
||||
public class InstrumentStreamParams {
|
||||
[StreamArgumentConstructor(false)]
|
||||
public InstrumentStreamParams() { }
|
||||
|
||||
public InstrumentStreamParams(
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.VenueRegex })] Venue? venue) {
|
||||
Venue = venue;
|
||||
}
|
||||
|
||||
public InstrumentStreamParams(
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.VenueRegex })] SecurityType? type) {
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public InstrumentStreamParams([StreamArgument] string? name) {
|
||||
// Assign both name and asset to make the streams do what the user wants (99.9% of the time).
|
||||
// For example, if the NLM generates 'instrument("ES")' or 'instrument("ESU5")', both work.
|
||||
NameOrAsset = name;
|
||||
}
|
||||
|
||||
public InstrumentStreamParams(
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.VenueRegex }, ParserType = typeof(VenueArgumentParser), DefaultValue = null)] Venue? venue,
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.AssetRegex }, DefaultValue = null)] string? asset,
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.TypeRegex }, ParserType = typeof(SecurityTypeArgumentParser), DefaultValue = null)] SecurityType? type,
|
||||
[StreamArgument(RegexNames = new[] { "legs", "nLegs", "numLegs" }, DefaultValue = 2)] int numLegs) {
|
||||
Venue = venue;
|
||||
Asset = asset;
|
||||
Type = type;
|
||||
NumLegs = numLegs;
|
||||
}
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.VenueRegex })]
|
||||
public Venue? Venue { get; set; }
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.AssetRegex })]
|
||||
public string? Asset { get; set; }
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.SecurityTypeRegex })]
|
||||
public SecurityType? Type { get; set; }
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.SecurityNameRegex })]
|
||||
public string? Name { get; set; }
|
||||
|
||||
public string? NameOrAsset { get; set; }
|
||||
|
||||
[StreamArgument("legs", "nLegs", "numLegs")]
|
||||
public int NumLegs { get; set; } = 2;
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.ShowVenueRegex })]
|
||||
public bool ShowVenue { get; set; } = true;
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.ShowSecurityTypeRegex })]
|
||||
public bool ShowType { get; set; } = true;
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.ShowAssetRegex })]
|
||||
public bool ShowAsset { get; set; } = true;
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.ShowCashPerPointRegex })]
|
||||
public bool ShowCashPerPoint { get; set; } = true;
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.ShowLegVenueRegex })]
|
||||
public bool ShowLegVenue { get; set; } = true;
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.ShowLegSecurityTypeRegex })]
|
||||
public bool ShowLegType { get; set; } = true;
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.ShowLegSymbolRegex })]
|
||||
public bool ShowLegAsset { get; set; } = true;
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.ShowLegCashPerPointRegex })]
|
||||
public bool ShowLegCashPerPoint { get; set; } = true;
|
||||
|
||||
public Func<SecurityImmutable, bool> GetSecurityFilter() {
|
||||
return SecurityFilter;
|
||||
|
||||
bool SecurityFilter(SecurityImmutable s) {
|
||||
if (Venue.HasValue && Venue.Value != s.Exchange) {
|
||||
return false;
|
||||
}
|
||||
if (Type.HasValue && Type != s.security_type()) {
|
||||
return false;
|
||||
}
|
||||
if (Asset is not null && Asset != s.Symbol) {
|
||||
return false;
|
||||
}
|
||||
if (Name is not null && Name != s.ToString()) {
|
||||
return false;
|
||||
}
|
||||
if (NameOrAsset is not null && NameOrAsset != s.Symbol && NameOrAsset != s.ToString()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public mbts.spark.SecurityCriteria GetSecurityCriteria() {
|
||||
var clause = new mbts.spark.SecurityCriteriaClause(
|
||||
exchanges: Venue.HasValue ? new[] { Venue.Value } : null,
|
||||
security_types: Type.HasValue ? new[] { Type.Value } : null,
|
||||
symbols: !string.IsNullOrEmpty(Asset) ? new[] { Asset } : null,
|
||||
names: !string.IsNullOrEmpty(Name) ? new[] { Name } : null);
|
||||
return clause.is_defined ? new(new[] { clause }) : new();
|
||||
}
|
||||
|
||||
public InstrumentSchemaBuilder GetSchemaBuilder() =>
|
||||
new() {
|
||||
NumLegs = NumLegs,
|
||||
ShowVenue = ShowVenue,
|
||||
ShowType = true,
|
||||
ShowAsset = true,
|
||||
ShowName = true,
|
||||
ShowId = true,
|
||||
ShowCashPerPoint = ShowCashPerPoint,
|
||||
};
|
||||
}
|
||||
@@ -1,25 +1,53 @@
|
||||
namespace bts.BlueOrb {
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
using BCG;
|
||||
|
||||
using bts.api;
|
||||
using bts.collections;
|
||||
|
||||
using Bts.DataStream;
|
||||
using Bts.DataStreamCore;
|
||||
using Bts.SharedStreams.StreamFactories;
|
||||
|
||||
using mbts.spark;
|
||||
|
||||
using Spark.Api.MarketData;
|
||||
|
||||
[DataStreamUserRespresentation(false)]
|
||||
public class LiveTradeStream : ViewStream {
|
||||
public LiveTradeStream(string target)
|
||||
: this(SecurityType.Future, target) { }
|
||||
public LiveTradeStream(SecurityType sec_type, string target) {
|
||||
ViewStream rs = null;
|
||||
switch (sec_type) {
|
||||
case SecurityType.Future:
|
||||
rs = new LiveFuturesTradeStream(target);
|
||||
break;
|
||||
default:
|
||||
Log.assert(false);
|
||||
break;
|
||||
}
|
||||
mySetRealSource(rs);
|
||||
// public LiveTradeStream(string target)
|
||||
// : this(SecurityType.Future, target) { }
|
||||
// public LiveTradeStream(SecurityType sec_type, string target) {
|
||||
// ViewStream rs = null;
|
||||
// switch (sec_type) {
|
||||
// case SecurityType.Future:
|
||||
// rs = new LiveFuturesTradeStream(target);
|
||||
// break;
|
||||
// default:
|
||||
// Log.assert(false);
|
||||
// break;
|
||||
// }
|
||||
// mySetRealSource(rs);
|
||||
// }
|
||||
|
||||
public LiveTradeStream(IMarketDataClient mdClient, TradeStreamParams opts) {
|
||||
var schemaBd = opts.GetSchemaBuilder();
|
||||
var tradeDps = TradeStream(mdClient.Trades(opts.GetSecurityCriteria()), schemaBd.ToSchema(), schemaBd.TradeInfoAdapter());
|
||||
var vs = tradeDps.AsViewStream();
|
||||
mySetRealSource(vs);
|
||||
}
|
||||
|
||||
public static IObservable<IDataPacket> TradeStream(IObservable<IList<TradeInfo>> trades, IBlueTableSchema tradeSchema, BlueTableSchemaAdapter<TradeInfo> tradeAdapter) =>
|
||||
trades.Scan((IDataPacket)null!, (dp, trades) => {
|
||||
var rowList = trades.WrapSelector(t => (IBlueRow)new BlueRowAdapter<TradeInfo>(tradeAdapter, t), null);
|
||||
var lastTable = dp?.newRows as BlueTableImmutable ?? new BlueTableImmutable(tradeSchema);
|
||||
var bd = lastTable.ToDataPacketBuilder();
|
||||
foreach (var t in trades) {
|
||||
bd.AddOrUpdate(new BlueRowAdapter<TradeInfo>(tradeAdapter, t));
|
||||
}
|
||||
return bd.ToDataPacket();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -32,48 +32,17 @@ public class BookStreamFactory : DataStreamFactory, IRecursiveDataStreamFactory
|
||||
this.mdClient = mdClient;
|
||||
this.logger = logger;
|
||||
this.workScheduler = workScheduler;
|
||||
this.Add<BookStreamParams>(new[] { "book" }, CreateBook, logger, TryGetBookStreamParams);
|
||||
this.Add<BookStreamParams>(new[] { "bbo" }, CreateBbo, logger, TryGetBookStreamParams);
|
||||
this.Add<BookStreamParams>(new[] { "bboPriceSummary" }, createBboPriceSummary, logger, TryGetBookStreamParams);
|
||||
this.Add<BookStreamParams>(new[] { "book" }, CreateBook, logger);
|
||||
this.Add<BookStreamParams>(new[] { "bbo" }, CreateBbo, logger);
|
||||
this.Add<BookStreamParams>(new[] { "bboPriceSummary" }, createBboPriceSummary, logger);
|
||||
liveBboFactory = new LiveBboStreamFactory(mdClient, logger);
|
||||
Add(liveBboFactory);
|
||||
|
||||
bool TryGetBookStreamParams(IEnumerable<(string? Name, int? Index, object? Value)> args, [NotNullWhen(true)]out BookStreamParams? result, [NotNullWhen(false)]out string? errorMsg) {
|
||||
var argList = args.ToList();
|
||||
if (argList.Count == 0) {
|
||||
errorMsg = "Missing required parameters (symbol)";
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
if (!StreamFactoryArgStore.TryGetParams(args, out result, out errorMsg)) {
|
||||
result = new();
|
||||
}
|
||||
var mdArgStore = new MarketDataArgStore(argList, "bboPriceSummary", logger);
|
||||
if (!result.Venue.HasValue) {
|
||||
result.Venue = mdArgStore.GetVenue(required: false);
|
||||
}
|
||||
if (string.IsNullOrEmpty(result.Asset)) {
|
||||
result.Asset = mdArgStore.GetSymbol(required: false);
|
||||
}
|
||||
if (string.IsNullOrEmpty(result.SecurityName)) {
|
||||
result.SecurityName = mdArgStore.GetSecurityName(required: false);
|
||||
}
|
||||
if (!result.SecurityType.HasValue) {
|
||||
result.SecurityType = mdArgStore.GetSecurityType(required: false);
|
||||
}
|
||||
if (string.IsNullOrEmpty(result.Asset) && string.IsNullOrEmpty(result.SecurityName)) {
|
||||
errorMsg = "Missing required parameters (symbol OR securityName)";
|
||||
return false;
|
||||
}
|
||||
errorMsg = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
ViewStream? CreateBook(BookStreamParams streamParams) {
|
||||
if (!checkHasLiveMd()) {
|
||||
return null;
|
||||
}
|
||||
return this.mdClient.Books(streamParams.GetSecurityCriteria())
|
||||
return this.mdClient.Books(streamParams.GetSecurityFilter())
|
||||
.AsDataPackets(streamParams.GetSchemaBuilder().BookTupleAdapter())
|
||||
.AsViewStream()
|
||||
.TimeSeries(streamParams.BufferSize, WellKnownColumnNames.Timestamp);
|
||||
@@ -83,7 +52,7 @@ public class BookStreamFactory : DataStreamFactory, IRecursiveDataStreamFactory
|
||||
if (!checkHasLiveMd()) {
|
||||
return null;
|
||||
}
|
||||
return this.mdClient.Books(streamParams.GetSecurityCriteria())
|
||||
return this.mdClient.Books(streamParams.GetSecurityFilter())
|
||||
.AsDataPackets(streamParams.GetSchemaBuilder().BboAdapter())
|
||||
.AsViewStream()
|
||||
.TimeSeries(streamParams.BufferSize, WellKnownColumnNames.Timestamp);
|
||||
@@ -99,7 +68,7 @@ public class BookStreamFactory : DataStreamFactory, IRecursiveDataStreamFactory
|
||||
if (!checkHasLiveMd()) {
|
||||
return null;
|
||||
}
|
||||
var secCriteria = streamParams.GetSecurityCriteria();
|
||||
var secCriteria = streamParams.GetSecurityFilter();
|
||||
mdClient.Books(secCriteria).WithHistory().Select(t => t.Table);
|
||||
// var bboStream = mdClient.Books(secCriteria).AsDataPackets(streamParams.GetSchemaBuilder().BboAdapter());
|
||||
var bboStream = liveBboFactory.Create(streamParams)
|
||||
@@ -117,7 +86,7 @@ public class BookStreamFactory : DataStreamFactory, IRecursiveDataStreamFactory
|
||||
var tradeSchemaBd = new TradeSchemaBuilder();
|
||||
var tradeSchema = tradeSchemaBd.ToSchema();
|
||||
var tradeAdapter = tradeSchemaBd.TradeInfoAdapter();
|
||||
tradeStream = TradeStreamFactory.TradeStream(mdClient.Trades(secCriteria), tradeSchema, tradeAdapter).AsViewStream();
|
||||
tradeStream = LiveTradeStream.TradeStream(mdClient.Trades(secCriteria), tradeSchema, tradeAdapter).AsViewStream();
|
||||
}
|
||||
var bboPriceSummaryStream = new BboPriceSummaryStream(bboStream.AsObservable(), tradeStream.AsObservable(), workScheduler, TimeSpan.FromSeconds(1));
|
||||
return bboPriceSummaryStream;
|
||||
@@ -161,7 +130,7 @@ public class BookStreamFactory : DataStreamFactory, IRecursiveDataStreamFactory
|
||||
public void OnCompositeFactory(IDataStreamFactory compositeFactory) =>
|
||||
this.compositeFactory = compositeFactory;
|
||||
|
||||
public ViewStream? Create(string streamId, IEnumerable<(string? Name, int? Index, object? Value)> args) {
|
||||
public ViewStream? Create(string streamId, IEnumerable<StreamArgument> args) {
|
||||
if (!metadata.IsMatch(streamId)) {
|
||||
return null;
|
||||
}
|
||||
@@ -211,7 +180,7 @@ public class BookStreamFactory : DataStreamFactory, IRecursiveDataStreamFactory
|
||||
if (!checkHasLiveMd()) {
|
||||
return null;
|
||||
}
|
||||
return mdClient.Books(streamParams.GetSecurityCriteria())
|
||||
return mdClient.Books(streamParams.GetSecurityFilter())
|
||||
.AsDataPackets(streamParams.GetSchemaBuilder().BboAdapter())
|
||||
.AsViewStream();
|
||||
}
|
||||
|
||||
@@ -40,54 +40,13 @@ class HistoricParquetDataLoader : DataStreamFactory {
|
||||
throw new ArgumentException("Failed to parse SecurityType", nameof(secTypeStr));
|
||||
}
|
||||
|
||||
// static Venue? ParseVenueArg(string? venueStr) {
|
||||
// if (string.IsNullOrEmpty(venueStr)) {
|
||||
// return null;
|
||||
// }
|
||||
// if (MarketDataArgStore.TryParseVenue(venueStr, out var venue)) {
|
||||
// return venue;
|
||||
// }
|
||||
// throw new ArgumentException("Failed to parse Venue", nameof(venueStr));
|
||||
// }
|
||||
|
||||
// bool TryGetHistoricInstrumentStreamParams(IEnumerable<(string? Name, int? Index, object? Value)> args, [NotNullWhen(true)] out HistoricInstrumentStreamParams? result, [NotNullWhen(false)] out string? errorMessage) {
|
||||
// var argList = args.ToList();
|
||||
// result = null;
|
||||
// errorMessage = null;
|
||||
// switch (argList.Count) {
|
||||
// case 2: {
|
||||
// var venue = ParseVenueArg(argList[0].Value as string);
|
||||
// var asset = argList[1].Value as string;
|
||||
// if (venue.HasValue && asset is not null) {
|
||||
// var secType = SecurityType.Future;
|
||||
// if (DatabentoFileStore.GetDataFiles("definition", asset, secType).TryGetMaxElement(f => f.Date, out var latestFile)) {
|
||||
// result = new(venue.Value, asset, latestFile.Date) {
|
||||
// Type = secType,
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case 3: {
|
||||
// var venue = ParseVenueArg(argList[0].Value as string);
|
||||
// var asset = argList[1].Value as string;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (result is not null) {
|
||||
// return true;
|
||||
// }
|
||||
// errorMessage ??= "Failed to convert args to HistoricInstrumentStreamParams";
|
||||
// return false;
|
||||
// }
|
||||
|
||||
ViewStream? CreateReplayFutureLiveBbo(ReplayFutureLiveBboParams opts) {
|
||||
if (opts.ContinuousContract is null) {
|
||||
logger.LogMissingParam("ReplayFutureLiveBBOStream", nameof(opts.ContinuousContract));
|
||||
if (opts.Name is null) {
|
||||
logger.LogMissingParam("ReplayFutureLiveBBOStream", nameof(opts.Name));
|
||||
return null;
|
||||
}
|
||||
Func<IBlueRow, bool>? filter = opts.ContinuousContract == "ES" ? ContractFilter : null;
|
||||
var tables = DatabentoFileStore.GetBboAsync(opts.ContinuousContract, ParseSecTypeArg(opts.SecurityType), opts.BeginDate, opts.EndDate, filter);
|
||||
Func<IBlueRow, bool>? filter = opts.Name == "ES" ? ContractFilter : null;
|
||||
var tables = DatabentoFileStore.GetBboAsync(opts.Name, opts.SecurityType, opts.BeginDate, opts.EndDate, filter);
|
||||
// var continuousContracts = HistoricContinuousContractStream.Create(new() { Symbol = opts.ContinuousContract, SecurityType = SecurityType.Future, BeginDate = opts.BeginDate, EndDate = opts.EndDate }, viewStreamDatabase, logger);
|
||||
return ReplayStream.Create(tables, "ts_event", opts.ReplaySpeed, viewStreamDatabase);
|
||||
|
||||
@@ -142,11 +101,15 @@ class HistoricParquetDataLoader : DataStreamFactory {
|
||||
}
|
||||
|
||||
class ReplayFutureLiveBboParams {
|
||||
public ReplayFutureLiveBboParams(
|
||||
[StreamArgument(RegexNames = new[] { "^(continuous)?Contract$" }, Position = 0, IsRequired = true)]string? continuousContract) {
|
||||
}
|
||||
|
||||
[StreamArgument(RegexNames = new[] { "^(continuous)?Contract$" }, Position = 0, IsRequired = true)]
|
||||
public string? ContinuousContract { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.SecurityTypeRegex, WellKnownStreamArgumentAliases.TypeRegex }, Position = 1)]
|
||||
public string? SecurityType { get; set; }
|
||||
public SecurityType? SecurityType { get; set; }
|
||||
|
||||
[StreamArgument(RegexNames = new[] { "(begin|start)(date)?" }, Position = 2)]
|
||||
public DateTime? BeginDate { get; set; }
|
||||
|
||||
@@ -13,19 +13,22 @@ using Microsoft.Extensions.Logging;
|
||||
using Spark.Api.MarketData;
|
||||
|
||||
class InstrumentStreamFactory : DataStreamFactory {
|
||||
readonly IMarketDataClient mdClient;
|
||||
|
||||
public InstrumentStreamFactory(IMarketDataClient mdClient, ILogger<InstrumentStreamFactory> logger) {
|
||||
this.mdClient = mdClient;
|
||||
this.Add<InstrumentStreamParams>("instrument", CreateInstrument, logger);
|
||||
this.Add<LiveFutureContractStreamParams>(new[] { "liveFutures", "liveFuturesContract", "LiveFuturesContractStream" }, CreateLiveFutureContract, logger);
|
||||
|
||||
ViewStream? CreateInstrument(InstrumentStreamParams streamParams) =>
|
||||
mdClient.Securities(streamParams.GetSecurityCriteria())
|
||||
.AsDataPackets(streamParams.GetSchemaBuilder().SecurityAdapter())
|
||||
.AsViewStream();
|
||||
|
||||
ViewStream? CreateLiveFutureContract(LiveFutureContractStreamParams streamParams) =>
|
||||
new LiveFuturesContractStream(streamParams.Target ?? string.Empty, mdClient);
|
||||
}
|
||||
|
||||
ViewStream? CreateInstrument(InstrumentStreamParams streamParams) =>
|
||||
mdClient.Securities(streamParams.GetSecurityFilter())
|
||||
.AsDataPackets(streamParams.GetSchemaBuilder().SecurityAdapter())
|
||||
.AsViewStream();
|
||||
|
||||
ViewStream? CreateLiveFutureContract(LiveFutureContractStreamParams streamParams) =>
|
||||
new LiveFuturesContractStream(streamParams.Target ?? string.Empty, mdClient);
|
||||
|
||||
public class LiveFutureContractStreamParams {
|
||||
[StreamArgument(RegexNames = new[] { "^(symbol|sym|product|asset|target|tgt)$" })]
|
||||
public string? Target { get; set; }
|
||||
|
||||
@@ -23,16 +23,24 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
public class SpreadBookStreamFactory : IDataStreamFactory {
|
||||
readonly ILogger logger;
|
||||
public class SpreadBookStreamFactory : DataStreamFactory {
|
||||
readonly IMarketDataClient? mdClient;
|
||||
|
||||
public SpreadBookStreamFactory(ILogger<SpreadBookStreamFactory> logger)
|
||||
: this(null, logger) { }
|
||||
|
||||
public SpreadBookStreamFactory(IMarketDataClient? mdClient, ILogger<SpreadBookStreamFactory> logger) {
|
||||
this.logger = logger;
|
||||
this.mdClient = mdClient;
|
||||
var meta = new DataStreamMetadata() {
|
||||
Name = "spreadBook",
|
||||
AlternateNames = new() { "synthBook" },
|
||||
};
|
||||
this.Add<SpreadBookStreamParams>(meta, Create);
|
||||
|
||||
ViewStream? Create(SpreadBookStreamParams sp) =>
|
||||
CreateLiveSpreadBookTables(sp)
|
||||
?.AsDataPackets(sp.GetSchemaBuilder().SpreadBookRowAdapter())
|
||||
?.AsViewStream();
|
||||
}
|
||||
|
||||
public IObservable<TableUpdate<SpreadBookRow, int>>? CreateLiveSpreadBookTables(SpreadBookStreamParams args) {
|
||||
@@ -66,20 +74,6 @@ public class SpreadBookStreamFactory : IDataStreamFactory {
|
||||
&& leg.Name == s.ToString());
|
||||
}
|
||||
|
||||
public IObservable<IDataPacket>? CreateSpreadBookStream(SpreadBookStreamParams streamParams) =>
|
||||
CreateLiveSpreadBookTables(streamParams)?.AsDataPackets(streamParams.GetSchemaBuilder().SpreadBookRowAdapter());
|
||||
|
||||
public ViewStream? Create(string streamId, IEnumerable<(string? Name, int? Index, object? Value)> args) {
|
||||
if (SupportedStreams.SpreadBook.IsMatch(streamId)) {
|
||||
return createSpreadBook(args);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IEnumerable<IDataStreamMetadata> GetSupportedStreams() {
|
||||
yield return SupportedStreams.SpreadBook;
|
||||
}
|
||||
|
||||
static IObservable<SpreadBookRow> createSpreadBook(
|
||||
List<(SecurityImmutable Sec, double Qty)> legs, IObservable<TableUpdate<BookTuple, uint>> books) {
|
||||
var synthLegs = legs.Select(l => new SpreadBookRow.Leg(
|
||||
@@ -100,14 +94,6 @@ public class SpreadBookStreamFactory : IDataStreamFactory {
|
||||
});
|
||||
}
|
||||
|
||||
ViewStream? createSpreadBook(IEnumerable<(string? Name, int? Index, object? Value)> args) {
|
||||
if (!StreamFactoryArgStore.TryGetParams(args, out SpreadBookStreamParams? streamParams, out var err)) {
|
||||
logger.LogInvalidParams("spreadBook", err);
|
||||
return null;
|
||||
}
|
||||
return CreateSpreadBookStream(streamParams)?.AsViewStream();
|
||||
}
|
||||
|
||||
static class SupportedStreams {
|
||||
public static readonly DataStreamMetadata SpreadBook = new() {
|
||||
Name = "spreadBook",
|
||||
|
||||
@@ -3,32 +3,48 @@ namespace Bts.SharedStreams.StreamFactories;
|
||||
using bts.api;
|
||||
|
||||
using Bts.DataStreamCore;
|
||||
using Bts.SharedStreams.MarketData;
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
public class SpreadBookStreamParams {
|
||||
[StreamArgument("venue1", "exchange1", "exch1", "ex1", "e1", IsRequired = true)]
|
||||
[StreamArgumentConstructor(false)]
|
||||
public SpreadBookStreamParams() { }
|
||||
|
||||
public SpreadBookStreamParams(
|
||||
[StreamArgument(ParserType = typeof(VenueArgumentParser))] Venue venue1,
|
||||
[StreamArgument] string name1,
|
||||
[StreamArgument(ParserType = typeof(VenueArgumentParser))] Venue venue2,
|
||||
[StreamArgument] string name2) {
|
||||
Venue1 = venue1;
|
||||
SecurityName1 = name1;
|
||||
Venue2 = venue2;
|
||||
SecurityName2 = name2;
|
||||
}
|
||||
|
||||
public SpreadBookStreamParams(
|
||||
[StreamArgument(ParserType = typeof(VenueArgumentParser))] Venue venue1,
|
||||
[StreamArgument] string name1,
|
||||
[StreamArgument(ParserType = typeof(SecurityTypeArgumentParser), DefaultValue = null )] SecurityType? type1,
|
||||
[StreamArgument(ParserType = typeof(VenueArgumentParser))] Venue venue2,
|
||||
[StreamArgument] string name2,
|
||||
[StreamArgument(ParserType = typeof(SecurityTypeArgumentParser), DefaultValue = null)] SecurityType? type2
|
||||
) {
|
||||
Venue1 = venue1;
|
||||
SecurityName1 = name1;
|
||||
SecurityType1 = type1;
|
||||
Venue2 = venue2;
|
||||
SecurityName2 = name2;
|
||||
SecurityType2 = type2;
|
||||
}
|
||||
|
||||
public Venue? Venue1 { get; set; }
|
||||
|
||||
[StreamArgument("type1", "typ1", IsRequired = false)]
|
||||
public SecurityType? SecurityType1 { get; set; }
|
||||
|
||||
[StreamArgument("sec1", "name1", IsRequired = true)]
|
||||
public string? SecurityName1 { get; set; }
|
||||
|
||||
[StreamArgument("qty1", "quantity1", "q1", "size1", "sz1", IsRequired = true)]
|
||||
public double? Quantity1 { get; set; }
|
||||
|
||||
[StreamArgument("venue2", "exchange2", "exch2", "ex2", "e2", IsRequired = true)]
|
||||
public Venue? Venue2 { get; set; }
|
||||
|
||||
[StreamArgument("type2", "typ2", IsRequired = false)]
|
||||
public SecurityType? SecurityType2 { get; set; }
|
||||
|
||||
[StreamArgument("sec2", "name2", IsRequired = true)]
|
||||
public string? SecurityName2 { get; set; }
|
||||
|
||||
[StreamArgument("qty2", "quantity2", "q2", "size2", "sz2", IsRequired = true)]
|
||||
public double? Quantity2 { get; set; }
|
||||
|
||||
[StreamArgument("price", "px", "p", "showPrice", "showPx", "showP")]
|
||||
|
||||
@@ -6,8 +6,6 @@ using Bts.DataStreamCore;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Spark.Core;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
@@ -25,7 +23,7 @@ public class ThrottleStreamFactory : DataStreamFactory {
|
||||
[StreamArgument(Position = 0, IsRequired = true)]
|
||||
public ViewStream? Stream { get; set; }
|
||||
|
||||
[StreamArgument(Position = 1, IsRequired = true, ParserType = typeof(IntervalParser))]
|
||||
[StreamArgument(Position = 1, IsRequired = true, ParserType = typeof(TimeSpanArgumentParser.IntSeconds))]
|
||||
public TimeSpan? Interval { get; set; }
|
||||
|
||||
[MemberNotNull(nameof(Stream), nameof(Interval))]
|
||||
@@ -38,20 +36,4 @@ public class ThrottleStreamFactory : DataStreamFactory {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class IntervalParser : IStreamArgumentParser {
|
||||
public bool TryParse(string? name, string? valueStr, out object? result) {
|
||||
if (int.TryParse(valueStr, out var secs)) {
|
||||
result = TimeSpan.FromSeconds(secs);
|
||||
} else if (TimeSpan.TryParse(valueStr, out var ts)) {
|
||||
result = ts;
|
||||
} else if (TimeSpanUnitParser.TryParse(valueStr, out ts)) {
|
||||
result = ts;
|
||||
} else {
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,152 +2,25 @@ namespace Bts.SharedStreams.StreamFactories;
|
||||
|
||||
using BCG;
|
||||
|
||||
using bts.BlueOrb;
|
||||
using bts.collections;
|
||||
|
||||
using Bts.DataStream;
|
||||
using Bts.DataStreamCore;
|
||||
using Bts.DataStreamCore.StreamFactories;
|
||||
|
||||
using mbts.spark;
|
||||
using mbts.utils;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Spark.Api.MarketData;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
public class TradeStreamFactory : DataStreamFactory, IRecursiveDataStreamFactory {
|
||||
readonly LiveTradeStreamFactory liveTradeFactory;
|
||||
IDataStreamFactory? compositeFactory = null;
|
||||
|
||||
public class TradeStreamFactory : DataStreamFactory {
|
||||
public TradeStreamFactory(IMarketDataClient? mdClient, ILogger<TradeStreamFactory> logger) {
|
||||
this.Add<TradeStreamParams>(new[] { "trade" }, CreateTrade, logger);
|
||||
liveTradeFactory = new LiveTradeStreamFactory(mdClient, logger);
|
||||
Add(liveTradeFactory);
|
||||
|
||||
ViewStream? CreateTrade(TradeStreamParams streamParams) {
|
||||
ViewStream? CreateTrade(TradeStreamParams opts) {
|
||||
if (mdClient is null) {
|
||||
logger.LogError("Unable to create trade stream, live md not available");
|
||||
return null;
|
||||
}
|
||||
var secCriteria = streamParams.GetSecurityCriteria();
|
||||
var schemaBd = new TradeSchemaBuilder();
|
||||
return TradeStream(mdClient.Trades(secCriteria), schemaBd.ToSchema(), schemaBd.TradeInfoAdapter())
|
||||
?.AsViewStream();
|
||||
return new LiveTradeStream(mdClient, opts);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCompositeFactory(IDataStreamFactory compositeFactory) {
|
||||
this.compositeFactory = compositeFactory;
|
||||
liveTradeFactory.OnCompositeFactory(compositeFactory);
|
||||
}
|
||||
|
||||
public static IObservable<IDataPacket> TradeStream(IObservable<IList<TradeInfo>> trades, IBlueTableSchema tradeSchema, BlueTableSchemaAdapter<TradeInfo> tradeAdapter) =>
|
||||
trades.Scan((IDataPacket)null!, (dp, trades) => {
|
||||
var rowList = trades.WrapSelector(t => (IBlueRow)new BlueRowAdapter<TradeInfo>(tradeAdapter, t), null);
|
||||
var lastTable = dp?.newRows as BlueTableImmutable ?? new BlueTableImmutable(tradeSchema);
|
||||
var bd = lastTable.ToDataPacketBuilder();
|
||||
foreach (var t in trades) {
|
||||
bd.AddOrUpdate(new BlueRowAdapter<TradeInfo>(tradeAdapter, t));
|
||||
}
|
||||
return bd.ToDataPacket();
|
||||
});
|
||||
|
||||
static IObservable<IDataPacket> tradeStream(IMarketDataClient mdClient, TradeStreamParams streamParams) {
|
||||
var schemaBd = streamParams.GetSchemaBuilder();
|
||||
return TradeStream(mdClient.Trades(streamParams.GetSecurityCriteria()), schemaBd.ToSchema(), schemaBd.TradeInfoAdapter());
|
||||
}
|
||||
|
||||
class LiveTradeStreamFactory : IDataStreamFactory, IRecursiveDataStreamFactory {
|
||||
static readonly IDataStreamMetadata metadata = new DataStreamMetadata() {
|
||||
Name = "LiveTradeStream",
|
||||
AlternateNames = new(),
|
||||
Signatures = new() {
|
||||
new (string?, Type?)[] {
|
||||
("symbol", typeof(string))
|
||||
},
|
||||
new (string?, Type?)[] {
|
||||
("secType", typeof(string)),
|
||||
("symbol", typeof(string)),
|
||||
}
|
||||
}
|
||||
};
|
||||
readonly IMarketDataClient? mdClient;
|
||||
readonly ILogger logger;
|
||||
IDataStreamFactory? compositeFactory = null;
|
||||
|
||||
public LiveTradeStreamFactory(IMarketDataClient? mdClient, ILogger logger) {
|
||||
this.mdClient = mdClient;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public void OnCompositeFactory(IDataStreamFactory compositeFactory) =>
|
||||
this.compositeFactory = compositeFactory;
|
||||
|
||||
public ViewStream? Create(string streamId, IEnumerable<(string? Name, int? Index, object? Value)> args) {
|
||||
if (!metadata.IsMatch(streamId)) {
|
||||
return null;
|
||||
}
|
||||
var argList = args.ToList();
|
||||
switch (argList.Count) {
|
||||
case 1: {
|
||||
var sym = argList[0].Value?.ToString() ?? throw new ArgumentException("Symbol arg is null or empty", nameof(args));
|
||||
if (sym == "ES" && compositeFactory is not null) {
|
||||
return compositeFactory.Create("ReplayFutureLiveTradeStream", new (string?, int?, object?)[] { ("contract", 0, sym) });
|
||||
}
|
||||
if (!checkHasLiveMd()) {
|
||||
return null;
|
||||
}
|
||||
var streamParams = new TradeStreamParams() {
|
||||
Symbol = sym
|
||||
};
|
||||
return tradeStream(mdClient, streamParams).AsViewStream();
|
||||
}
|
||||
case 2: {
|
||||
if (!checkHasLiveMd()) {
|
||||
return null;
|
||||
}
|
||||
var secTypeStr = argList[0].Value?.ToString() ?? string.Empty;
|
||||
if (!MarketDataArgStore.TryParseSecurityType(secTypeStr, out var secType)) {
|
||||
throw new ArgumentException("Failed to parse SecurityType arg", nameof(args));
|
||||
}
|
||||
var sym = argList[1].Value?.ToString() ?? throw new ArgumentException("Symbol arg is null or empty", nameof(args));
|
||||
if (sym == "ES" && secType == bts.api.SecurityType.Future && compositeFactory is not null) {
|
||||
return compositeFactory.Create("ReplayFutureLiveBBOStream", new (string?, int?, object?)[] { ("contract", 0, sym) });
|
||||
}
|
||||
var streamParams = new TradeStreamParams() {
|
||||
SecurityType = secType,
|
||||
Symbol = sym,
|
||||
};
|
||||
return tradeStream(mdClient, streamParams).AsViewStream();
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<IDataStreamMetadata> GetSupportedStreams() {
|
||||
yield return metadata;
|
||||
}
|
||||
|
||||
[MemberNotNullWhen(true, nameof(mdClient))]
|
||||
bool checkHasLiveMd() {
|
||||
if (mdClient is not null) {
|
||||
return true;
|
||||
}
|
||||
logger.LogError("Market data is unavailable (md client is null)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class LiveBboStreamParams {
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.SecurityTypeRegex }, Position = 0, IsRequired = false)]
|
||||
public string? SecurityType { get; set; }
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.AssetRegex }, Position = 1, IsRequired = false)]
|
||||
public string? ContinuousContract { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public class TradeStreamParams {
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.VenueRegex })]
|
||||
public Venue? Venue { get; set; }
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.SymbolRegex })]
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.AssetRegex })]
|
||||
public string? Symbol { get; set; }
|
||||
|
||||
[StreamArgument(RegexNames = new[] { WellKnownStreamArgumentAliases.SecurityTypeRegex })]
|
||||
|
||||
Reference in new issue
Block a user