public void testCanGoLiveWithoutCloseTime() { var liveSystem = LIVE_SYSTEM; liveSystem.setQClassName(typeof(ExampleSymbolSystem).FullName); liveSystem.populateDetailsIfNeeded(false); liveSystem.insertParameter("lookback", "2"); liveSystem.insertParameter("LeadBars", "0"); MarketSessionTable.SESSION.update(SYMBOL.name, Session.DAY, "NO_CLOSE", 0); ExchangeSessionTable.EXCHANGE_SESSION.update(new Market(SYMBOL.name).exchange(), Session.DAY, "NO_CLOSE", 0); var args = new SystemArguments(SYMBOL, new Parameters { { "systemId", liveSystem.id() }, { "RunMode", (double)RunMode.LIVE } }); var simulator = makeSimulator(args); simulator.processBars(300); while (O.hasContent(simulator.allPositions())) { simulator.nextBar(); } simulator.goLive(); var time = simulator.currentDate().AddDays(1); O.freezeNow(time); noPosition(simulator); var current = new Bar(120, 120, 120, 120, time); tick(simulator, current, SYMBOL); hasPosition(simulator); time = time.AddSeconds(1); current = current.update(new Tick(118, 1, time)); tick(simulator, current, SYMBOL); }
void fillOrdersHighLow(Symbol symbol, Bar bar) { var highLow = bar.orderedHighLow(); fillOrdersNotOpen(symbol, new Tick(highLow[0], 0, bar.time), false); fillOrdersNotOpen(symbol, new Tick(highLow[1], 0, bar.time), false); }
public static void addBarTo(DataRow row, Bar bar) { row["time"] = bar.time; row["open"] = bar.open; row["high"] = bar.high; row["low"] = bar.low; row["close"] = bar.close; }
protected void close(double tri) { if (lastBar != null) { processBar(lastBar); } lastTime = lastTime.AddDays(1); lastBar = new Bar(tri, tri + 1, tri - 1, tri, lastTime); processClose(lastBar); }
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); }
protected override void onNewTick(Bar partialBar, Tick tick) { }
void fillOrdersClose(Symbol symbol, Bar bar) { fillOrdersNotOpen(symbol, new Tick(bar.close, 0, bar.time), true); }
void fillOrdersOpen(Symbol symbol, Bar bar) { fillOrders(symbol, new Tick(bar.open, 0, bar.time), order => order.fillPrice(bar.open, true), false); }
protected override void onNewTick(Bar partialBar, Tick tick) { placeOrders(); }
static StockPt stockPoint(Bar bar) { return(new StockPt(new XDate(bar.time).XLDate, bar.high, bar.low, bar.open, bar.close, bar.volume)); }
static void tick(Simulator simulator, Bar current, Symbol symbol) { symbol.publish(current); simulator.waitForTick(); }