Пример #1
0
        void addRunInfoTab(SystemRunInfo info, ItemsControl charts)
        {
            var parametersGrid = new QDataTableGrid();

            charts.Items.Add(new DockableContent {
                Title = title("RunInfo"), Content = parametersGrid
            });
            var parametersTable = new QDataTable {
                { "name", typeof(string) },
                { "value", typeof(string) }
            };
            Action <string, string> addRow = (name, value) => {
                var row = parametersTable.NewRow();
                row["name"]  = name;
                row["value"] = value;
                parametersTable.add(row);
            };

            Objects.each(info.parameters, name => addRow(name, info.parameters.get <string>(name)));
            addRow("", "");
            addRow("start date", Objects.ymdHuman(info.startDate, ""));
            addRow("end date", Objects.ymdHuman(info.endDate, ""));
            addRow("slippage calculator", info.slippageCalculatorName);
            addRow("run in native currency", info.runInNativeCurrency + "");
            parametersGrid.populateFromDataTable(parametersTable);
        }
Пример #2
0
        DataRow addRow(string tag, string fullTicker, string rowKey)
        {
            var row = table.NewRow();

            row["tag"]      = tag;
            row["symbol"]   = fullTicker;
            row["tomahawk"] = 0;
            row["aim"]      = 0;
            row["diff"]     = 0;
            table.addAtStart(row);
            rowsByTagTicker[rowKey] = row;
            return(row);
        }
Пример #3
0
        void addRow(string metric, QDataTable result)
        {
            var row = result.NewRow();

            row["Metric"] = metric;
            foreach (var column in result.columns())
            {
                var columnName = column.ColumnName;
                if (columnName.Equals("Metric"))
                {
                    continue;
                }
                row[column] = this[columnName.Replace("_", ".")][metric];
            }
            result.add(row);
        }
Пример #4
0
        void addRow(int barIndex, Bar bar)
        {
            var row = dataTable_.NewRow();

            addBarTo(row, bar);
            eachPane(pane => Objects.each(pane.spuds, pane.names, (spud, name) => {
                if (spud.count() > barIndex)
                {
                    addSpudTo(row, name, spud[barIndex]);
                }
            }));
            var equity = spudPane(EQUITY).equity;

            addEquityTo(row, equity[equity.Count - barIndex - 1]);
            dataTable_.add(row);
        }
Пример #5
0
        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))));
        }
Пример #6
0
        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()));
        }