Ejemplo n.º 1
0
        void addBar(StatisticsCollector collector, IEnumerable <Position> positions, double close, double fxRate)
        {
            var weightedPositions = O.convert(positions, p => new WeightedPosition(p));

            collector.addBar(weightedPositions, O.dictionaryOne(symbol(), new Bar(close, close, close, close, currentDate)), O.dictionaryOne(symbol(), fxRate));
            currentDate = currentDate.AddDays(1);
        }
Ejemplo n.º 2
0
        static IEnumerable <string> allIds()
        {
            var jids = SystemDetailsTable.allAvailableStoIds();
            var ids  = O.list <java.lang.Integer>(jids);

            return(O.convert(ids, i => "" + i));
        }
Ejemplo n.º 3
0
        public void testSortedRunNumbersByParameter()
        {
            var minLengthDnRuns = O.list(O.convert(O.seq(2500), i => 1 + 20 * i));
            var results         = hamster();
            var actual          = results.runsByParameter("LengthDn").GetRange(0, 2500);

            LogC.info(Objects.toShortString(actual));
            AreEqual(minLengthDnRuns, O.sort(actual));
        }
Ejemplo n.º 4
0
        public void testCanPopulateStuffFromSystemIdLive()
        {
            O.freezeNow("2009/04/28");
            var gui = new FakeResearchGUI();

            gui.setSystemId("39");
            gui.loadSystem();
            gui.doAllWork();
            var parameters = gui.parameters();

            AreEqual(39, parameters.get <int>("systemId"));
            AreEqual(50, parameters.get <int>("LeadBars"));
            AreEqual(30, parameters.get <int>("BreakDays"));
            IsTrue(gui.runNumberEnabled());
            IsFalse(gui.runInNativeCurrency());
            var markets = O.convert(O.list <Market>(SystemDetailsTable.DETAILS.details(39).liveSystem().markets()), m => m.name());

            AreEqual(O.list(markets), gui.markets());
        }
Ejemplo n.º 5
0
        [Test] public void testOneSubscribe()
        {
            OrderTable.prefix = "PREFIX";
            O.freezeNow("2009/07/10 13:00:00");
            var liveSystem = OneSystemTest <EmptySystem> .fakeLiveSystem(new Parameters(), false);

            liveSystem.removeAllLiveMarkets();
            insertMarket("FOO", 0);
            liveSystem.addLiveMarket("FOO", "2009/07/07", null);
            insertMarket("BAR", 0);
            liveSystem.addLiveMarket("BAR", "2009/07/07", null);
            var fooTopic = new QTopic("PREFIX.TestSystem1.1.0.daily.Slow.FOO.heartbeat");

            O.timerManager().isInterceptingTimersForTest = true;

            O.timerManager().intercept("2009/07/10 13:00:00", "gui update");
            var map = new StatusTreeMap(new FakeStatusMapGUI(), O.list(liveSystem));

            map.setIsEqualSizes(false);
            var systemNode = O.the(map.nodes());

            AreEqual("TestSystem1", systemNode.text);
            var pvNode = O.the(systemNode.children());

            AreEqual("Slow", pvNode.text);
            var symbolNodes = O.dictionaryFromValues(O.convert(pvNode.children(), child => child as LiveMarketNode), child => child.id);

            AreEqual(1d, symbolNodes["FOO"].size);
            AreEqual(0, symbolNodes["FOO"].ticksReceived);
            AreEqual(1d, symbolNodes["BAR"].size);
            var message = new Fields();

            message.put("timestamp", "2009/07/10 12:59:59");
            message.put("lastTickProcessed", "2009/07/10 12:59:58");
            message.put("ticksReceived", "200");
            message.put("hostname", "hullabaloo");
            fooTopic.send(message);
            Objects.timerManager().intercept("2009/07/10 13:00:01", "second gui update");
            O.timerManager().runTimers("2009/07/10 13:00:00");
            waitMatches(200d, () => symbolNodes["FOO"].ticksReceived); // you just
        }
Ejemplo n.º 6
0
        public static int Main(string[] args)
        {
            QControl.forceLoad();
            Assembly q = null;

            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                if (assembly.GetName().Name.Equals("Gui"))
                {
                    q = assembly;
                }
            }
            if (q == null)
            {
                throw Bomb.toss(
                          "Cannot find Gui.dll in assemblies:\n" + O.toShortString(O.convert(AppDomain.CurrentDomain.GetAssemblies(), a => a.FullName))
                          );
            }

            var appName   = args[0];
            var className = "Gui." + appName + ".MainWindow";

            try {
                var type    = q.GetType(className, true, false);
                var newArgs = new string[args.Length - 1];
                O.zeroTo(args.Length - 1, i => newArgs[i] = args[i + 1]);

                var application = new Application();
                System.Windows.Forms.Application.ThreadException += (s, e) => { DockingWindow.handleUncaughtException(e.Exception, appName); throw e.Exception; };
                var mainWindow = (Window)type.GetConstructor(new[] { typeof(string[]) }).Invoke(new[] { newArgs });
                mainWindow.Closed += (s, e) => Environment.Exit(0);
                application.Run(mainWindow);
            } catch (Exception e) {
                DockingWindow.handleUncaughtException(e, appName);
                return(-1);
            }
            return(0);
        }
Ejemplo n.º 7
0
        public IEnumerable <ROW> selectedRows()
        {
            var selectedEntries = O.accept(rows, (model, ui) => ui.IsSelected);

            return(O.convert(selectedEntries, e => e.Key));
        }
Ejemplo n.º 8
0
 static Dictionary <Symbol, Bar> collectBars(IEnumerable <Bar> bars)
 {
     return(O.dictionary(O.convert(O.seq(5), i => symbols[i]), bars));
 }