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 T theSymbolSystem <T>(Symbol symbol) where T : SymbolSystem { var typedBridge = (QREBridge <IndependentSymbolSystems <T> >)bridge; var multiSymbol = typedBridge.system; return(the(multiSymbol.systems(symbol))); }
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); }
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]); }
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); } }
Symbol symbol(string name) { var result = new Symbol(new Market(name)); if (slippageCalculator != null) { result.overrideSlippageCalculator(slippageCalculator); } return(result); }
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)); }
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(); }); }
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]); }
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; } } }
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); }
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 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); }
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(); }
protected List <Order> orders(Symbol symbol) { return(system().orders(symbol)); }
protected void fill(Symbol symbol, int index, double price) { fill(orders(symbol)[index], price); }
static void tick(Simulator simulator, Bar current, Symbol symbol) { symbol.publish(current); simulator.waitForTick(); }
void fillOrdersNotOpen(Symbol symbol, Tick tick, bool isClose) { fillOrders(symbol, tick, order => order.fillPrice(tick.price, false), isClose); }
public double slippage(Symbol symbol) { return(bridge.slippage(symbol)); }
public GenericTestSystem(QREBridgeBase bridge, Symbol symbol) : base(bridge, symbol) { }
public BarSpud bars(Symbol s) { return(bridge.bars(s)); }
protected Position position(Symbol symbol) { return(system().position(symbol)); }
public List <Order> orders(Symbol symbol) { return(bridge.orders(symbol)); }
void fillOrdersOpen(Symbol symbol, Bar bar) { fillOrders(symbol, new Tick(bar.open, 0, bar.time), order => order.fillPrice(bar.open, true), false); }
public TestOnCloseSystem(QREBridgeBase bridge, Symbol symbol) : base(bridge, symbol) { bars.close.prepare(); }
public double fxRate(Symbol symbol) { return(bridge.fxRate(symbol)); }
protected static PublishCounter positionPublishCounter(Symbol symbol) { return(new PublishCounter(OrderTable.DEFAULT_PREFIX + ".TestSystem1.1.0.daily.Slow." + symbol.name + ".optimalPosition")); }
public void removeNewBarListener(Symbol symbol, Action <Bar> onNewBar) { newBarListeners.overwrite(symbol, newBarListeners.get(symbol) - onNewBar); }
protected void hasPosition(Symbol symbol, double amount) { AreEqual(amount, position(symbol).amount); }
void fillOrdersClose(Symbol symbol, Bar bar) { fillOrdersNotOpen(symbol, new Tick(bar.close, 0, bar.time), true); }