71 lines
3.4 KiB
C#
71 lines
3.4 KiB
C#
using bts.api;
|
|
using System.Collections.Generic;
|
|
|
|
namespace mbts.spark {
|
|
static class SecurityDataHelper {
|
|
// Ice
|
|
public static string market_description(this SecurityImmutable security) => security.HasIce ? security.Ice.MarketDescription : string.Empty;
|
|
public static string product_name(this SecurityImmutable security) => security.HasIce ? security.Ice.ProductName : string.Empty;
|
|
public static string cleared_alias(this SecurityImmutable security) => security.HasIce ? security.Ice.ClearedAlias : string.Empty;
|
|
public static string hub_alias(this SecurityImmutable security) => security.HasIce ? security.Ice.HubAlias : string.Empty;
|
|
public static string strip_name(this SecurityImmutable security) => security.HasIce ? security.Ice.StripName : string.Empty;
|
|
public static string mic_code(this SecurityImmutable security) => security.HasIce ? security.Ice.MicCode : string.Empty;
|
|
|
|
public static bool is_exchange_security(this SecurityImmutable? security) =>
|
|
security.HasValue && is_exchange_security(security.Value);
|
|
|
|
public static bool is_exchange_security(this SecurityImmutable security) {
|
|
switch (security.Exchange) {
|
|
case Venue.Bts:
|
|
case Venue.Unset: return false;
|
|
}
|
|
switch (security.ContractCase) {
|
|
case Security.ContractOneofCase.Future:
|
|
case Security.ContractOneofCase.Spread:
|
|
return true;
|
|
default: return false;
|
|
}
|
|
}
|
|
|
|
public static class EqualityComparer {
|
|
public static readonly IEqualityComparer<SecurityMD> MDComparer = bts.utils.EqualityComparer.Create<SecurityMD>(Equals, GetHashCode);
|
|
public static bool Equals(SecurityMD x, SecurityMD y) => x.security.Id == y.security.Id;
|
|
public static int GetHashCode(SecurityMD security_md) => security_md.security.Id.GetHashCode();
|
|
|
|
public static readonly IEqualityComparer<SecurityImmutable> IDComparer = bts.utils.EqualityComparer.Create<SecurityImmutable, uint>(s => s.Id);
|
|
}
|
|
|
|
public static class Defaults {
|
|
public static ContractSpecification ContractSpecification =>
|
|
new ContractSpecification {
|
|
CashPerPoint = 1.0,
|
|
LowTick = 0.0001,
|
|
HighTick = 0.0001,
|
|
PriceBreak = double.MaxValue,
|
|
PriceMultiplier = 1.0,
|
|
MainFraction = 10000
|
|
};
|
|
public static readonly ContractSpecificationImmutable ContractSpecificationImmutable = new ContractSpecificationImmutable(ContractSpecification);
|
|
|
|
public static ContractSpecification ContractSpecificationPennies =>
|
|
new ContractSpecification {
|
|
CashPerPoint = 1.0,
|
|
LowTick = 0.01,
|
|
HighTick = 0.01,
|
|
PriceBreak = double.MaxValue,
|
|
PriceMultiplier = 1.0,
|
|
MainFraction = 100
|
|
};
|
|
public static ContractSpecificationImmutable ContractSpecificationImmutablePennies = new ContractSpecificationImmutable(ContractSpecificationPennies);
|
|
|
|
public static Security Security =>
|
|
new Security {
|
|
Symbol = string.Empty,
|
|
Exchange = Venue.Bts,
|
|
ContractSpec = ContractSpecification
|
|
};
|
|
public static readonly SecurityImmutable SecurityImmutable = new SecurityImmutable(Security);
|
|
}
|
|
}
|
|
}
|