MarketView - working orders hyperlinks to OrderBook
This commit is contained in:
1 parent
7a712fbaf2
commit
e71b6bbb73
6 files changed
+125
-103
No files matched your search
@@ -101,8 +101,49 @@ namespace mbts.spark
|
||||
public double working_best_bid => _working_best_bid.Value;
|
||||
public double working_best_ask => _working_best_ask.Value;
|
||||
public IEnumerable<CellAnimation> animations => _animation.get_animations();
|
||||
public ICommand show_ladder => new DelegateCommand(() => _bus.post(SparkTags.ShowLadderTag, md));
|
||||
public ICommand show_order_ticket => new DelegateCommand<MarketViewView.Columns>(col => {
|
||||
public ICommand show_ladder => new DelegateCommand(_show_ladder);
|
||||
public ICommand show_order_book => new DelegateCommand<MarketViewView.Columns>(_show_order_book);
|
||||
public ICommand show_order_ticket => new DelegateCommand<MarketViewView.Columns>(_show_order_ticket);
|
||||
#endregion
|
||||
|
||||
public void refresh() {
|
||||
if (md.md.get_bbo(ref _bbo_ref, out NativePriceSize b, out NativePriceSize a)) {
|
||||
_bid_price.set(b.price);
|
||||
_bid_size.set(b.size);
|
||||
_ask_price.set(a.price);
|
||||
_ask_size.set(a.size);
|
||||
}
|
||||
if (md.md.get_last_trade(ref _last_ref, out NativePriceSize ps, out DateTime ts, out ulong v)) {
|
||||
_last_price.set(ps.price);
|
||||
_last_size.set(ps.size);
|
||||
_volume.set(v);
|
||||
}
|
||||
_settlement.set(md.md.settlement_price);
|
||||
_session_low.set(md.md.session_low);
|
||||
_session_high.set(md.md.session_high);
|
||||
_day_change.set(last_price - session_high);
|
||||
}
|
||||
|
||||
#region Show Windows
|
||||
void _show_ladder() => _bus.post(SparkTags.ShowLadderTag, md);
|
||||
|
||||
void _show_order_book(MarketViewView.Columns col) {
|
||||
switch(col) {
|
||||
case MarketViewView.Columns.WorkingBids: _show_order_book(Side.Buy); break;
|
||||
case MarketViewView.Columns.WorkingAsks: _show_order_book(Side.Sell); break;
|
||||
}
|
||||
}
|
||||
|
||||
void _show_order_book(Side side) =>
|
||||
_bus.post(SparkTags.ShowOrderBookTag, new bts.shell.OrderBookWindowFactory.OrderBookStartupData(
|
||||
new List<SortingCriteria>(),
|
||||
new bts.shell.OrderBookWindowFactory.FilterStates {
|
||||
statuses = new[] { OrderUtils.order_state_display_name(OrderStatus.Working) },
|
||||
sides = new[] { Side.Sell },
|
||||
security_criteria = new SecurityCriteria(security)
|
||||
}));
|
||||
|
||||
void _show_order_ticket(MarketViewView.Columns col) {
|
||||
var order = OrderDataHelper.Defaults.OrderDefinition(security);
|
||||
switch (col) {
|
||||
case MarketViewView.Columns.Bid:
|
||||
@@ -128,27 +169,10 @@ namespace mbts.spark
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, last_price, last_size));
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void refresh() {
|
||||
if (md.md.get_bbo(ref _bbo_ref, out NativePriceSize b, out NativePriceSize a)) {
|
||||
_bid_price.set(b.price);
|
||||
_bid_size.set(b.size);
|
||||
_ask_price.set(a.price);
|
||||
_ask_size.set(a.size);
|
||||
}
|
||||
if (md.md.get_last_trade(ref _last_ref, out NativePriceSize ps, out DateTime ts, out ulong v)) {
|
||||
_last_price.set(ps.price);
|
||||
_last_size.set(ps.size);
|
||||
_volume.set(v);
|
||||
}
|
||||
_settlement.set(md.md.settlement_price);
|
||||
_session_low.set(md.md.session_low);
|
||||
_session_high.set(md.md.session_high);
|
||||
_day_change.set(last_price - session_high);
|
||||
}
|
||||
|
||||
#region Callbacks
|
||||
void _on_orders(TableUpdate<OrderRecordImmutable, uint> orders) {
|
||||
uint removed_buys = 0, removed_sells = 0, added_buys = 0, added_sells = 0;
|
||||
foreach (var o in orders.removed) {
|
||||
@@ -183,6 +207,7 @@ namespace mbts.spark
|
||||
}
|
||||
|
||||
void _animation_AnimationsChanged() => RaisePropertyChanged(nameof(animations));
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,11 +46,44 @@
|
||||
<Style x:Key="LastSizeElement" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{uc:BTSColor MarketData.last}"/>
|
||||
</Style>
|
||||
<Style x:Key="BidSizeElement" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{uc:BTSColor MarketData.bid}"/>
|
||||
<Style x:Key="HyperlinkElementBase" TargetType="Hyperlink">
|
||||
<Setter Property="CommandParameter" Value="{Binding Path='Column.(c:DataGridEx.CellKey)', RelativeSource={RelativeSource AncestorType=DataGridCell}}"/>
|
||||
</Style>
|
||||
<Style x:Key="AskSizeElement" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{uc:BTSColor MarketData.ask}"/>
|
||||
<Style x:Key="HyperlinkBidFG" TargetType="Hyperlink" BasedOn="{StaticResource HyperlinkElementBase}">
|
||||
<Setter Property="Foreground" Value="Transparent"/>
|
||||
<Setter Property="TextDecorations" Value="Underline"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{u:BTSColor MarketData.bid}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="True">
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="HyperlinkAskFG" TargetType="Hyperlink" BasedOn="{StaticResource HyperlinkElementBase}">
|
||||
<Setter Property="Foreground" Value="Transparent"/>
|
||||
<Setter Property="TextDecorations" Value="Underline"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{u:BTSColor MarketData.ask}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="True">
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="HyperlinkWhiteFG" TargetType="Hyperlink" BasedOn="{StaticResource HyperlinkElementBase}">
|
||||
<Setter Property="Foreground" Value="Transparent"/>
|
||||
<Setter Property="TextDecorations" Value="Underline"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="True">
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
@@ -96,11 +129,21 @@
|
||||
c:DataGridFilterProperties.Filter="{Binding DataContext.position_filter, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterActive="{Binding DataContext.position_filter.active, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterTemplate="{StaticResource IntMinMaxTemplate}"/>
|
||||
<DataGridTextColumn Header="Wrkg" ElementStyle="{StaticResource BidSizeElement}" Binding="{Binding working_bids_text}" SortMemberPath="working_best_bid"
|
||||
c:DataGridEx.CellKey="{u:Enum WorkingBids, Type={u:Nested usp:MarketViewView.Columns}}"
|
||||
c:DataGridFilterProperties.Filter="{Binding DataContext.working_bid_volume_filter, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterActive="{Binding DataContext.working_bid_volume_filter.active, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterTemplate="{StaticResource UIntMinMaxTemplate}"/>
|
||||
<DataGridTemplateColumn Header="Wrkg" SortMemberPath="working_best_bid"
|
||||
c:DataGridEx.CellKey="{u:Enum WorkingBids, Type={u:Nested usp:MarketViewView.Columns}}"
|
||||
c:DataGridFilterProperties.Filter="{Binding DataContext.working_bid_volume_filter, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterActive="{Binding DataContext.working_bid_volume_filter.active, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterTemplate="{StaticResource UIntMinMaxTemplate}">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock>
|
||||
<Hyperlink Command="{Binding show_order_book}" Style="{StaticResource HyperlinkBidFG}">
|
||||
<TextBlock Text="{Binding working_bids_text}" Foreground="{u:BTSColor MarketData.bid}"/>
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="Qty"
|
||||
c:DataGridEx.CellKey="{u:Enum BidSize, Type={u:Nested usp:MarketViewView.Columns}}"
|
||||
c:DataGridFilterProperties.Filter="{Binding DataContext.bid_size_filter, Source={u:DirectReference grid}}"
|
||||
@@ -109,21 +152,7 @@
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock>
|
||||
<Hyperlink Command="{Binding show_order_ticket}" CommandParameter="{Binding Path='Column.(c:DataGridEx.CellKey)', RelativeSource={RelativeSource AncestorType=DataGridCell}}">
|
||||
<Hyperlink.Style>
|
||||
<Style TargetType="Hyperlink">
|
||||
<Setter Property="Foreground" Value="Transparent"/>
|
||||
<Setter Property="TextDecorations" Value="Underline" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{u:BTSColor MarketData.bid}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="True">
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Hyperlink.Style>
|
||||
<Hyperlink Command="{Binding show_order_ticket}" Style="{StaticResource HyperlinkBidFG}">
|
||||
<TextBlock Text="{Binding bid_size}" Foreground="{u:BTSColor MarketData.bid}"/>
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
@@ -138,21 +167,7 @@
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock>
|
||||
<Hyperlink Command="{Binding show_order_ticket}" CommandParameter="{Binding Path='Column.(c:DataGridEx.CellKey)', RelativeSource={RelativeSource AncestorType=DataGridCell}}">
|
||||
<Hyperlink.Style>
|
||||
<Style TargetType="Hyperlink">
|
||||
<Setter Property="Foreground" Value="Transparent"/>
|
||||
<Setter Property="TextDecorations" Value="Underline" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="True">
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Hyperlink.Style>
|
||||
<Hyperlink Command="{Binding show_order_ticket}" Style="{StaticResource HyperlinkWhiteFG}">
|
||||
<TextBlock Foreground="White">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource TickDisplayConverter}">
|
||||
@@ -174,21 +189,7 @@
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock>
|
||||
<Hyperlink Command="{Binding show_order_ticket}" CommandParameter="{Binding Path='Column.(c:DataGridEx.CellKey)', RelativeSource={RelativeSource AncestorType=DataGridCell}}">
|
||||
<Hyperlink.Style>
|
||||
<Style TargetType="Hyperlink">
|
||||
<Setter Property="Foreground" Value="Transparent"/>
|
||||
<Setter Property="TextDecorations" Value="Underline" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="True">
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Hyperlink.Style>
|
||||
<Hyperlink Command="{Binding show_order_ticket}" Style="{StaticResource HyperlinkWhiteFG}">
|
||||
<TextBlock Foreground="White">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource TickDisplayConverter}">
|
||||
@@ -210,32 +211,28 @@
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock>
|
||||
<Hyperlink Command="{Binding show_order_ticket}" CommandParameter="{Binding Path='Column.(c:DataGridEx.CellKey)', RelativeSource={RelativeSource AncestorType=DataGridCell}}">
|
||||
<Hyperlink.Style>
|
||||
<Style TargetType="Hyperlink">
|
||||
<Setter Property="Foreground" Value="Transparent"/>
|
||||
<Setter Property="TextDecorations" Value="Underline" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{u:BTSColor MarketData.ask}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="True">
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Hyperlink.Style>
|
||||
<Hyperlink Command="{Binding show_order_ticket}" Style="{StaticResource HyperlinkAskFG}">
|
||||
<TextBlock Text="{Binding ask_size}" Foreground="{u:BTSColor MarketData.ask}"/>
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Header="Wrkg" ElementStyle="{StaticResource AskSizeElement}" Binding="{Binding working_asks_text}" SortMemberPath="working_best_ask"
|
||||
c:DataGridEx.CellKey="{u:Enum WorkingAsks, Type={u:Nested usp:MarketViewView.Columns}}"
|
||||
c:DataGridFilterProperties.Filter="{Binding DataContext.working_ask_volume_filter, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterActive="{Binding DataContext.working_ask_volume.active, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterTemplate="{StaticResource UIntMinMaxTemplate}"/>
|
||||
<DataGridTemplateColumn Header="Wrkg" SortMemberPath="working_best_ask"
|
||||
c:DataGridEx.CellKey="{u:Enum WorkingAsks, Type={u:Nested usp:MarketViewView.Columns}}"
|
||||
c:DataGridFilterProperties.Filter="{Binding DataContext.working_ask_volume_filter, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterActive="{Binding DataContext.working_ask_volume_filter.active, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterTemplate="{StaticResource UIntMinMaxTemplate}">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock>
|
||||
<Hyperlink Command="{Binding show_order_book}" Style="{StaticResource HyperlinkAskFG}">
|
||||
<TextBlock Text="{Binding working_asks_text}" Foreground="{u:BTSColor MarketData.ask}"/>
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Header="Settlement" SortMemberPath="settlement"
|
||||
c:DataGridEx.CellKey="{u:Enum Settlement, Type={u:Nested usp:MarketViewView.Columns}}"
|
||||
c:DataGridFilterProperties.Filter="{Binding DataContext.settlement_filter, Source={u:DirectReference grid}}"
|
||||
|
||||
@@ -18,9 +18,7 @@ namespace bts.shell {
|
||||
_bus = bus;
|
||||
_model = model;
|
||||
|
||||
_dispose = Disposable.Create(
|
||||
bus.subscribe(SparkTags.ShowOrderBookTag).ObserveOnDispatcher().Subscribe(_ => show())
|
||||
);
|
||||
_dispose = bus.subscribe(SparkTags.ShowOrderBookTag).ObserveOnDispatcher().Subscribe(show);
|
||||
}
|
||||
|
||||
public override Task<IShellWindow> load(OrderBookStartupData state) {
|
||||
@@ -28,8 +26,8 @@ namespace bts.shell {
|
||||
return Task.FromResult(w);
|
||||
}
|
||||
|
||||
public async void show() {
|
||||
var w = await load(new OrderBookStartupData());
|
||||
async void show(OrderBookStartupData startup_data) {
|
||||
var w = await load(startup_data);
|
||||
_bus.post(SparkTags.ShowWindow, w);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace bts.shell
|
||||
public int priority => 20;
|
||||
|
||||
public IEnumerable<SparkCommand> actions => new [] {
|
||||
SparkCommands.ShowOrders,
|
||||
SparkCommands.ShowOrders.complete(() => new OrderBookWindowFactory.OrderBookStartupData()),
|
||||
SparkCommands.ShowFills,
|
||||
//SparkCommands.ShowPAndL,
|
||||
SparkCommands.PickLadder,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using bts.api;
|
||||
using bts.api.orderman2;
|
||||
using bts.shell;
|
||||
using mbts.spark;
|
||||
using mbts.ui;
|
||||
using System;
|
||||
@@ -21,7 +22,7 @@ namespace bts.spark
|
||||
SparkCommand.create("Time and Sales", Icons.Clock, SparkTags.ShowPickMultiple, ShowTimeAndSales);
|
||||
|
||||
// Trading
|
||||
public static SparkCommand ShowOrders =>
|
||||
public static PartialCommand<OrderBookWindowFactory.OrderBookStartupData> ShowOrders =>
|
||||
SparkCommand.create("Order Book", Icons.Book, SparkTags.ShowOrderBookTag);
|
||||
|
||||
public static SparkCommand ShowFills =>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using bts.api;
|
||||
using bts.api.orderman2;
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
using mbts.ui;
|
||||
using System;
|
||||
@@ -35,7 +36,7 @@ namespace mbts.spark
|
||||
public static ITag<SecurityMD> ShowLadderTag { get; } = new SparkTag<SecurityMD>("Show Ladder");
|
||||
public static ITag<IObservable<SecurityMD>> ShowLinkedLadder { get; } = new SparkTag<IObservable<SecurityMD>>("Linked Ladder");
|
||||
public static ITag<SecurityCriteria> ShowMarketViewTag { get; } = new SparkTag<SecurityCriteria>("Show MarketView");
|
||||
public static ITag<Nothing> ShowOrderBookTag { get; } = new SparkTag<Nothing>(nameof(ShowOrderBookTag));
|
||||
public static ITag<OrderBookWindowFactory.OrderBookStartupData> ShowOrderBookTag { get; } = new SparkTag<OrderBookWindowFactory.OrderBookStartupData>(nameof(ShowOrderBookTag));
|
||||
public static ITag<OrderRecordImmutable> ShowModifyOrderTag { get; } = new SparkTag<OrderRecordImmutable>(nameof(ShowModifyOrderTag));
|
||||
public static ITag<OrderID> ShowOrderDetailsTag { get; } = new SparkTag<OrderID>(nameof(ShowOrderDetailsTag));
|
||||
public static ITag<ShowOrderModifyMessage> ShowOrderModifyTag { get; } = new SparkTag<ShowOrderModifyMessage>(nameof(ShowOrderModifyTag));
|
||||
|
||||
Reference in new issue
Block a user