36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using System.Globalization;
|
|
using bts.api;
|
|
using bts.api.admin;
|
|
using bts.api.orderman;
|
|
using bts.spark;
|
|
|
|
namespace Spark.Command.Bridge;
|
|
|
|
internal static class SpreadOrderSubmission {
|
|
internal static OrderDefinition BuildDefinition(
|
|
SecurityImmutable security, ExecutionStrategyImmutable strategy,
|
|
BTSAccountImmutable account, string userName, uint userId,
|
|
Side side, string tag) => new() {
|
|
SecurityKey = security.Id,
|
|
Account = account.Name,
|
|
AccountId = account.Id,
|
|
User = userName,
|
|
UserId = userId,
|
|
Side = side,
|
|
TimeInForce = TimeInForce.Gtc,
|
|
Tag = tag,
|
|
CustomDef = new CustomOrderDefinition {
|
|
Spreader = new SpreaderOrderDefinition {
|
|
Security = security.CloneToMutable(),
|
|
ExecutionStrategy = strategy.CloneToMutable()
|
|
}
|
|
}
|
|
};
|
|
|
|
internal static double ParsePrice(string value) =>
|
|
double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var price)
|
|
&& double.IsFinite(price)
|
|
? price
|
|
: throw new ArgumentException("price must be a finite decimal string");
|
|
}
|