public void testDifferentDatesBehaviorIsConsistent() { insertSymbol(A.name); insertSymbol(B.name); var systemId = OneSystemTest <TestSystemWithEWMA> .fakeLiveSystem(new Parameters { { "LeadBars", 2.0 } }, false).id(); var parameters = new Parameters { { "systemId", (double)systemId }, { "RunMode", (double)RunMode.LIVE } }; combined = new SystemArguments(O.list(A, B), parameters).bridge <IndependentSymbolSystems <TestSystemWithEWMA> >(); a = new SystemArguments(O.list(A), parameters).bridge <IndependentSymbolSystems <TestSystemWithEWMA> >(); b = new SystemArguments(O.list(B), parameters).bridge <IndependentSymbolSystems <TestSystemWithEWMA> >(); bar(1.0, null); bar(2.0, 1.0); bar(null, 2.0); bar(3.0, 3.0); AreEqual(ewma(a, A)[0], ewma(b, B)[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()); }
public void testSubscribeButton() { var gui = startGui(); var t = LiveOrderEmailsTable.ORDER_EMAILS; t.deleteAll(Clause.TRUE); AreEqual(0, t.emails("NDayBreak-daily-1.0", "BFBD30", "RE.TEST.TY.1C").size()); gui.selectedSystem = "NDayBreak-daily-1.0"; gui.selectedPv = "BFBD30"; gui.setMarketChoices(O.list("ALL")); gui.tracker.subscribe(); var addresses = t.emails("NDayBreak-daily-1.0", "BFBD30", "RE.TEST.TY.1C"); AreEqual(1, addresses.size()); var expected = "You have subscribed to NDayBreak-daily-1.0, BFBD30, RE.TEST.TY.1C " + "to address " + addresses.get(0); gui.hasMessage(expected); }
public OrdersPanel() { var panel = new QDockPanel(); Content = panel; Loaded += initialize; systemBox = new QComboBox(onSystemSelected); pvBox = new QComboBox(onPvSelected); marketBox = new QComboBox(onMarketSelected); filterBox = new QComboBox("ALL", onFilterSelected, O.list("Not Ferret", "Ferret")); panel.add(comboBoxPanel(), Dock.Top); panel.add(new FerretPanel(), Dock.Bottom); orderGrid = new QDataTableGrid(loadOrderRow, unloadOrderRow); panel.add(orderGrid); LogC.info("starting order tracker"); orderTracker = new OrderTracker(this); }
static void startProcesses(Fields fields) { var nProcs = fields.integer("numProcs"); var mainDir = fields.text("mainDir"); var command = fields.text("command"); Environment.SetEnvironmentVariable("MAIN", mainDir); O.zeroTo(nProcs, i => { LogC.info("starting " + mainDir + " " + command + " -serverIndex " + i); try { var exe = new QFile(mainDir + @"\dotNET\QRun\bin\Release\QRun.exe"); Bomb.unless(exe.exists(), () => "no exe found at " + exe.path()); var process = Process.Start(exe.path(), command + " -serverIndex " + i); processes.get(mainDir + command).Add(process); } catch (Exception e) { LogC.err("failure to launch!", e); throw Bomb.toss("failure to launch!", e); } }); }
public MyInstaller() { Installers.Add(new ServiceProcessInstaller { Account = ServiceAccount.LocalSystem }); var q = Program.qAssembly(); O.each(q.GetTypes(), type => { if (!type.IsSubclassOf(typeof(ServiceBase))) { return; } var service = (ServiceBase)type.GetConstructor(Type.EmptyTypes).Invoke(new object[0]); Installers.Add(new MyServiceInstaller(type) { StartType = ServiceStartMode.Disabled, ServiceName = service.ServiceName }); }); }
public void testCanWriteCurveFileToS3() { var dates = O.list( date("2005/11/10"), date("2005/11/14"), date("2005/11/15") ); var pnls = O.list(1.0, 0.0, -1.0); var positions = O.list(0.0, 2.0, 3.0); var id = 5203; new MetaBucket("quantys-5203").create(); var marketName = "RE.TEST.TY.1C"; var runNumber = 1; CurveFiles.writeToS3(id, marketName, runNumber, dates, pnls, positions); CurveFiles.readFromS3(id, marketName, runNumber, PATH); AreEqual(File.ReadAllBytes(@"..\..\..\..\R\src\STO\inst\testdata\SimpleCurves\ABC_1_daily_mkt1\run_1.bin"), File.ReadAllBytes(PATH)); }
public object retrieveOneTimeSeriesByName(string seriesName, string source, string start, string end) { try { var ss = seriesSource(seriesName, source); var range = Range.range(start, end); var observations = ss.observations(range); var result = new object[observations.size(), 2]; // datetime, double var i = 0; foreach (java.util.Date d in observations) { result[i, 0] = O.date(d); result[i, 1] = observations.value(d); i++; } return(result); } catch (Exception e) { var message = "failed to retrieve " + seriesName + " " + source + " " + start + " " + end; return(loggedError(message, e)); } }
[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 }
public override void setUp() { base.setUp(); currentDate = date("2009-01-01"); O.each(symbols, symbol => { var subSymbolSystem = symbolSystem(symbol); subSymbolSystem.richCheap.enterTestMode(); subSymbolSystem.dv01.enterTestMode(); subSymbolSystem.spread.enterTestMode(); subSymbolSystem.dtd.enterTestMode(); }); O.zeroTo(leadBars(), i => processBar(new[] { bar(0, 1, 1, 0, 0.01, 1), bar(1, 1, 1, 0, 0.02, 1), bar(2, 1, 1, 0, 0.03, 1), bar(3, 1, 1, 0, 0.04, 1), bar(4, 1, 1, 0, 0.05, 1) })); }
public void testSymbolBarSpud() { var manager = new SpudManager(); var barSpud = new BarSpud(manager); var symbol = new Symbol("RE.TEST.TY.1C"); var spud = symbol.bars(barSpud); barSpud.set(new Bar(1, 3, 1, 2, O.date("2007/01/02"))); AreEqual(105.04687500, spud[0].close); barSpud.lastTickedAt(O.date("2007/01/02 12:34:55")); symbol.javaSymbol().jmsLive().publish(new JTick(98, 100, 96, 99, 93, O.jDate("2007/01/02 12:34:56"))); O.sleep(250); AreEqual(105.04687500, spud[0].close); manager.goLive(); symbol.javaSymbol().jmsLive().publish(new JTick(98, 100, 96, 99, 93, O.jDate("2007/01/02 12:34:57"))); O.wait(() => spud[0].time.Equals(date("2007/01/02 12:34:57"))); AreEqual(98.0, spud[0].close); AreEqual(93.0, spud[0].low); }
public void testFerretOrderSimFilled() { O.freezeNow("2009/03/03"); insertSubmitted(39, SYMBOL, "test", "f2"); var id = insertSubmitted(39, SYMBOL, "test", "f3"); insertSubmitted(39, SYMBOL, "test", "f4"); insertSubmitted(39, SYMBOL, "test", "f5"); var gui = startGui(); gui.setMarket(SYMBOL); gui.wait(populateCompleted); var filledAt = Dates.date("1999/09/09 09:09:09"); LiveOrders.ORDERS.order(id).updateFill(12345, filledAt); publish(id); var row = Util.Objects.nth(gui.tracker.orderTable().rows(), 3); AreEqual(id.ToString(), row["liveOrderId"]); gui.waitMatches("12345.000000", () => row["simFillPrice"]); }
public void testSystemSelectPopulatesPvAndMarketCombo() { O.freezeNow("2009/07/15"); var gui = startGui(); gui.tracker.systemUpdated(); gui.doAllWork(); gui.selectedSystem = SYSTEM; gui.tracker.systemUpdated(); gui.wait(populateCompleted); IsTrue(gui.marketChoices.Contains("TY.1C")); IsTrue(gui.marketChoices.Contains("CD.1C")); IsFalse(gui.marketChoices.Contains("TRI.CNAIG5")); IsTrue(gui.pvChoices.Contains("BFBD30")); IsFalse(gui.pvChoices.Contains("CDXMV20")); gui.selectedPv = "BFBD30"; gui.tracker.pvUpdated(); gui.wait(populateCompleted); IsTrue(gui.marketChoices.Contains("TY.1C")); IsFalse(gui.marketChoices.Contains("CD.1C")); }
public object retrieveOneSymbol(string marketName, string start, string end) { try { var bars = rBars(marketName, start, end); var result = new object[bars.open.Length, 7]; O.zeroTo(bars.open.Length, i => { // date open high low close interest volume result[i, 0] = O.date(bars.dates[i]); result[i, 1] = bars.open[i]; result[i, 2] = bars.high[i]; result[i, 3] = bars.low[i]; result[i, 4] = bars.close[i]; result[i, 5] = bars.openInterest[i]; result[i, 6] = bars.volume[i]; }); return(result); } catch (Exception e) { return(loggedError("failed to retrieve " + marketName + " between " + start + " " + end, e)); } }
public DataTable table() { var result = new QDataTable(); result.addTypedColumn("Metric", typeof(string)); O.each(O.sort(Keys, (a, b) => { if (a.Equals(b)) { return(0); } if (a.Equals("ALL")) { return(-1); } return(b.Equals("ALL") ? 1 : a.CompareTo(b)); }), symbol => result.addTypedColumn(symbol.Replace(".", "_"), typeof(double))); var example = O.first(Values); O.each(O.sort(example.Keys), metric => addRow(metric, result)); return(result); }
public void testIsolatedTomahawkMessages() { O.freezeNow("07/01/2009"); MarketTickersTable.TICKERS.C_BLOOMBERG.updateOne(MarketTickersTable.TICKERS.C_MARKET.@is("FV.1C"), "anything"); var nday20 = new Topic("TOMAHAWK.NDayBreak.1.0.daily.BFBD20.FV.1C.optimalPosition"); var nday30 = new Topic("TOMAHAWK.NDayBreak.1.0.daily.BFBD30.FV.1C.optimalPosition"); var fakeGui = new FakeWatcherGui(); var watcher = new LiveWatcher(fakeGui); watcher.initialize(); watcher.eachRow(row => AreEqual(row["tomahawk"], 0)); watcher.requireContains("QF.NDayBreak", "anything Comdty"); var fv1C = new Symbol("FV.1C"); Action <double> waitForCount = expected => fakeGui.waitMatches(expected, () => watcher.row("QF.NDayBreak", fv1C)["tomahawk"]); publishTomahawk(nday20, 3, "2009/07/01 14:00:00"); waitForCount(3); publishTomahawk(nday20, 2, "2009/07/01 14:00:01"); waitForCount(2); publishTomahawk(nday30, 3, "2009/07/01 14:00:03"); waitForCount(5); }
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); }
public void testNBarFade() { O.freezeNow("2009/03/10"); var symbol = new Symbol("RE.TEST.TY.1C", 1000); var args = new SystemArguments(symbol, new Parameters { { "systemId", 133486 }, { "RunMode", (double)RunMode.RIGHTEDGE }, { "LeadBars", 50 }, { "ATRLen", 5 }, { "nDays", 6 }, { "nATRentry", 1.5 }, { "exitATRmultiple", 1 }, { "stopAfStep", 0.02 }, { "stopAfMax", 0.2 }, { "entryBarWindow", 2 }, { "closeBetter", 1 }, { "riskDollars", 100000000 } }); var loader = new SystemDbBarLoader(Interval.DAILY, O.list(symbol), date("2003/01/01")); var simulator = new Simulator(args, loader, OrderTable.prefix); simulator.processBars(); }
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); }
public void testStoWorks() { LogC.setOut("testStoWorks", @"C:\logs\localCloud.log", false); LogC.useJavaLog = true; const int systemId = 178114; var curveFile = new QFile(@"V:\Market Systems\General Market Systems\Benchmark\20080923\CurvesBin\Benchmark_1.0_daily_RE.TEST.TY.1C/run_678.bin"); curveFile.deleteIfExists(); var testQueue = new Queue("TEST.LocalCloud"); O.timerManager().isInterceptingTimersForTest = true; O.freezeNow("2009/06/22 03:00:00"); O.timerManager().intercept("2009/06/22 03:00:00", "heartbeat"); O.timerManager().intercept("2009/06/22 03:00:03", "second heartbeat"); var server = new STOServer(systemId, 2); var fired = false; server.heart.subscribe(fields => { fired = true; AreEqual(fields.get("Hostname"), O.hostname()); AreEqual(fields.get("ServerIndex"), 2); }); server.subscribe(testQueue); server.heart.initiate(); IsFalse(fired); O.timerManager().runTimers("2009/06/22 03:00:00"); O.wait(() => fired); MetricResults metrics = null; O.timerManager().intercept("2009/06/22 03:00:00", "client heartbeat"); new STOClient(SystemDetailsTable.DETAILS.details(systemId), testQueue).metrics(678, results => metrics = results); O.wait(100, 1000, () => metrics != null); AreEqual(-1953125.00, metrics["RE.TEST.TY.1C"]["QNetProfit"]); curveFile.requireExists(); }
public void testTick() { O.freezeNow("2008/08/08 11:00:00"); StatusTracker.LATE_MILLIS = 500; StatusTracker.CRASHED_MILLIS = 500; var tracker = startGui(); AreEqual(SystemStatus.UNKNOWN, gui.tickStatus(system)); message("2008/08/08 11:00:00", "2008/08/08 10:00:00"); waitForTickStatus(SystemStatus.GREEN); O.advanceNow(1000); Log.setFile(@"C:\foo.log"); SYMBOL.publish(new Bar(0, 0, 0, 0, date("2008/08/08 11:00:01"))); O.wait(() => tracker.tickTimers[system].running()); O.advanceNow(500); waitForTickStatus(SystemStatus.YELLOW); O.advanceNow(500); waitForTickStatus(SystemStatus.RED); O.advanceNow(59000); message("2008/08/08 11:01:00", "2008/08/08 11:00:01"); waitForTickStatus(SystemStatus.GREEN); // lastTickProcessed should be the time on the tick }
public void testOnCloseIntraDay() { var siv5Minute = new Siv("TestSystem1", "5minute", "1.0"); var liveSystem = new LiveSystem(siv5Minute, FAST); var args = arguments(O.list(SYMBOL, SYMBOL2), liveSystem, RunMode.RIGHTEDGE, typeof(TestOnCloseSystem)); var loader = new FakeBarLoader(SYMBOL, SYMBOL2); var simulator = loader.simulator(args, OrderTable.prefix); var system = simulator.theSymbolSystem <TestOnCloseSystem>(SYMBOL); var system2 = simulator.theSymbolSystem <TestOnCloseSystem>(SYMBOL2); MarketSessionTable.SESSION.update(SYMBOL.name, Session.DAY, "16:00:00", 360); MarketSessionTable.SESSION.update(SYMBOL2.name, Session.DAY, "15:50:00", 360); Action <int, int> bar = (close, minutesAfter3) => { var barTime = Dates.minutesAhead(minutesAfter3, Dates.date("2008/08/08 15:00:00")); loader.add(SYMBOL, close, close, close, close, barTime); loader.add(SYMBOL2, close, close, close, close, barTime); simulator.nextBar(); }; Action <bool, bool> closeTriggered = (expected1, expected2) => { AreEqual(expected1, system.onCloseTriggered); AreEqual(expected2, system2.onCloseTriggered); system.onCloseTriggered = false; system2.onCloseTriggered = false; }; O.zeroTo(5, i => { bar(i, 15 + i * 5); closeTriggered(false, false); }); bar(6, 40); closeTriggered(false, false); // ? format but couldn't resist the parallellism. and terseness. bar(7, 45); closeTriggered(false, true); bar(8, 50); closeTriggered(false, false); bar(9, 55); closeTriggered(true, false); bar(10, 60); closeTriggered(false, false); }
public void testOrderSubmission() { O.freezeNow("2008/08/08 08:08:08"); var order1 = buy("order 1", stop(99.50), 100, oneBar()); symbolSystem.order(order1); processBar(1, 3, 1, 2); hasOrders(order1); requireFerretHasOrders(); processTick(2.5); requireFerretHasOrders(order1); emailer.allowMessages(); var submitted = O.the <LiveOrders.LiveOrder>(LiveOrders.ORDERS.ordersSubmitted(systemId, symbol().name)); AreEqual("Enter", submitted.entryExit()); fill(order1, 123); submitted = O.the <LiveOrders.LiveOrder>(LiveOrders.ORDERS.ordersSubmitted(systemId, symbol().name)); var filled = O.the(O.list <LiveOrders.LiveOrder>(LiveOrders.ORDERS.ordersFilled(systemId, symbol().name))); AreEqual(123.0, filled.price().doubleValue()); AreEqual(submitted, filled); var order2 = sell("order 2", stop(97.50), 10, oneBar()); symbolSystem.order(order2); processTick(3.0); requireFerretHasOrders(order1, order2); var order3 = sell("market", market(), 50, oneBar()); symbolSystem.order(order3); processTick(3.0); requireFerretHasOrders(order1, order2); symbolSystem.order(symbolSystem.position().exit("exit 1", market(), onTheClose())); processTick(4.0); submitted = O.first(O.list <LiveOrders.LiveOrder>(LiveOrders.ORDERS.ordersSubmitted(systemId, symbol().name))); AreEqual("Exit", submitted.entryExit()); }
public void setSummary(long complete, long total, double rpm, DateTime completionTime) { summaryLabel.Content = "Completed: " + complete + "/" + total + " (" + Strings.nDecimals(2, rpm) + " per min)"; var dateString = completionTime.CompareTo(O.now().AddDays(1)) > 0 ? O.ymdHuman(completionTime) : Dates.hhMmSs(O.jDate(completionTime)); completionTimeLabel.Content = completionTime == O.SQL_MIN_DATE ? "" : "Est. Completion Time: " + dateString; }
/** the *new* here is because the simulator clears the trade list by bar */ void hasNewTrades(params Trade[] expected) { AreEqual(O.list(expected), simulator.trades); }
void hasPositions(Position[] expected) { O.each(system.positions(SYMBOL), O.list(expected), (a, b) => a.requireMatches(b)); }
void tick(double d, params Position[] expected) { simulator.processTick(new Tick(d, 1, O.now()), SYMBOL); hasPositions(expected); }
protected override void OnStop() { O.each(processes, process => process.Kill()); }
public void testEmails() { var abc = new Symbol("RE.TEST.TY.1C"); var slippage = MarketTable.MARKET.fixedSlippage(abc.name); var monitor = new PositionMonitor(LIVE_SYSTEM, O.list(abc, new Symbol("DEF")), "A_TOPIC"); var counter = new PublishCounter("OrderTracker.orderAdded"); var order = abc.buy("Go LONG", new Stop(50), 10, FillOrKill.FILL_KILL).placed(); var trade = new Trade(order, 52, 10, slippage, 1); var position = order.fill(trade); monitor.positionUpdate(position, trade, PositionMonitor.basicTradeEmail); monitor.goLive(O.list(position), abc); O.freezeNow("2008/09/22 14:47:04"); LiveOrderEmailsTable.ORDER_EMAILS.insert("S-I-V", "PV", "ALL", "team"); emailer.allowMessages(); monitor.positionUpdate(position, trade, PositionMonitor.basicTradeEmail); var message = emailer.sent(); message.hasSubject(@"S\(PV\) Filled Order for RE.TEST.TY.1C - " + O.hostname()); message.hasContent(@"Order.*: Enter long 10 RE.TEST.TY.1C @ 52 STOP\(50.0000000\)"); message.hasContent("Timestamp: 2008/09/22 14:47:04"); message.hasContent("Description: Go LONG"); emailer.clear(); var liveOrders = O.list <LiveOrders.LiveOrder>(LiveOrders.ORDERS.ordersFilled(LIVE_SYSTEM.id(), abc.name)); HasCount(1, liveOrders); var liveOrder = O.the(liveOrders); AreEqual(10, liveOrder.size()); AreEqual("Enter", liveOrder.entryExit()); AreEqual("long", liveOrder.positionDirection()); AreEqual(liveOrder.id(), counter.getOneAndClear <int>("liveOrderId")); order = position.scaleUpLong("gimme more", new StopLimit(50, 60), 25, FillOrKill.FILL_KILL).placed(); trade = new Trade(order, 55, 25, slippage, 1); order.fill(trade); monitor.positionUpdate(position, trade, PositionMonitor.basicTradeEmail); emailer.sent().hasContent(@"Order.*: Scale up long 25 RE.TEST.TY.1C @ 55 STOP_LIMIT\(50.0000000, 60.0000000\)"); emailer.clear(); liveOrders = O.list <LiveOrders.LiveOrder>(LiveOrders.ORDERS.ordersFilled(LIVE_SYSTEM.id(), abc.name)); HasCount(2, liveOrders); liveOrder = O.first(liveOrders); AreEqual(25, liveOrder.size()); AreEqual("Scale up", liveOrder.entryExit()); AreEqual("long", liveOrder.positionDirection()); order = position.scaleDownLong("gimme more", new Limit(55), 20, FillOrKill.FILL_KILL).placed(); trade = new Trade(order, 55, 20, slippage, 1); order.fill(trade); monitor.positionUpdate(position, trade, PositionMonitor.basicTradeEmail); emailer.sent().hasContent(@"Order.*: Scale down long 20 RE.TEST.TY.1C @ 55 LIMIT\(55.0000000\)"); emailer.clear(); order = position.exitLong("Get out", new Market(), OneBar.ONE).placed(); trade = new Trade(order, 40, 15, slippage, 1); order.fill(trade); monitor.positionUpdate(position, trade, PositionMonitor.basicTradeEmail); emailer.sent().hasContent(@"Order.*: Exit long 15 RE.TEST.TY.1C @ 40 MARKET"); emailer.disallowMessages(); LiveOrderEmailsTable.ORDER_EMAILS.deleteAll(Clause.TRUE); monitor.positionUpdate(position, trade, PositionMonitor.basicTradeEmail); }
static Tick tick(int price) { return(new Tick(price, 1, O.now())); }