Example #1
0
 public void SetNewTrade(FreeQuant.Instruments.Instrument instrument, FreeQuant.Data.Trade trade)
 {
     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.OnNewTrade(trade);
                     }
                 }
             }
         }
         Strategy strategy = (Strategy)null;
         if (!this.strategies.TryGetValue(instrument, out strategy))
         {
             return;
         }
         strategy.OnTrade((OpenQuant.API.Trade) this.objectConverter.Convert(trade));
     }
     catch (Exception ex)
     {
         this.EmitError(ex);
     }
 }
Example #2
0
		public void OnNewTrade(IFIXInstrument instrument, Trade trade)
		{
			if (this.Enabled && this.Input == BarFactoryInput.Trade)
			{
				this.AddTrade(instrument, trade.DateTime, trade.Price, trade.Size);
			}
		}
Example #3
0
		public MarketDataUpdateItem(MarketDataViewRow row, Quote quote, Trade trade, Bar bar)
		{
			this.Row = row;
			this.Quote = quote;
			this.Trade = trade;
			this.Bar = bar;
		}
Example #4
0
		public void Update(Quote quote, Trade trade, Bar bar)
		{
			if (!this.enabled)
				return;
			if (quote != null)
				this.OnUpdateQuote(quote);
			if (trade != null)
				this.OnUpdateTrade(trade);
			if (bar == null)
				return;
			this.OnUpdateBar(bar);
		}
Example #5
0
 protected override void OnUpdateTrade(Trade trade)
 {
     double change = this.GetChange(trade.Price);
     this.Cells[1].Value = trade.DateTime;
     this.Cells[2].Value = trade.Price;
     this.Cells[3].Value = change;
     this.Cells[4].Value = trade.Size;
     if (change > 0.0)
         this.Cells[2].Style.ForeColor = Color.Green;
     else if (change < 0.0)
     {
         this.Cells[2].Style.ForeColor = Color.Red;
     }
     else
     {
         if (this.DataGridView == null)
             return;
         this.Cells[2].Style.ForeColor = this.DataGridView.Columns[2].DefaultCellStyle.ForeColor;
     }
 }
Example #6
0
 public void EmitTrade(Instrument instrument, DateTime time, byte providerId, double price, int size)
 {
     FreeQuant.Data.Trade trade = new FreeQuant.Data.Trade(time, price, size);
     trade.ProviderId = providerId;
     if (this.MarketDataFilter != null)
     {
         trade = this.MarketDataFilter.FilterTrade(trade, instrument.Symbol);
     }
     if (trade == null)
     {
         return;
     }
     if (this.NewTrade != null)
     {
         this.NewTrade((object)this, new TradeEventArgs(trade, (IFIXInstrument)instrument.instrument, (IMarketDataProvider)this));
     }
     if (this.barFactory == null)
     {
         return;
     }
     this.barFactory.OnNewTrade((IFIXInstrument)instrument.instrument, trade);
 }
Example #7
0
		private double VirF0ddUxQ(SingleOrder obj0, Quote obj1, Trade obj2, Bar obj3)
		{
			bool flag = !obj0.IsStopLimitReady && (obj0.OrdType == OrdType.TrailingStop || obj0.OrdType == OrdType.TrailingStopLimit || obj0.OrdType == OrdType.StopLimit);
			if (obj1 != null && this.A8bFJItyyx.PartialFills && (this.A8bFJItyyx.FillOnQuote && !flag || this.A8bFJItyyx.TriggerOnQuote && flag))
			{
				if (!this.A8bFJItyyx.FillAtWorstQuoteRate || obj1.Bid <= obj1.Ask)
				{
					switch (obj0.Side)
					{
						case Side.Buy:
							if (obj1.AskSize > 0)
								return (double) obj1.AskSize;
							else
								break;
						case Side.Sell:
						case Side.SellShort:
							if (obj1.BidSize > 0)
								return (double) obj1.BidSize;
							else
								break;
						default:
							return obj0.OrderQty;
					}
				}
				else
				{
					switch (obj0.Side)
					{
						case Side.Buy:
							if (obj1.BidSize > 0)
								return (double) obj1.BidSize;
							else
								break;
						case Side.Sell:
						case Side.SellShort:
							if (obj1.Ask > 0.0)
								return (double) obj1.AskSize;
							else
								break;
						default:
							return obj0.OrderQty;
					}
				}
			}
			if ((this.A8bFJItyyx.FillOnTrade && !flag || this.A8bFJItyyx.TriggerOnTrade && flag) && obj2 != null)
			{
				if ((obj0.OrdType == OrdType.Limit || (obj0.OrdType == OrdType.StopLimit || obj0.OrdType == OrdType.TrailingStopLimit) && obj0.IsStopLimitReady) && (obj0.CumQty == 0.0 && Math.Abs(obj2.Price - obj0.Price) < 0.001 && (obj0.TradeVolumeDelay != 0 && !this.gxTF8gufMx)))
				{
					this.w02FZf7vnP += obj2.Size;
					if (this.w02FZf7vnP <= obj0.TradeVolumeDelay)
						return 0.0;
					this.gxTF8gufMx = true;
					if (this.A8bFJItyyx.PartialFills)
						return (double) (this.w02FZf7vnP - obj0.TradeVolumeDelay);
					else
						return obj0.OrderQty;
				}
				else if (this.A8bFJItyyx.PartialFills)
					return (double) obj2.Size;
			}
			return obj0.OrderQty;
		}
Example #8
0
 protected override void OnNewTrade(Instrument instrument, Trade trade)
 {
   foreach (Stop stop in new ArrayList((ICollection) this.activeStops[instrument]))
   {
     if (stop.Connected)
       stop.yu56453Z5Z(trade);
   }
   this.A6MpF2380O.OnTrade(instrument, trade);
   this.HeHpDewVKD.OnTrade(instrument, trade);
   this.marketManager.OnTrade(instrument, trade);
   this.exits[instrument].OnTrade(trade);
   this.entries[instrument].OnTrade(trade);
   this.moneyManagers[instrument].OnTrade(trade);
   this.riskManagers[instrument].OnTrade(trade);
 }
Example #9
0
 public void Add(Trade trade)
 {
     DataManager.Add(this, trade);
 }
Example #10
0
		private void EmitNewTrade(IFIXInstrument instrument, Trade trade)
		{
			if (this.NewTrade != null)
			{
				this.NewTrade(this, new TradeEventArgs(trade, instrument, this));
			}
			if (this.barFactory != null)
			{
				this.barFactory.OnNewTrade(instrument, trade);
			}
		}
Example #11
0
		public SimpleDataObject(IFIXInstrument instrument, Trade trade)
		{
			this.DateTime = trade.DateTime;
			this.Instrument = instrument;
			this.DataType = 0;
		}
Example #12
0
		protected override void OnNewTrade(Instrument instrument, Trade trade)
		{
			foreach (ATSStop atsStop in new ArrayList((ICollection) this.activeStops[instrument]))
			{
				if (atsStop.Connected)
					atsStop.OnNewTrade(trade);
			}
			this.marketManager.OnTrade(instrument, trade);
			this.klBiFcxZsD.OnTrade(instrument, trade);
			this.csNiLdTRqH[instrument].OnTrade(trade);
		}
Example #13
0
		public void OnNewTrade(Trade trade)
		{
			if (!this.fTraceOnTrade)
				return;
			this.fCurrPrice = trade.Price;
			this.fFillPrice = trade.Price;
			this.fTrailPrice = trade.Price;
			this.oEtiRP16ys();
		}
Example #14
0
 public object Convert(FreeQuant.Data.Trade trade)
 {
     return(new Trade(trade));
 }
Example #15
0
		protected virtual void OnUpdateTrade(Trade trade)
		{
		}
Example #16
0
		public virtual void OnTrade(Instrument instrument, Trade trade)
		{
		}
Example #17
0
 public override void Write(Instrument instrument, Trade trade)
 {
   if (this.error != null)
     throw this.error;
   this.Enqueue(instrument, (IDataObject) trade);
 }
Example #18
0
 public TradeAction(Instrument instrument, Trade trade)
   : base(instrument)
 {
   this.trade = trade;
 }
Example #19
0
		public void OnNewTrade(IFIXInstrument instrument, Trade trade)
		{
			if (!this.Enabled || this.Input != BarFactoryInput.Trade)
				return;
			this.AddTrade(instrument, DateTime.Now, trade.Price, trade.Size);
		}
Example #20
0
		public void EmitTrade(IFIXInstrument instrument, Trade trade)
		{
			this.Simulator.nNp9oHTwk(new SimpleDataObject(instrument, trade));
		}
Example #21
0
		private double CcXFPEywDQ(Quote obj0, Trade obj1, Bar obj2)
		{
			SingleOrder singleOrder = this.PYBF7sahqY as SingleOrder;
			if (singleOrder.ContainsField(11103) && singleOrder.StrategyFill)
				return singleOrder.StrategyPrice;
			bool flag = !singleOrder.IsStopLimitReady && (singleOrder.OrdType == OrdType.TrailingStop || singleOrder.OrdType == OrdType.TrailingStopLimit || singleOrder.OrdType == OrdType.StopLimit);
			if (obj0 != null && (this.A8bFJItyyx.FillOnQuote && !flag || this.A8bFJItyyx.TriggerOnQuote && flag))
			{
				if (!this.A8bFJItyyx.FillAtWorstQuoteRate || obj0.Bid <= obj0.Ask)
				{
					switch (singleOrder.Side)
					{
						case Side.Buy:
						case Side.BuyMinus:
							if (obj0.Ask != 0.0)
								return obj0.Ask;
							else
								break;
						case Side.Sell:
						case Side.SellShort:
							if (obj0.Bid != 0.0)
								return obj0.Bid;
							else
								break;
						default:
							throw new NotSupportedException("" + ((object) singleOrder.Side).ToString());
					}
				}
				else
				{
					switch (singleOrder.Side)
					{
						case Side.Buy:
						case Side.BuyMinus:
							if (obj0.Bid != 0.0)
								return obj0.Bid;
							else
								break;
						case Side.Sell:
						case Side.SellShort:
							if (obj0.Ask != 0.0)
								return obj0.Ask;
							else
								break;
						default:
							throw new NotSupportedException("" + ((object) singleOrder.Side).ToString());
					}
				}
			}
			if (obj1 != null && (this.A8bFJItyyx.FillOnTrade && !flag || this.A8bFJItyyx.TriggerOnTrade && flag) && obj1.Price != 0.0)
				return obj1.Price;
			if (obj2 != null && (this.A8bFJItyyx.FillOnBar && !flag || this.A8bFJItyyx.TriggerOnBar && flag))
			{
				if (singleOrder.StrategyComponent == "which")
					return singleOrder.StrategyPrice;
				if (singleOrder.ForceMarketOrder)
				{
					if (obj2.Close != 0.0)
						return obj2.Close;
					if (obj2.Open != 0.0)
						return obj2.Open;
				}
				switch (this.kUyFaL3cQu)
				{
					case FillOnBarMode.LastBarClose:
					case FillOnBarMode.NextBarClose:
						return obj2.Close;
					case FillOnBarMode.NextBarOpen:
						return obj2.Open;
				}
			}
			return 0.0;
		}
Example #22
0
		private void Y18FFPmDy5(Quote obj0, Trade obj1, Bar obj2)
		{
			SingleOrder singleOrder = this.PYBF7sahqY as SingleOrder;
			if (singleOrder.OrdStatus != OrdStatus.New && singleOrder.OrdStatus != OrdStatus.PendingNew && (singleOrder.OrdStatus != OrdStatus.PartiallyFilled && singleOrder.OrdStatus != OrdStatus.Replaced))
				return;
			double num1 = this.CcXFPEywDQ(obj0, obj1, obj2);
			double num2 = this.VirF0ddUxQ(singleOrder, obj0, obj1, obj2);
			if (num1 == 0.0 || num2 == 0.0)
				return;
			if (singleOrder.OrdType == OrdType.Market || singleOrder.OrdType == OrdType.TrailingStop && singleOrder.IsStopLimitReady)
				this.D35FmNWSPm(num1, num2);
			else
				this.wYBFLwFB4S(num1, num2);
		}
Example #23
0
    internal void gSQVAlpOg(Instrument obj0, Trade obj1)
    {
      if (!this.isActive)
        return;
      if (Trace.IsLevelEnabled(TraceLevel.Verbose))
				Trace.WriteLine(string.Format("dfdf", (object) this.Name, (object) obj0.Symbol, (object) obj1));
      this.OnNewTrade(obj0, obj1);
    }
Example #24
0
File: Stop.cs Project: heber/FreeOQ
 internal void yu56453Z5Z(Trade obj0)
 {
   if (!this.fTraceOnTrade)
     return;
   this.fCurrPrice = obj0.Price;
   this.fFillPrice = obj0.Price;
   this.fTrailPrice = obj0.Price;
   this.XqY6FAU6Mj();
 }
Example #25
0
 public static void Add(Instrument instrument, string suffix, Trade trade)
 {
     DataManager.Add(instrument.Symbol + SERIES_SEPARATOR + suffix, trade);
 }
Example #26
0
		public abstract void Write(Instrument instrument, Trade trade);
Example #27
0
 public void Add(string series, Trade trade)
 {
     DataManager.Add(this, series, trade);
 }
Example #28
0
 protected virtual void OnNewTrade(Instrument instrument, Trade trade)
 {
 }
Example #29
0
		public void AddTrade(Trade trade, Instrument instrument)
		{
			this.Il6yEpdoR8.Add(trade.DateTime, new SimpleDataObject(instrument, trade));
		}
Example #30
0
 public static void Add(string series, Trade trade)
 {
     DataManager.server.Add(series, trade);
 }
Example #31
0
		private void ST74ZxO7ZP([In] object obj0, [In] FIXMarketDataSnapshotEventArgs obj1)
		{
			Console.WriteLine(BeAEwTZGlZaeOmY5cm.J00weU3cM6(4536));
			FIXMarketDataSnapshot snapshotFullRefresh = obj1.MarketDataSnapshotFullRefresh;
			Instrument instrument = InstrumentManager.Instruments[(this.mdRequests[(object)snapshotFullRefresh.MDReqID] as RequestRecord).Symbol];
			Trade trade = this.OEp4ErKILr[(object)instrument] as Trade;
			Quote quote = this.Hmv4SHEnBE[(object)instrument] as Quote;
			if (trade == null)
			{
				trade = new Trade();
				this.OEp4ErKILr[(object)instrument] = (object)trade;
			}
			if (quote == null)
			{
				quote = new Quote();
				this.Hmv4SHEnBE[(object)instrument] = (object)quote;
			}
			bool flag1 = false;
			bool flag2 = false;
			for (int i = 0; i < snapshotFullRefresh.NoMDEntries; ++i)
			{
				FIXMDEntriesGroup mdEntriesGroup = snapshotFullRefresh.GetMDEntriesGroup(i);
				switch (mdEntriesGroup.MDEntryType)
				{
					case '0':
						if (quote.Bid != mdEntriesGroup.MDEntryPx || quote.BidSize != (int)mdEntriesGroup.MDEntrySize)
						{
							quote.DateTime = Clock.Now;
							quote.Bid = mdEntriesGroup.MDEntryPx;
							quote.BidSize = (int)mdEntriesGroup.MDEntrySize;
							flag2 = true;
							break;
						}
						else
							break;
					case '1':
						if (quote.Ask != mdEntriesGroup.MDEntryPx || quote.AskSize != (int)mdEntriesGroup.MDEntrySize)
						{
							quote.DateTime = Clock.Now;
							quote.Ask = mdEntriesGroup.MDEntryPx;
							quote.AskSize = (int)mdEntriesGroup.MDEntrySize;
							flag2 = true;
							break;
						}
						else
							break;
					case '2':
						if (trade.Price != mdEntriesGroup.MDEntryPx || trade.Size != (int)mdEntriesGroup.MDEntrySize)
						{
							trade.DateTime = Clock.Now;
							trade.Price = mdEntriesGroup.MDEntryPx;
							trade.Size = (int)mdEntriesGroup.MDEntrySize;
							flag1 = true;
							break;
						}
						else
							break;
				}
			}
			if (flag1 && this.odL46gHXsq != null)
				this.odL46gHXsq((object)this, new TradeEventArgs(new Trade(trade), (IFIXInstrument)instrument, (IMarketDataProvider)this));
			if (flag2 && this.uQX4e0V1fj != null)
				this.uQX4e0V1fj((object)this, new QuoteEventArgs(new Quote(quote), (IFIXInstrument)instrument, (IMarketDataProvider)this));
			if (this.oSc4rhuvbm == null)
				return;
			this.oSc4rhuvbm((object)this, new MarketDataSnapshotEventArgs(obj1.MarketDataSnapshotFullRefresh));
		}
Example #32
0
 public static void Add(Instrument instrument, Trade trade)
 {
     DataManager.Add(instrument, SUFFIX_TRADE, trade);
 }
Example #33
0
		public void EmitTrade(Trade trade, Instrument instrument)
		{
			if (this.MarketDataFilter != null)
			{
				trade = this.MarketDataFilter.FilterTrade(trade, instrument.Symbol);
				if (trade == null)
					return;
			}
			if (this.odL46gHXsq != null)
				this.odL46gHXsq((object)this, new TradeEventArgs(trade, (IFIXInstrument)instrument, (IMarketDataProvider)this));
			if (this.barFactory == null)
				return;
			this.barFactory.OnNewTrade((IFIXInstrument)instrument, trade);
		}