Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 protected override void onNewTick(Bar partialBar, Tick tick)
 {
 }
Ejemplo n.º 7
0
 void fillOrdersClose(Symbol symbol, Bar bar)
 {
     fillOrdersNotOpen(symbol, new Tick(bar.close, 0, bar.time), true);
 }
Ejemplo n.º 8
0
 void fillOrdersOpen(Symbol symbol, Bar bar)
 {
     fillOrders(symbol, new Tick(bar.open, 0, bar.time), order => order.fillPrice(bar.open, true), false);
 }
Ejemplo n.º 9
0
 protected override void onNewTick(Bar partialBar, Tick tick)
 {
     placeOrders();
 }
Ejemplo n.º 10
0
 static StockPt stockPoint(Bar bar)
 {
     return(new StockPt(new XDate(bar.time).XLDate, bar.high, bar.low, bar.open, bar.close, bar.volume));
 }
Ejemplo n.º 11
0
 static void tick(Simulator simulator, Bar current, Symbol symbol)
 {
     symbol.publish(current);
     simulator.waitForTick();
 }