private void portfolio_PositionClosed(object sender, PositionEventArgs args) { try { FreeQuant.Instruments.Instrument instrument = args.Position.Instrument; if (this.activeStops.ContainsKey(instrument)) { foreach (ATSStop atsStop in new ArrayList((ICollection)this.activeStops[instrument])) { if (((StopBase)atsStop).Type == FreeQuant.Trading.StopType.Time && ((StopBase)atsStop).Status == null || atsStop.Connected) { atsStop.OnPositionClosed(args.Position); } } } Strategy strategy = (Strategy)null; if (!this.strategies.TryGetValue(instrument, out strategy)) { return; } strategy.OnPositionClosed(); } catch (Exception ex) { this.EmitError(ex); } }
public void SetNewBarOpen(FreeQuant.Instruments.Instrument instrument, FreeQuant.Data.Bar bar) { try { if (this.stops.Count != 0) { List <ATSStop> list = (List <ATSStop>)null; if (this.activeStops.TryGetValue(instrument, out list)) { foreach (ATSStop atsStop in new ArrayList((ICollection)list)) { if (atsStop.Connected) { atsStop.OnNewBarOpen(bar); } } } } Strategy strategy = (Strategy)null; if (!this.strategies.TryGetValue(instrument, out strategy)) { return; } strategy.OnBarOpen((OpenQuant.API.Bar) this.objectConverter.Convert(bar)); } catch (Exception ex) { this.EmitError(ex); } }
internal MarketDataSubscription(IMarketDataProvider provider, Instrument instrument, MarketDataType mdType, int count) { this.Provider = provider; this.Instrument = instrument; this.MDType = mdType; this.Count = count; }
private void AddInstrument(Instrument instrument) { List <GroupNode> list = new List <GroupNode>(); foreach (GroupNode groupNode in this.trvInstruments.Nodes) { if (groupNode.IsInstrumentValid(instrument)) { list.Add(groupNode); } } if (list.Count == 0) { switch (this.ActiveGroupMode) { case GroupMode.Alphabet: list.Add(new AlphabetGroupNode(((FIXInstrument)instrument).Symbol[0])); break; case GroupMode.Currency: list.Add(new CurrencyGroupNode(instrument.Currency)); break; case GroupMode.Exchange: list.Add(new ExchangeGroupNode(((FIXInstrument)instrument).SecurityExchange)); break; case GroupMode.InstrumentType: InstrumentType type = OpenQuant.Shared.APITypeConverter.InstrumentType.Convert(instrument.SecurityType); list.Add(new InstrumentTypeGroupNode(type)); // list.Add(new InstrumentTypeGroupNode(OpenQuant.Instruments[((FIXInstrument) instrument).Symbol].Type)); break; case GroupMode.Maturity: list.Add(new MaturityGroupNode(((FIXInstrument)instrument).MaturityDate)); break; case GroupMode.Group: list.Add(new IndustryGroupGroupNode(instrument.IndustryGroup)); break; case GroupMode.Sector: list.Add(new IndustrySectorGroupNode(instrument.IndustrySector)); break; case GroupMode.None: list.Add(new AnySymbolGroupNode()); break; default: throw new Exception(); } this.trvInstruments.Nodes.Add((TreeNode)list[0]); } foreach (GroupNode groupNode in list) { groupNode.AddInstrument(instrument); } }
public Position this[Instrument instrument] { get { return this.positions[instrument.Symbol] as Position; } }
public Signal(DateTime datetime, ComponentType sender, SignalType type, SignalSide side, double qty, double strategyPrice, Instrument instrument, string text) : base() { this.BuyColor = Color.Blue; this.BuyCoverColor = Color.SkyBlue; this.SellColor = Color.Pink; this.SellShortColor = Color.Red; this.ToolTipEnabled = true; this.ToolTipFormat = "dfdfs"; this.DateTime = datetime; this.Sender = sender; this.Type = type; this.Side = side; this.Qty = qty; this.StrategyPrice = strategyPrice; this.Instrument = instrument; this.Price = this.Instrument.Price(); this.TimeInForce = TimeInForce.GTC; this.Text = text; this.Strategy = (Strategy)null; this.Rejecter = ComponentType.Unknown; this.StopPrice = 0.0; this.LimitPrice = 0.0; this.Status = SignalStatus.New; }
public virtual SingleOrder LongEntry(Instrument instrument, string text) { if (!this.Strategy.IsInstrumentActive(instrument)) return null; else return this.Strategy.BgvpSPpUAD(new Signal(DateTime.Now, ComponentType.CrossEntry, SignalType.Market, SignalSide.Buy, instrument, text)); }
public QuoteViewRow(Instrument instrument) : base(instrument, 10) { this.prevPrice = 0.0; Color color1 = Color.FromArgb((int)byte.MaxValue, (int)byte.MaxValue, 200); Color color2 = Color.FromArgb((int)byte.MaxValue, 230, 230); Color color3 = Color.FromArgb(220, (int)byte.MaxValue, 220); this.Cells[0].Value = (object)((FIXInstrument)instrument).Symbol; this.Cells[0].Style.BackColor = color1; this.Cells[2].Style.Format = instrument.PriceDisplay; this.Cells[3].Style.Format = instrument.PriceDisplay; this.Cells[7].Style.Format = instrument.PriceDisplay; this.Cells[7].Style.BackColor = color2; this.Cells[8].Style.Format = instrument.PriceDisplay; this.Cells[8].Style.BackColor = color3; NumberFormatInfo numberFormatInfo = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone(); numberFormatInfo.NumberDecimalDigits = 0; this.Cells[4].Style.FormatProvider = (IFormatProvider)numberFormatInfo; this.Cells[6].Style.FormatProvider = (IFormatProvider)numberFormatInfo; this.Cells[6].Style.BackColor = color2; this.Cells[9].Style.FormatProvider = (IFormatProvider)numberFormatInfo; this.Cells[9].Style.BackColor = color3; this.Cells[4].Style.Format = "n"; this.Cells[6].Style.Format = "n"; this.Cells[9].Style.Format = "n"; this.Cells[1].Style.Format = DateTimeFormatInfo.CurrentInfo.LongTimePattern; }
public virtual SingleOrder ShortEntry(Instrument instrument, string text) { if (!this.Strategy.IsInstrumentActive(instrument)) return (SingleOrder)null; else return this.Strategy.BgvpSPpUAD(new Signal(Clock.Now, ComponentType.CrossEntry, SignalType.Market, SignalSide.SellShort, instrument, text)); }
public SingleOrder this[Instrument instrument, string name] { get { return (this.orders[instrument] as NamedOrderTable)[name]; } }
public MarketOrder SendMarketOrder(Instrument instrument, Side side, double qty) { MarketOrder marketOrder = new MarketOrder(instrument, side, qty); this.Strategy.EB2iXBUSFK((SingleOrder)marketOrder); marketOrder.Send(); return marketOrder; }
private static void RemoveInstrument(FreeQuant.Instruments.Instrument fq_instrument) { OpenQuant.instruments.Remove(fq_instrument.Symbol); Instrument instrument = Map.FQ_OQ_Instrument[fq_instrument] as Instrument; Map.OQ_FQ_Instrument.Remove(instrument); Map.FQ_OQ_Instrument.Remove(fq_instrument); }
public static void Remove(Instrument instrument) { InstrumentManager.Server.Remove(instrument); InstrumentManager.Instruments.Remove(instrument); if (InstrumentManager.InstrumentRemoved == null) return; InstrumentManager.InstrumentRemoved(new InstrumentEventArgs(instrument)); }
// private static void SQ_OrderManager_OrderListUpdated(object sender, EventArgs e) // { // OpenQuant.orders.Clear(); // Map.OQ_FQ_Order.Clear(); // Map.FQ_OQ_Order.Clear(); // foreach (SingleOrder order1 in (FIXGroupList) ((InstrumentOrderListTable) OrderManager.Orders).All) // { // Order order2 = new Order(order1); // OpenQuant.orders.Add(order2); // Map.OQ_FQ_Order[order2] = order1; // Map.FQ_OQ_Order[order1] = order2; // } // } private static void AddInstrument(FreeQuant.Instruments.Instrument fq_instrument) { Instrument instrument = new Instrument(fq_instrument); OpenQuant.instruments.Add(fq_instrument.Symbol, instrument); Map.OQ_FQ_Instrument[instrument] = fq_instrument; Map.FQ_OQ_Instrument[fq_instrument] = instrument; }
public void AddInstruments(Instrument[] instruments) { this.treeView.BeginUpdate(); foreach (Instrument instrument in instruments) this.AddInstrument(instrument); if (this.treeView.Nodes.Count == 1) this.treeView.Nodes[0].Expand(); this.treeView.EndUpdate(); }
public void AddInstrument(Instrument instrument) { if (this.instrumentNodes.ContainsKey(instrument)) return; InstrumentNode instrumentNode = new InstrumentNode(instrument); this.instrumentNodes.Add(instrument, instrumentNode); this.Nodes.Add(instrumentNode); this.UpdateToolTipText(); }
public NamedOrderTable this[Instrument instrument] { get { if (!this.orders.ContainsKey(instrument)) this.orders.Add(instrument, new NamedOrderTable()); return this.orders[instrument] as NamedOrderTable; } }
private void RemoveInstrument(Instrument instrument) { GroupNode[] groupNodeArray = new GroupNode[this.treeView.Nodes.Count]; this.treeView.Nodes.CopyTo((Array)groupNodeArray, 0); foreach (GroupNode groupNode in groupNodeArray) { groupNode.RemoveInstrument(instrument); } }
public virtual SingleOrder LongEntry(Instrument instrument, FillOnBarMode mode, string text) { if (!this.Strategy.IsInstrumentActive(instrument)) return (SingleOrder)null; return this.Strategy.BgvpSPpUAD(new Signal(Clock.Now, ComponentType.CrossEntry, SignalType.Market, SignalSide.Buy, instrument, text) { Fuwj5CvMiW = true, R2djQy947W = mode }); }
public virtual SingleOrder LongEntry(Instrument instrument, double price, string text) { if (!this.Strategy.IsInstrumentActive(instrument)) return (SingleOrder)null; return this.Strategy.BgvpSPpUAD(new Signal(Clock.Now, ComponentType.CrossEntry, SignalType.Market, SignalSide.Buy, instrument, text) { StrategyFill = true, StrategyPrice = price }); }
public InstrumentRow(Instrument instrument) { this.Instrument = instrument; this.Trades = 0; this.Quotes = 0; this.Bars = 0; this.MarketDepths = 0; this.Cells[0].Value = (object) ((FIXInstrument) instrument).Symbol; this.UpdateValues(); }
public TrailingStopOrder(IExecutionProvider provider, Portfolio portfolio, Instrument instrument, Side side, double qty, double delta) : base() { this.OrdType = OrdType.TrailingStop; this.Provider = provider; this.Portfolio = portfolio; this.Instrument = instrument; this.Side = side; this.OrderQty = qty; this.TrailingAmt = delta; }
internal void Add(Instrument instrument, Bar bar) { BarSlice barSlice = null; if (!this.data.TryGetValue(bar.Size, out barSlice)) { barSlice = new BarSlice(this.InstrumentsCount); this.data.Add(bar.Size, barSlice); } barSlice.Add(instrument, bar); }
protected override void OnInit() { InstrumentProviderKey instrumentProviderKey = (InstrumentProviderKey) this.Key; this.instrument = instrumentProviderKey.Instrument; this.marketDataProvider = (IMarketDataProvider) instrumentProviderKey.Provider; if ((int) ((IProvider) this.marketDataProvider).Id != 1) ThreadPool.QueueUserWorkItem((WaitCallback) (state => Global.ProviderHelper.RequestMarketData(this.marketDataProvider, this.instrument, (MarketDataType) 4))); Global.TimerManager.Start((ITimerItem) this); this.Text = string.Format("Order Book [{0}]", (object) ((FIXInstrument) this.instrument).Symbol); }
public MarketOrder(IExecutionProvider provider, Portfolio portfolio, Instrument instrument, Side side, double qty, string text) : base() { this.OrdType = OrdType.Market; this.Provider = provider; this.Portfolio = portfolio; this.Instrument = instrument; this.Side = side; this.OrderQty = qty; this.Text = text; }
public void AddInstrument(Instrument instrument, IMarketDataProvider marketDataProvider, IExecutionProvider executionProvider) { if (!this.cYRAR9UWJy.Contains(instrument)) this.cYRAR9UWJy.Add(instrument); this.nxTAjlViDK[instrument] = marketDataProvider == null ? this.strategyMarketDataProvider : marketDataProvider; if (executionProvider != null) this.utDAWNS3ic[instrument] = executionProvider; else this.utDAWNS3ic[instrument] = this.strategyExecutionProvider; }
public void Remove(Instrument instrument) { this.instrumentsBySymbol.Remove(instrument.Symbol); this.SB4BlaFNT0.Remove(instrument); foreach (DictionaryEntry dictionaryEntry in new SortedList((IDictionary) this.s1kB8GECjT)) { if (instrument == dictionaryEntry.Value) this.s1kB8GECjT.Remove(dictionaryEntry.Key); } base.Remove(instrument); }
public TimeSeries this[Instrument instrument] { get { return this.serieses[instrument] as TimeSeries; } set { this.serieses[instrument] = value; } }
public StopLimitOrder(Instrument instrument, Side side, double qty, double price, double stopPx) : base() { this.OrdType = OrdType.StopLimit; this.Provider = ProviderManager.DefaultExecutionProvider; this.Portfolio = PortfolioManager.DefaultPortfolio; this.Instrument = instrument; this.Side = side; this.OrderQty = qty; this.Price = price; this.StopPx = stopPx; }
public void Add(Instrument instrument) { if (this.instrumentsBySymbol.Contains(instrument.Symbol)) throw new ApplicationException(instrument.Symbol); this.instrumentsBySymbol.Add(instrument.Symbol, instrument); this.SB4BlaFNT0.Add(instrument, true); foreach (FIXSecurityAltIDGroup group in instrument.SecurityAltIDGroup) this.s1kB8GECjT[group.SecurityAltID + "" + group.SecurityAltIDSource] = instrument; base.Add(instrument); }
public StopLimitOrder(IExecutionProvider provider, Portfolio portfolio, Instrument instrument, Side side, double qty, double price, double stopPx) : base() { this.OrdType = OrdType.StopLimit; this.Provider = provider; this.Portfolio = portfolio; this.Instrument = instrument; this.Side = side; this.OrderQty = qty; this.Price = price; this.StopPx = stopPx; }
public virtual SingleOrder ShortExit(Instrument instrument, string text) { if (!this.Strategy.IsInstrumentActive(instrument)) return (SingleOrder) null; Signal signal = new Signal(Clock.Now, ComponentType.Exit, SignalType.Market, SignalSide.BuyCover, instrument, text); if (!this.HasPosition || this.Position.Side != PositionSide.Short) { signal.Status = SignalStatus.Rejected; signal.Rejecter = ComponentType.Exit; } return this.Strategy.BgvpSPpUAD(signal); }
public void RemoveInstrument(Instrument instrument) { if (!this.instrumentNodes.ContainsKey(instrument)) return; InstrumentNode instrumentNode = this.instrumentNodes[instrument]; this.instrumentNodes.Remove(instrument); instrumentNode.Remove(); if (this.Nodes.Count == 0) this.Remove(); else this.UpdateToolTipText(); }
public virtual double Price(Instrument instrument) { if (instrument.Trade.DateTime != DateTime.MinValue && instrument.Trade.DateTime >= instrument.Bar.DateTime) return instrument.Trade.Price; if (instrument.Bar.DateTime != DateTime.MinValue) return instrument.Bar.Close; Daily last = (Daily)(instrument.GetDailySeries()).Last; if (last != null) return last.Close; else return 0.0; }
public int this[Instrument instrument] { get { object obj = this.Whi61bRdZC[instrument]; return (obj != null) ? (int)obj : 0; } set { this.Whi61bRdZC[instrument] = value; } }
public double this [Instrument instrument] { get { object obj = this.yvNRbXLeMW[instrument]; return (obj != null) ? (double)obj : 0.0; } set { this.yvNRbXLeMW[instrument] = value; } }
private void ViewChart() { if (!this.viewChartEnabled) { return; } Instrument selectedInstrument = this.GetSelectedInstrument(); if (selectedInstrument == null) { return; } Global.DockManager.Open(typeof(QuickChartForm), selectedInstrument); }
private void marketDataProvider_NewMarketDepth(object sender, MarketDepthEventArgs args) { FreeQuant.Instruments.Instrument instrument = args.Instrument as FreeQuant.Instruments.Instrument; List <StrategyRunner> list = (List <StrategyRunner>)null; if (!this.instrumentTable.TryGetValue(instrument, out list)) { return; } foreach (StrategyRunner strategyRunner in list) { strategyRunner.SetNewMarketDepth(instrument, args.MarketDepth); } }
private void ViewData() { if (!this.viewDataEnabled) { return; } Instrument selectedInstrument = this.GetSelectedInstrument(); if (selectedInstrument == null) { return; } Global.DockManager.Open(typeof(InstrumentDataWindow), selectedInstrument); }
public void SetNewMarketDepth(FreeQuant.Instruments.Instrument instrument, MarketDepth depth) { try { Strategy strategy = (Strategy)null; if (!this.strategies.TryGetValue(instrument, out strategy)) { return; } strategy.OnOrderBookChanged((OrderBookUpdate)this.objectConverter.Convert(depth)); } catch (Exception ex) { this.EmitError(ex); } }
public void SetNewBar(FreeQuant.Instruments.Instrument instrument, FreeQuant.Data.Bar bar) { try { if (bar.BarType == FreeQuant.Data.BarType.Time) { this.barSliceManager.AddBar(instrument, bar); } else { this.OnNewBar(instrument, bar); } } catch (Exception ex) { this.EmitError(ex); } }
// base use FreeQuant.Instruments.Instrument public override bool IsInstrumentValid(FreeQuant.Instruments.Instrument instrument) { return(OpenQuant.Shared.APITypeConverter.InstrumentType.Convert(instrument.SecurityType) == this.instrumentType); // return OpenQuant.Instruments[instrument.Symbol].Type == this.instrumentType; }
private void ctxInstruments_AddNew_Click(object sender, EventArgs e) { NewInstrumentForm newInstrumentForm = new NewInstrumentForm(); TreeNode selectedNode = this.trvInstruments.SelectedNode; string str1 = (string)null; if (selectedNode is InstrumentNode) { str1 = ((FIXInstrument)(selectedNode as InstrumentNode).Instrument).SecurityType; } if (selectedNode is GroupNode) { SortedList <string, bool> sortedList = new SortedList <string, bool>(); foreach (Instrument instrument in (selectedNode as GroupNode).Instruments) { sortedList[((FIXInstrument)instrument).SecurityType] = true; } if (sortedList.Count == 1) { str1 = sortedList.Keys[0]; } } if (str1 != null) { newInstrumentForm.InstrumentType = APITypeConverter.InstrumentType.Convert(str1); } while (newInstrumentForm.ShowDialog((IWin32Window)this) == DialogResult.OK) { string symbol = newInstrumentForm.Symbol; string str2 = APITypeConverter.InstrumentType.Convert(newInstrumentForm.InstrumentType); string exchange = newInstrumentForm.Exchange; string currency = newInstrumentForm.Currency; DateTime maturity = newInstrumentForm.Maturity; PutOrCall putOrCall = APITypeConverter.PutCall.Convert(newInstrumentForm.PutCall); double strike = newInstrumentForm.Strike; if (InstrumentManager.Instruments.Contains(symbol)) { int num = (int)MessageBox.Show((IWin32Window)this, string.Format("Instrument {0} already exists!", symbol), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { Instrument instrument = new Instrument(symbol, str2); if (!string.IsNullOrEmpty(exchange)) { ((FIXInstrument)instrument).SecurityExchange = exchange; } if (!string.IsNullOrEmpty(currency)) { instrument.Currency = currency; } if (str2 == "FUT" || str2 == "OPT" || str2 == "FOP") { ((FIXInstrument)instrument).MaturityDate = maturity; if (str2 == "OPT" || str2 == "FOP") { instrument.PutOrCall = putOrCall; ((FIXInstrument)instrument).StrikePrice = strike; } } instrument.Save(); break; } } newInstrumentForm.Dispose(); }
public Transaction(DateTime dateTime, Side side, double qty, Instrument instrument, double price, double commission, CommType commType) : this(dateTime, side, qty, instrument, price) { this.transactionCost.Commission = commission; this.transactionCost.CommType = commType; }
public bool HasPosition(Instrument instrument) { return(this.positions[instrument] != null); }
public bool Contains(Instrument instrument) { return(this.positions.Contains(instrument)); }
public void Add(DateTime datetime, Side side, double qty, Instrument instrument, double price) { this.Add(new Transaction(datetime, side, qty, instrument, price)); }