Exemple #1
0
        static void generateCurves(LiveSystem system, IEnumerable <JMarket> markets, QDirectory directory, DateTime start, DateTime end, DataSource metricSource)
        {
            var symbols    = convert(markets, market => new Symbol(market.name(), market.bigPointValue()));
            var parameters = new Parameters {
                { "systemId", system.id() },
                { "RunMode", (double)RunMode.LIVE }
            };
            var startLoading = DateTime.Now;

            Bomb.when(system.details().runInNativeCurrency(), () => "portfolio optimization requires systems to run in dollars, not native currency");
            var bars            = new SystemDbBarLoader(system.details().interval(), symbols, start, end);
            var simulator       = new Simulator(new SystemArguments(symbols, parameters), bars, "QUEDGE");
            var startProcessing = DateTime.Now;
            var perSecond       = simulator.processBars();

            saveMetric(system, "marketBarsPerSecond", metricSource, perSecond);
            var startMetricCalc = DateTime.Now;

            simulator.metrics();
            saveMetric(system, "metricCalculationSeconds", metricSource, secondsSince(startMetricCalc));
            saveMetric(system, "totalRunSeconds", metricSource, secondsSince(startProcessing));
            simulator.writeCurveFiles(directory);
            saveMetric(system, "totaSeconds", metricSource, secondsSince(startLoading));
            Db.commit();
        }
Exemple #2
0
        void updateNode(LiveSystem liveSystem, QNode node)
        {
            var childNodes = list <LiveMarketNode>(node.children());
            var totalTicks = sum(convert(childNodes, child => child.ticksReceived));

            if (totalTicks == 0)
            {
                return;
            }
            var tickRate = sum(convert(childNodes, child => child.tickRate));
            var tickLag  = max(convert(childNodes, child => child.tickLag));

            node.color = tickLag - 5000;
            node.size  = isEqualSizes_ ? 1 : Math.Max(1F, tickRate);
            var isDown            = exists(childNodes, child => child.isDown);
            var downText          = isDown ? "" : "DOWN ";
            var lastTickProcessed = max(convert(childNodes, child => child.lastTickProcessed));

            node.text =
                downText +
                liveSystem.pv().name() + " - " + liveSystem.id() + "\n" +
                tickRate.ToString("n0") + "/min, " + tickLag + "ms\n" +
                totalTicks.ToString("n0") + "\n" +
                lastTickProcessed.ToString("HH:mm:ss") + "\n";
        }
Exemple #3
0
        public int filledUpdateDb(double fillPrice, LiveSystem liveSystem, string topicPrefix)
        {
            int liveOrderId;

            if (ferretSubmission == null)
            {
                liveOrderId = LiveOrders.ORDERS.insert(
                    liveSystem.id(), symbol.name, jDate(now()), null, enterExit(),
                    positionDirection().ToString(), size, new java.lang.Double(fillPrice),
                    details.ToString(), description, hostname(), topicPrefix, null
                    );
            }
            else
            {
                liveOrderId = ferretSubmission.liveOrderId;
                var submitted = LiveOrders.ORDERS.order(liveOrderId);
                submitted.updateFill(fillPrice, jDate(now()));
            }
            Db.commit();
            OrderTable.topic().send(new Dictionary <string, object> {
                { "liveOrderId", liveOrderId },
                { "timestamp", ymdHuman(now()) }
            });
            return(liveOrderId);
        }
Exemple #4
0
 static SystemArguments arguments(IEnumerable <Symbol> symbols, LiveSystem liveSystem, RunMode mode, Type type)
 {
     O.each(symbols, symbol => MsivTable.MSIVS.insert(symbol.name, liveSystem.siv()));
     liveSystem.setQClassName(type.FullName);
     liveSystem.populateDetailsIfNeeded(false);
     return(new SystemArguments(symbols, new Parameters {
         { "LeadBars", 5 },
         { "systemId", liveSystem.id() },
         { "RunMode", (double)mode },
         { "lookback", 2 }
     }));
 }
Exemple #5
0
 void insertUnknownRow(DataRow row, LiveSystem system)
 {
     row.ItemArray = new object[] {
         system.siv().sivName("-"),
         system.pv().name(),
         system.id(),
         "unknown",
         -1,
         "unknown", // "2008/10/09 15:55:07",
         "unknown", // "2008/10/09 15:55:07",
     };
     table.Rows.InsertAt(row, 0);
 }
Exemple #6
0
        public override void setUp()
        {
            base.setUp();

            liveSystem = fakeLiveSystem(parameters(), runInNativeCurrency());
            systemId   = liveSystem.id();
            initializeSymbols();
            bridge_ = new QREBridge <S>(arguments());
            loader  = new FakeBarLoader(bridge_.arguments().symbols);
            loader.setSpudManager(bridge_.manager);
            barsLoadedThisBar = false;

            noOrders();
        }
Exemple #7
0
        public void testCanPublishRestart()
        {
            LogC.useJavaLog = true;
            FerretControl.onOutgoing(fields => O.queueWorkItem(() => FerretControl.setStatus(fields.text("FERRETSTATE"))));
            system.populateDetailsIfNeeded(false);
            system.populateTagIfNeeded("QF.Example", false);
            FerretControl.setStatus("Ticket");
            var    tracker         = startGui();
            var    restartRequests = LiveLauncher.restartTopic();
            Fields received        = null;

            restartRequests.subscribe(fields => { received = fields; });
            tracker.restart(O.hostname(), system.id());
            O.wait(() => received != null);
            AreEqual(system.id(), (int)received.longg("SystemId"));
            AreEqual(O.hostname(), received.text("Hostname"));
            gui.noMessage();

            system.setAutoExecuteTrades(true);
            gui.stageAnswer(YesNoCancel.NO);
            restartRequests.setReadonly(true);
            tracker.restart(O.hostname(), system.id());
            gui.hasMessage("This will put Ferret into Stage mode.  Are you sure you want to do this?");

            gui.stageAnswer(YesNoCancel.YES);
            restartRequests.setReadonly(false);
            received = null;
            tracker.restart(O.hostname(), system.id());
            gui.hasMessage("This will put Ferret into Stage mode.  Are you sure you want to do this?");
            waitMatches("Stage", FerretControl.status);
            O.wait(() => received != null);

            received = null;
            tracker.restart(O.hostname(), system.id());
            gui.noMessage();
            O.wait(() => received != null);
        }
Exemple #8
0
        public int submittedInsertDb(LiveSystem liveSystem, string topicPrefix)
        {
            var positionDir = hasPosition() ? positionDirection() : direction;
            var liveOrderId = LiveOrders.ORDERS.insert(
                liveSystem.id(), symbol.name, null, jDate(now()), enterExit(),
                positionDir.ToString(), size, null,
                details.ToString(), description, hostname(), topicPrefix, ferretSubmission.id
                );

            Db.commit();
            OrderTable.topic().send(new Dictionary <string, object> {
                { "liveOrderId", liveOrderId },
                { "timestamp", now() }
            });
            return(liveOrderId);
        }
Exemple #9
0
 static Parameters parameters(LiveSystem system)
 {
     return(new Parameters {
         { "systemId", (double)system.id() }, { "RunMode", (double)RunMode.LIVE }
     });
 }