public CloudSTOPanel() { var panel = new QDockPanel(); Content = panel; Loaded += initialize; instanceGrid = new QDataTableGrid(loadInstanceRow, unloadInstanceRow); var controls = new QDockPanel(); systemIdBox = new QComboBox("-1", resetInstanceId, true) { MinWidth = 80, IsTextSearchEnabled = true, IsSynchronizedWithCurrentItem = false }; controls.add(systemIdBox, Dock.Left); var grid = new QGrid(); grid.addColumns(4); instancesLabel = label(""); grid.add(instancesLabel, 0); redGreenLabel = label(""); grid.add(redGreenLabel, 1); summaryLabel = label(""); grid.add(summaryLabel, 2); completionTimeLabel = label(""); grid.add(completionTimeLabel, 3); controls.add(grid, Dock.Left); controls.add(new QButton("Refresh System Ids", refreshSystemIds), Dock.Left); panel.add(controls, Dock.Top); panel.add(instanceGrid, Dock.Top); LogC.info("starting cloud STO tracker"); tracker = new CloudSTOTracker(this); }
public FerretPanel() { control = new FerretControl(this, FerretControl.incomingStatus()); var grid = new QGrid(); Content = grid; grid.addColumns(4); statusLabel = new Label { Content = "Currently in Unknown mode", FontSize = 24, VerticalAlignment = VerticalAlignment.Center }; dma = new QButton("DMA", () => control.onButtonPressed("DMA")) { Background = Brushes.SpringGreen, HorizontalAlignment = HorizontalAlignment.Stretch, MinWidth = 250, FontSize = 24, IsEnabled = false }; ticket = new QButton("Ticket", () => control.onButtonPressed("Ticket")) { Background = Brushes.Yellow, HorizontalAlignment = HorizontalAlignment.Stretch, MinWidth = 250, FontSize = 24, IsEnabled = false }; staged = new QButton("Stage", () => control.onButtonPressed("Stage")) { Background = Brushes.Red, HorizontalAlignment = HorizontalAlignment.Stretch, MinWidth = 250, FontSize = 24, IsEnabled = false }; grid.add(statusLabel, 0); grid.add(dma, 1); grid.add(ticket, 2); grid.add(staged, 3); }
UIElement comboBoxPanel() { var comboBoxes = new QGrid { Height = 25 }; comboBoxes.addColumns(6); comboBoxes.add(withLabel("_System:", systemBox), 0); comboBoxes.add(withLabel("_Pv:", pvBox), 1); comboBoxes.add(withLabel("_Market:", marketBox), 2); comboBoxes.add(new QButton("Subscribe", subscribeButtonClicked) { HorizontalAlignment = HorizontalAlignment.Left }, 3); comboBoxes.add(withLabel("_Filter:", filterBox), 4); return(comboBoxes); }
void addTradesTab(Simulator simulator, ItemsControl charts, IEnumerable <Trade> trades) { var dataGrid = new QDataTableGrid(); var table = new QDataTable { { "symbol", typeof(string) }, { "time", typeof(DateTime) }, { "description", typeof(string) }, { "direction", typeof(string) }, { "size", typeof(int) }, { "price", typeof(double) }, { "details", typeof(string) }, { "fxRate", typeof(double) } }; var panel = new QDockPanel(); charts.Items.Add(new DockableContent { Title = title("Trades"), Content = panel }); var controlGrid = new QGrid(); controlGrid.addColumns(2); controlGrid.add(withLabel("S_ymbol", new QComboBox("ALL", selected => table.filter("symbol", selected), markets())), 0); controlGrid.add(withLabel("_Direction", new QComboBox("ALL", selected => table.filter("direction", selected), Objects.list("buy", "sell"))), 1); panel.add(controlGrid, Dock.Top); panel.add(dataGrid, Dock.Bottom); Converter <Trade, DataRow> newTradeRow = trade => { var row = table.NewRow(); row["symbol"] = trade.order().symbol.name; row["time"] = trade.time; row["description"] = trade.description; row["direction"] = trade.direction.longShort("buy", "sell"); row["size"] = trade.size; row["price"] = trade.price; row["details"] = " " + trade.order().details; row["fxRate"] = trade.fxRate; return(row); }; Objects.each(Objects.reverse(trades), trade => table.add(newTradeRow(trade))); dataGrid.populateFromDataTable(table); dataGrid.AutoGeneratedColumns += rightJustifyColumns; simulator.addNewTradeListener((position, trade) => runOnGuiThread(() => table.addAtStart(newTradeRow(trade)))); }
void addPositionsTab(Researcher researcher, ItemsControl charts) { var simulator = researcher.simulator; var positionsPane = new DockablePane(); var dataGrid = new QDataTableGrid(); var table = new QDataTable("symbol", "entryTime", "exitTime", "direction") { { "initialSize", typeof(int) }, { "pnl", typeof(double) }, { "barsHeld", typeof(int) }, { "numTrades", typeof(int) }, { "positionHIDDEN", typeof(Position) } }; var panel = new QDockPanel(); positionsPane.Items.Add(new DockableContent { Title = title("Position List"), Content = panel }); charts.Items.Add(new DockableContent { Title = title("Positions"), Content = positionsPane }); var controlGrid = new QGrid(); controlGrid.addColumns(3); controlGrid.add(withLabel("S_ymbol", new QComboBox("ALL", selected => table.filter("symbol", selected), markets())), 0); controlGrid.add(withLabel("_Direction", new QComboBox("ALL", selected => table.filter("direction", selected), Objects.list("long", "short"))), 1); controlGrid.add(withLabel("_P&L", new QComboBox("ALL", selected => table.filter <double>("pnl", value => pnlMatchesSelection(selected, value)), Objects.list("winning", "losing"))), 2); panel.add(controlGrid, Dock.Top); panel.add(dataGrid, Dock.Bottom); Action <DataRow, Position> updateRow = (row, position) => { row["symbol"] = position.symbol.name; row["entryTime"] = Objects.ymdHuman(position.entry().time); row["exitTime"] = position.isClosed() ? Objects.ymdHuman(position.exitTrade().time) : "Open"; row["direction"] = position.entry().direction.ToString(); row["initialSize"] = position.entry().size; row["pnl"] = position.isClosed() ? position.pnl(true, simulator.runInNativeCurrency()) : simulator.pnlForPosition(position); row["barsHeld"] = position.barsHeld(); row["numTrades"] = position.trades().Count; row["positionHIDDEN"] = position; }; Converter <Position, DataRow> newRow = position => { var row = table.NewRow(); updateRow(row, position); return(row); }; Objects.each(Objects.reverse(researcher.positions), position => table.add(newRow(position))); dataGrid.populateFromDataTable(table); dataGrid.AutoGeneratedColumns += rightJustifyColumns; simulator.addNewTradeListener((position, trade) => runOnGuiThread(() => { if (position.isEntry(trade)) { table.addAtStart(newRow(position)); } else { updateRow(table.firstRow("positionHIDDEN", position), position); } })); addFilteredHistogram(positionsPane, table, "Average P&L (Bar To End)", new TradePathHistogramControl(researcher, true, true)); addFilteredHistogram(positionsPane, table, "Cumulative P&L (Bar To End)", new TradePathHistogramControl(researcher, false, true)); addFilteredHistogram(positionsPane, table, "Average P&L (Start To Bar)", new TradePathHistogramControl(researcher, true, false)); addFilteredHistogram(positionsPane, table, "Cumulative P&L (Start To Bar)", new TradePathHistogramControl(researcher, false, false)); addFilteredHistogram(positionsPane, table, "Pnl Distribution", new PositionHistogramControl(researcher, position => position.pnl(true, researcher.simulator.runInNativeCurrency()))); addFilteredHistogram(positionsPane, table, "Entry Size Distribution", new PositionHistogramControl(researcher, position => Objects.first(position.trades()).size)); addFilteredHistogram(positionsPane, table, "Bars Held Distribution", new PositionHistogramControl(researcher, position => position.barsHeld())); }