add accounts static placeholder
This commit is contained in:
1 parent
f7599a83ea
commit
758dc9e07f
5 files changed
+22
-8
No files matched your search
@@ -22,14 +22,14 @@ namespace mbts.spark {
|
||||
class LadderVM : DisposableViewModelBase, IKeyListener {
|
||||
readonly LadderModel _model;
|
||||
readonly DispatcherTimer _timer;
|
||||
Order _order_template = new Order();
|
||||
Order _order_template;
|
||||
LadderSettings _settings;
|
||||
|
||||
public const string SAVE_NAME = "SparkLadder";
|
||||
|
||||
public LadderVM(LadderModel model, IObservable<LadderSettings> settings) {
|
||||
_model = model;
|
||||
_order_template.Security = model.security;
|
||||
_order_template = OrderDataHelper.Defaults.Order(_model.security);
|
||||
_timer = new DispatcherTimer() {
|
||||
Interval = TimeSpan.FromMilliseconds(100),
|
||||
IsEnabled = true
|
||||
@@ -167,7 +167,7 @@ namespace mbts.spark {
|
||||
Property<bool> _revert;
|
||||
public bool revert { get => _revert.Value; set => _revert.set(value); }
|
||||
|
||||
public string[] accounts { get; } = new[] { "Account1", "Account2", "Account3", "Account4" };
|
||||
public string[] accounts { get; } = ImportedResources.Accounts;
|
||||
public string account { get => _order_template.Account; set => _order_template.Account = value; }
|
||||
public Order.Types.TimeInForce[] order_types => Enum.GetValues(typeof(Order.Types.TimeInForce)).Cast<Order.Types.TimeInForce>().ToArray();
|
||||
Property<Order.Types.TimeInForce> _selected_order_type;
|
||||
|
||||
@@ -85,7 +85,9 @@ namespace mbts.spark
|
||||
private static Security _get_security(DataGridCellInfo cell) { return (cell.Item as Row)?.security.value; }
|
||||
private static Order _create_order(DataGridCellInfo cell) { return _create_order((Row)cell.Item, (Columns)DataGridEx.GetArgument(cell.Column)); }
|
||||
private static Order _create_order(Row row, Columns col) {
|
||||
var order = new Order { Security = row.security.value, MarketOrder = new MarketOrder(), Price = 0, Size = 1 };
|
||||
var order = OrderDataHelper.Defaults.Order(row.security.value, Order.AlgoOrderTypeOneofCase.MarketOrder);
|
||||
order.Price = 0;
|
||||
order.Size = 1;
|
||||
switch(col) {
|
||||
case Columns.Bid: order.Price = row.bid_price.output; break;
|
||||
case Columns.BidSize: order.Price = row.bid_price.output; order.Size = row.bid_size.output; break;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace mbts.spark
|
||||
});
|
||||
}
|
||||
|
||||
public string[] accounts { get; } = new[] { "Account1", "Account2", "Account3", "Account4" };
|
||||
public string[] accounts { get; } = ImportedResources.Accounts;
|
||||
public string account { get => _order.Account; set => _order.Account = value; }
|
||||
public ObservableCollection<OrderTypeVM> algo_types { get; }
|
||||
public OrderTypeVM algo_type {
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace mbts.spark.utilities
|
||||
{
|
||||
public static IBus Bus => _instance.bus;
|
||||
public static string UserName => _instance.user_name;
|
||||
public static readonly string[] Accounts = new[] { "Account1", "Account2", "Account3", "Account4" };
|
||||
|
||||
#region Misc Extensions (should put these in a more appropriate place eventually)
|
||||
public static IObservable<Security> ToSecurity(this IObservable<uint> securityKey) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using bts.spark;
|
||||
using Google.Protobuf;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace mbts.spark.utilities
|
||||
{
|
||||
@@ -38,12 +39,22 @@ namespace mbts.spark.utilities
|
||||
BTSIcebergOrder
|
||||
};
|
||||
|
||||
public static Order Order(Security security) {
|
||||
return new Order {
|
||||
public static Order Order(Security security) { return Order(security, bts.spark.Order.AlgoOrderTypeOneofCase.LimitOrder); }
|
||||
public static Order Order(Security security, Order.AlgoOrderTypeOneofCase algo_type) {
|
||||
var rv = new Order {
|
||||
Account = ImportedResources.Accounts.FirstOrDefault(),
|
||||
User = ImportedResources.UserName,
|
||||
Security = security,
|
||||
LimitOrder = new LimitOrder()
|
||||
};
|
||||
switch (algo_type) {
|
||||
case bts.spark.Order.AlgoOrderTypeOneofCase.LimitOrder: rv.LimitOrder = new LimitOrder(); break;
|
||||
case bts.spark.Order.AlgoOrderTypeOneofCase.MarketOrder: rv.MarketOrder = new MarketOrder(); break;
|
||||
case bts.spark.Order.AlgoOrderTypeOneofCase.StopLimitOrder: rv.StopLimitOrder = new StopLimitOrder(); break;
|
||||
case bts.spark.Order.AlgoOrderTypeOneofCase.StopMarketOrder: rv.StopMarketOrder = new StopMarketOrder(); break;
|
||||
case bts.spark.Order.AlgoOrderTypeOneofCase.BtsStopOrder: rv.BtsStopOrder = BTSStopOrder; break;
|
||||
case bts.spark.Order.AlgoOrderTypeOneofCase.BtsIcebergOrder: rv.BtsIcebergOrder = BTSIcebergOrder; break;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user