コード例 #1
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);
        }
コード例 #2
0
        public T theSymbolSystem <T>(Symbol symbol) where T : SymbolSystem
        {
            var typedBridge = (QREBridge <IndependentSymbolSystems <T> >)bridge;
            var multiSymbol = typedBridge.system;

            return(the(multiSymbol.systems(symbol)));
        }
コード例 #3
0
        static bool isFillable(Order order, Symbol symbol, double tick, bool isClose)
        {
            var matches = order.matches(symbol);
            var canFill = order.canFill(tick, isClose);

            return(matches && canFill);
        }
コード例 #4
0
ファイル: TestSymbolSpud.cs プロジェクト: TzarIvan/ratel
        public void testSymbolValueLive()
        {
            Log.setFile(@"C:\logs\jefftest");

            SystemTimeSeriesTable.SYSTEM_TS.insert("testone", "ASCII", "ActiveMQ", "somedangtopic");
            AsciiTable.SYSTEM_ASCII.insert("testone", @"\\nysrv37\share\Tools\RightEdge\TransitionTest\TY1C.full.csv", true, 1);
            var manager  = new SpudManager();
            var barSpud  = new BarSpud(manager);
            var barSpud2 = new BarSpud(manager);
            var symbol   = new Symbol("testone");
            var spud     = symbol.doubles(barSpud);
            var spud2    = new Symbol("RE.TEST.TY.1C").doubles(barSpud2);

            manager.newBar();
            barSpud.set(new Bar(1, 3, 1, 2, O.date("2008/08/06")));
            barSpud2.set(new Bar(1, 3, 1, 2, O.date("2008/08/06")));

            manager.newTick();
            spud.doSubscribe();

            barSpud.lastTickedAt(O.date("2008/08/06 11:22:34"));
            spud2.doSubscribe();
            IsTrue(spud2.isDirty());
            symbol.javaSymbol().jmsLive().topic().send("value=97.1|timestamp=2008/08/06 11:22:33|MSTimestamp=2008/06/05 13:10:08");

            Bombs(() => LogC.info("" + spud[0]), "stale");
            symbol.javaSymbol().jmsLive().topic().send("value=97.2|timestamp=2008/08/06 11:22:34|MSTimestamp=2008/06/05 13:10:08");
            O.wait(() => spud[0] == 97.2);
            barSpud.lastTickedAt(O.date("2008/08/06 11:22:35"));
            spud.allowStaleTicks();
            AreEqual(97.2, spud[0]);
            AreEqual(116.140625, spud2[0]);
        }
コード例 #5
0
        IEnumerable <Bar> barList(Symbol symbol, Interval interval)
        {
            var jBars = list <JBar>(symbol.bars(ranges[symbol], interval));

            try {
                return(convert(jBars, jbar => new Bar(jbar, false)));
            } catch (Exception e) {
                throw Bomb.toss("error loading bars for symbol: " + symbol, e);
            }
        }
コード例 #6
0
ファイル: SystemRunInfo.cs プロジェクト: TzarIvan/ratel
        Symbol symbol(string name)
        {
            var result = new Symbol(new Market(name));

            if (slippageCalculator != null)
            {
                result.overrideSlippageCalculator(slippageCalculator);
            }
            return(result);
        }
コード例 #7
0
        void fillOrders(Symbol symbol, Tick tick, Converter <Order, double> fillPrice, bool isClose)
        {
            var fillable = accept(orders(symbol), order => isFillable(order, symbol, tick.price, isClose));

            fillable = sort(fillable, (a, b) => {
                var fillA      = Math.Abs(tick.price - fillPrice(a));
                var fillB      = Math.Abs(tick.price - fillPrice(b));
                var priceOrder = fillB.CompareTo(fillA);
                return(priceOrder != 0 ? priceOrder : a.id.CompareTo(b.id));
            });
            each(fillable, order => fillOrderMaybe(order, tick, fillPrice, isClose));
        }
コード例 #8
0
        void populateSlippageCache(Symbol symbol)
        {
            var manager    = new SpudManager();
            var bars       = bars_[symbol];
            var spud       = new BarSpud(manager);
            var calculator = symbol.slippageCalculator(spud);

            each(sort(bars.Keys), date => {
                spud.set(bars[date]);
                slippageCache.get(date)[symbol] = calculator.slippage();
                manager.newBar();
            });
        }
コード例 #9
0
ファイル: TestSymbolSpud.cs プロジェクト: TzarIvan/ratel
        public void testSymbolValueSpud()
        {
            var manager = new SpudManager();
            var barSpud = new BarSpud(manager);
            var spud    = new Symbol("RE.TEST.TY.1C").doubles(barSpud);

            barSpud.set(new Bar(1, 3, 1, 2, O.date("2007/01/02")));
            AreEqual(105.04687500, spud[0]);

            // test barSPud has date, but spud does not
            manager.newBar();
            barSpud.set(new Bar(1, 3, 1, 2, O.date("2007/01/06")));
            AreEqual(105.32812500, spud[0]);
        }
コード例 #10
0
 internal void processTick(Tick tick, Symbol symbol)
 {
     lock (partialBars) {
         trades.Clear();
         var price    = tick.price;
         var runClose = bridge.runOnClose() && !hasRunLiveClose && now().CompareTo(symbol.closeAt()) >= 0;
         fillOrders(symbol, tick, order => price, runClose);
         bridge.processTick(symbol, tick);
         gottenTicks = true;
         if (runClose)
         {
             hasRunLiveClose = true;
         }
     }
 }
コード例 #11
0
        public ITrend(QREBridgeBase bridge, Symbol symbol) : base(bridge, symbol)
        {
            atrLength       = parameter <int>("atrLength");
            sizeScaleSwitch = parameter <int>("sizeScaleSwitch");
            nATRStop        = parameter <double>("nATRStop");
            nATRTrigger     = parameter <double>("nATRTrigger");
            dailyATRSwitch  = parameter <int>("useDailyATR");
            risk            = parameter <int>("risk");
            timeStampClose  = parameter <double>("timeStampClose");
            timeStampMark   = parameter <double>("timeStampMark");

            atr = new AverageTrueRangeEW(
                dailyATRSwitch == 1 ? (Spud <Bar>) new IntervalSpud(bars, Interval.DAILY) : bars,
                atrLength);

            scaleWeights = new double[10];
            zeroTo(scaleWeights.Length, i => scaleWeights[i] = 1.5 - (double)i / 9);
            scaleWins = new double[10];
            initializeWinScale();
            financialCenter = FinancialCenterTable.CENTER.name(39);
        }
コード例 #12
0
ファイル: TestSymbolSpud.cs プロジェクト: TzarIvan/ratel
        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);
        }
コード例 #13
0
ファイル: StatusTreeMap.cs プロジェクト: TzarIvan/ratel
        public List <QNode> nodes()
        {
            var bySystem = new LazyDictionary <string, List <LiveSystem> > (system => new List <LiveSystem>());

            each(systems, liveSystem => bySystem.get(liveSystem.siv().system()).Add(liveSystem));
            var result = list(convert(bySystem.keys(), system => {
                var liveSystems = bySystem.get(system);
                var systemNode  = new QNode(system, liveSystems.Count, 0);
                each(liveSystems, liveSystem => {
                    var liveSystemNode = systemNode.add(new LiveSystemNode(liveSystem, 1, 0));
                    var liveMarkets    = list <MsivPv>(liveSystem.liveMarkets());
                    each(liveMarkets, liveMarket => {
                        try {
                            var symbol         = new Symbol(liveMarket.market());
                            var liveMarketNode = new LiveMarketNode(symbol, 1, 0);
                            liveSystemNode.add(liveMarketNode);
                            var topic = new Topic(liveSystem.topicName(OrderTable.prefix, symbol.name + "." + SystemHeartbeat.SUFFIX));
                            topic.subscribeIfNeeded();
                            updateModelNodes += () => updateNode(topic, liveMarket, liveMarketNode);
                            symbol.subscribe(bar => recordMarketDataTickReceived(liveMarket, bar.time));
                            topic.subscribe(fields => {
                                var tickTime = fields.time("lastTickProcessed");
                                ticks.get(liveMarket).systemProcessed(date(tickTime));
                            });
                        } catch (Exception ex) {
                            LogC.err("exception caught subscribing to tick data for " + liveMarket + ", " + system, ex);
                            gui.alertUser("exception caught susbcribing to data for " + liveMarket + ", " + system + ".\nSkipping... see log for details.");
                        }
                    });
                    updateModelNodes += () => updateNode(liveSystem, liveSystemNode);
                });
                updateModelNodes += () => updateNode(systemNode);
                return(systemNode);
            }));

            timerManager().everyMillis(1000, updateModelNodes, out timer);
            LiveLauncher.subscribeHeartbeat(gui.launcherAvailable);
            LogC.ignore(timer);
            return(result);
        }
コード例 #14
0
ファイル: TestSimulator.cs プロジェクト: TzarIvan/ratel
        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();
        }
コード例 #15
0
 protected List <Order> orders(Symbol symbol)
 {
     return(system().orders(symbol));
 }
コード例 #16
0
 protected void fill(Symbol symbol, int index, double price)
 {
     fill(orders(symbol)[index], price);
 }
コード例 #17
0
ファイル: TestSimulator.cs プロジェクト: TzarIvan/ratel
 static void tick(Simulator simulator, Bar current, Symbol symbol)
 {
     symbol.publish(current);
     simulator.waitForTick();
 }
コード例 #18
0
 void fillOrdersNotOpen(Symbol symbol, Tick tick, bool isClose)
 {
     fillOrders(symbol, tick, order => order.fillPrice(tick.price, false), isClose);
 }
コード例 #19
0
 public double slippage(Symbol symbol)
 {
     return(bridge.slippage(symbol));
 }
コード例 #20
0
ファイル: TestOrderSubmitter.cs プロジェクト: TzarIvan/ratel
 public GenericTestSystem(QREBridgeBase bridge, Symbol symbol) : base(bridge, symbol)
 {
 }
コード例 #21
0
 public BarSpud bars(Symbol s)
 {
     return(bridge.bars(s));
 }
コード例 #22
0
 protected Position position(Symbol symbol)
 {
     return(system().position(symbol));
 }
コード例 #23
0
 public List <Order> orders(Symbol symbol)
 {
     return(bridge.orders(symbol));
 }
コード例 #24
0
 void fillOrdersOpen(Symbol symbol, Bar bar)
 {
     fillOrders(symbol, new Tick(bar.open, 0, bar.time), order => order.fillPrice(bar.open, true), false);
 }
コード例 #25
0
ファイル: TestOnClose.cs プロジェクト: TzarIvan/ratel
 public TestOnCloseSystem(QREBridgeBase bridge, Symbol symbol) : base(bridge, symbol)
 {
     bars.close.prepare();
 }
コード例 #26
0
 public double fxRate(Symbol symbol)
 {
     return(bridge.fxRate(symbol));
 }
コード例 #27
0
 protected static PublishCounter positionPublishCounter(Symbol symbol)
 {
     return(new PublishCounter(OrderTable.DEFAULT_PREFIX + ".TestSystem1.1.0.daily.Slow." + symbol.name + ".optimalPosition"));
 }
コード例 #28
0
 public void removeNewBarListener(Symbol symbol, Action <Bar> onNewBar)
 {
     newBarListeners.overwrite(symbol, newBarListeners.get(symbol) - onNewBar);
 }
コード例 #29
0
 protected void hasPosition(Symbol symbol, double amount)
 {
     AreEqual(amount, position(symbol).amount);
 }
コード例 #30
0
 void fillOrdersClose(Symbol symbol, Bar bar)
 {
     fillOrdersNotOpen(symbol, new Tick(bar.close, 0, bar.time), true);
 }