コード例 #1
0
ファイル: RiskManager.cs プロジェクト: heber/FreeOQ
		public virtual Stop AddStop(Position position, double level, StopType type, StopMode mode)
		{
			if (!this.Strategy.IsInstrumentActive(position.Instrument))
				return null;
			else
				return new Stop(this.Strategy, position, level, type, mode);
		}
コード例 #2
0
ファイル: RiskManager.cs プロジェクト: heber/FreeOQ
		public virtual Stop AddStop(Position position, DateTime time)
		{
			if (!this.Strategy.IsInstrumentActive(position.Instrument))
				return null;
			else
				return new Stop(this.Strategy, position, time);
		}
コード例 #3
0
ファイル: Stop.cs プロジェクト: heber/FreeOQ
		public Stop(StrategyBase strategy, Position position, DateTime time):base()
    {
      this.Udd6EeE9v6 = strategy;
      this.fPosition = position;
      this.fInstrument = position.Instrument;
      this.fQty = position.Qty;
      this.fSide = position.Side;
      this.fType = StopType.Time;
      this.fCreationTime = Clock.Now;
      this.fCompletionTime = time;
      this.fStopPrice = this.fInstrument.Price();
      if (!(this.fCompletionTime > this.fCreationTime))
        return;
      Clock.AddReminder(new ReminderEventHandler(this.mSa6vRBe3Z), this.fCompletionTime, (object) null);
      this.Udd6EeE9v6.AddStop((StopBase) this);
    }
コード例 #4
0
ファイル: Stop.cs プロジェクト: heber/FreeOQ
    public Stop(StrategyBase strategy, Position position, double level, StopType type, StopMode mode)
			:base()
		{
      this.Udd6EeE9v6 = strategy;
      this.fPosition = position;
      this.fInstrument = position.Instrument;
      this.fQty = position.Qty;
      this.fSide = position.Side;
      this.fLevel = level;
      this.fType = type;
      this.fMode = mode;
      this.fCurrPrice = this.fInstrument.Price();
      this.fTrailPrice = this.fCurrPrice;
      this.fStopPrice = this.SlN6PMZ5Ct();
      this.fCreationTime = Clock.Now;
      this.fCompletionTime = DateTime.MinValue;
      this.Udd6EeE9v6.AddStop((StopBase) this);
      this.t276DXCuDr();
    }
コード例 #5
0
ファイル: ATSStop.cs プロジェクト: heber/FreeOQ
		public ATSStop(Position position, double level, StopType type, StopMode mode)	: base()
		{
			this.fPosition = position;
			this.fInstrument = position.Instrument;
			this.fQty = position.Qty;
			this.fSide = position.Side;
			this.fLevel = level;
			this.fType = type;
			this.fMode = mode;
			this.fCurrPrice = this.fInstrument.Price();
			this.fTrailPrice = this.fCurrPrice;
			this.fStopPrice = this.lkZijZtYnj();
			this.fCreationTime = Clock.Now;
			this.fCompletionTime = DateTime.MinValue;
			this.series = new DoubleSeries();
			if (this.fType == StopType.Trailing)
				this.series.Add(this.fCreationTime, this.lkZijZtYnj());
			this.Connect();
		}
コード例 #6
0
ファイル: ATSStop.cs プロジェクト: heber/FreeOQ
		public void OnPositionClosed(Position position)
		{
			if (position != this.fPosition)
				return;
			this.Disconnect();
			this.Lf6iiLBYf9(StopStatus.Canceled);
		}
コード例 #7
0
		public virtual void OnPositionOpened(Position position)
		{
		}
コード例 #8
0
ファイル: ATSStop.cs プロジェクト: heber/FreeOQ
		public ATSStop(Position position, DateTime time) : base()
		{
			this.fPosition = position;
			this.fInstrument = position.Instrument;
			this.fQty = position.Qty;
			this.fSide = position.Side;
			this.fType = StopType.Time;
			this.fCreationTime = Clock.Now;
			this.fCompletionTime = time;
			this.fStopPrice = this.fInstrument.Price();
			this.series = new DoubleSeries();
			if (this.fType == StopType.Trailing)
				this.series.Add(this.fCreationTime, this.lkZijZtYnj());
			if (!(this.fCompletionTime > this.fCreationTime))
				return;
			Clock.AddReminder(new ReminderEventHandler(this.tQYi7Nff5A), this.fCompletionTime, (object)null);
		}
コード例 #9
0
ファイル: StrategyBase.cs プロジェクト: heber/FreeOQ
 protected virtual void OnPositionChanged(Position position)
 {
 }
コード例 #10
0
ファイル: StrategyBase.cs プロジェクト: heber/FreeOQ
 protected virtual void OnPositionOpened(Position position)
 {
 }
コード例 #11
0
		public virtual void OnPositionValueChanged(Position position)
		{
		}
コード例 #12
0
ファイル: PositionList.cs プロジェクト: heber/FreeOQ
		public void Remove(Position position)
		{
			this.positions.Remove(position.Name);
		}
コード例 #13
0
ファイル: Strategy.cs プロジェクト: heber/FreeOQ
 protected override void OnPositionChanged(Position position)
 {
   this.A6MpF2380O.OnPositionChanged(position);
   this.HeHpDewVKD.OnPositionChanged(position);
   this.ayRpJCTRPY.OnPositionChanged(position);
   Instrument instrument = position.Instrument;
   this.exits[instrument].OnPositionChanged();
   this.entries[instrument].OnPositionChanged();
   this.moneyManagers[instrument].OnPositionChanged();
   this.riskManagers[instrument].OnPositionChanged();
 }
コード例 #14
0
ファイル: Stop.cs プロジェクト: heber/FreeOQ
 internal void xbx6LKbgmx(Position obj0)
 {
   if (obj0 != this.fPosition)
     return;
   this.Disconnect();
   this.Lk960PQCI8(StopStatus.Canceled);
 }
コード例 #15
0
 public double Price(FreeQuant.Instruments.Position position)
 {
     return(this.pricer.Price(new Position(position)));
 }
コード例 #16
0
ファイル: PositionList.cs プロジェクト: heber/FreeOQ
		public ICollection Clone()
		{
			Position[] positionArray = new Position[this.positions.Values.Count];
			this.positions.Values.CopyTo(positionArray, 0);
			return positionArray;
		}
コード例 #17
0
ファイル: PositionList.cs プロジェクト: heber/FreeOQ
		public bool Contains(Position position)
		{
			return this.positions.ContainsValue(position);
		}
コード例 #18
0
		public virtual void OnPositionClosed(Position position)
		{
		}
コード例 #19
0
ファイル: ATSStrategy.cs プロジェクト: heber/FreeOQ
		protected override void OnPositionClosed(Position position)
		{
			Instrument instrument = position.Instrument;
			foreach (ATSStop atsStop in new ArrayList((ICollection) this.activeStops[instrument]))
			{
				if (atsStop.Type == StopType.Time && atsStop.Status == StopStatus.Active || atsStop.Connected)
					atsStop.OnPositionClosed(position);
			}
			this.klBiFcxZsD.OnPositionClosed(position);
			this.csNiLdTRqH[instrument].OnPositionClosed();
		}
コード例 #20
0
ファイル: Strategy.cs プロジェクト: heber/FreeOQ
 protected override void OnPositionClosed(Position position)
 {
   foreach (Stop stop in new ArrayList((ICollection) this.activeStops[position.Instrument]))
   {
     if (stop.Type == StopType.Time && stop.Status == StopStatus.Active || stop.Connected)
       stop.xbx6LKbgmx(position);
   }
   this.A6MpF2380O.OnPositionClosed(position);
   this.HeHpDewVKD.OnPositionClosed(position);
   this.ayRpJCTRPY.OnPositionClosed(position);
   Instrument instrument = position.Instrument;
   this.exits[instrument].OnPositionClosed();
   this.entries[instrument].OnPositionClosed();
   this.moneyManagers[instrument].OnPositionClosed();
   this.riskManagers[instrument].OnPositionClosed();
 }
コード例 #21
0
ファイル: PositionList.cs プロジェクト: heber/FreeOQ
		public void Add(Position position)
		{
			if (this.positions.Contains(position.Name))
                throw new ApplicationException("Already Added. {0}" + position.Name);
			this.positions.Add(position.Name, position);
		}
コード例 #22
0
ファイル: Strategy.cs プロジェクト: heber/FreeOQ
 protected override void OnPortfolioValueChanged(Position position)
 {
   this.MetaStrategy.MetaRiskManager.OnStrategyPortfolioValueChanged(this);
   if (!this.isActive)
     return;
   this.A6MpF2380O.OnPortfolioValueChanged(position);
   this.HeHpDewVKD.OnPortfolioValueChanged(position);
   this.ayRpJCTRPY.OnPortfolioValueChanged(position);
   Instrument instrument = position.Instrument;
   this.exits[instrument].OnPositionValueChanged();
   this.entries[instrument].OnPositionValueChanged();
   this.moneyManagers[instrument].OnPositionValueChanged();
   this.riskManagers[instrument].OnPositionValueChanged();
 }
コード例 #23
0
ファイル: Portfolio.cs プロジェクト: smther/FreeOQ
        public void Add(Transaction transaction)
        {
            lock (this.dataLock)
            {
                bool posOpened = false;
                bool posChanged = true;
                bool posClosed = false;
                double local_4 = 0.0;
                double local_5 = 0.0;
                double local_6 = 0.0;

                Position position = this.positions[transaction.Instrument];
                if (position == null)
                {
                    position = new Position(this, transaction);
                    this.positions.Add(position);
                    if (this.monitored)
                        this.WatchPosition(position);
                    if (transaction.Margin != 0.0)
                    {
                        local_4 = transaction.Margin;
                        local_6 = 0.0;
                        local_5 = transaction.Debt;
                        position.Margin = transaction.Margin;
                        position.Debt = transaction.Debt;
                    }
                    posOpened = true;
                }
                else
                {
                    if (transaction.Margin != 0.0)
                    {
                        if (position.Side == PositionSide.Long && transaction.Side == Side.Buy || position.Side == PositionSide.Short && (transaction.Side == Side.Sell || transaction.Side == Side.SellShort))
                        {
                            local_4 = transaction.Margin;
                            local_6 = 0.0;
                            local_5 = transaction.Debt;
                            position.Margin += transaction.Margin;
                            position.Debt += transaction.Debt;
                        }
                        if (position.Side == PositionSide.Long && (transaction.Side == Side.Sell || transaction.Side == Side.SellShort) || position.Side == PositionSide.Short && transaction.Side == Side.Buy)
                        {
                            if (position.Qty == transaction.Qty)
                            {
                                double temp_152 = position.Margin;
                                local_4 = 0.0;
                                local_6 = position.Debt;
                                local_5 = 0.0;
                                position.Margin = 0.0;
                                position.Debt = 0.0;
                            }
                            else if (position.Qty > transaction.Qty)
                            {
                                double temp_131 = transaction.Margin;
                                local_4 = 0.0;
                                local_6 = position.Debt * transaction.Qty / position.Qty;
                                local_5 = 0.0;
                                position.Margin -= transaction.Margin;
                                position.Debt -= local_6;
                            }
                            else
                            {
                                double local_7 = transaction.Qty - position.Qty;
                                double local_8 = local_7 * transaction.Price;
                                if (transaction.Instrument.Factor != 0.0)
                                    local_8 *= transaction.Instrument.Factor;
                                double temp_110 = position.Margin;
                                double local_4_1 = transaction.Instrument.Margin * local_7;
                                local_6 = position.Debt;
                                local_5 = local_8 - local_4_1;
                                position.Margin = local_4_1;
                                position.Debt = local_5;
                            }
                        }
                    }
                    position.Add(transaction);
                    if (position.Qty == 0.0)
                    {
                        this.positions.Remove(position);
                        if (this.monitored)
                            this.UnWatchPosition(position);
                        posClosed = true;
                    }
                }
                this.transactions.Add(transaction);
                if (!this.Mk5dJuOhmC && this.persistent)
                    PortfolioManager.Add(this, transaction);
                this.EmitTransactionAdded(transaction);
                if (!this.Mk5dJuOhmC)
                    this.account.Add(transaction.CashFlow + local_5 - local_6, transaction.Currency, transaction.DateTime, transaction.Text);
                if (posOpened)
                    this.EmitPositionOpened(position);
                if (posChanged)
                    this.EmitPositionChanged(position);
                if (posClosed)
                    this.EmitPositionClosed(position);
                this.EmitCompositionChanged();
                if (this.Mk5dJuOhmC)
                    return;
                this.EmitValueChanged(position);
            }
        }
コード例 #24
0
ファイル: ATSStrategy.cs プロジェクト: heber/FreeOQ
		protected override void OnPositionOpened(Position position)
		{
			this.klBiFcxZsD.OnPositionOpened(position);
			this.csNiLdTRqH[position.Instrument].OnPositionOpened();
		}
コード例 #25
0
ファイル: Portfolio.cs プロジェクト: smther/FreeOQ
 private void UnWatchPosition(Position position)
 {
     position.Instrument.NewBar -= new BarEventHandler(this.OnNewBar);
     position.Instrument.NewTrade -= new TradeEventHandler(this.OnNewTrade);
 }
コード例 #26
0
ファイル: ATSStrategy.cs プロジェクト: heber/FreeOQ
		protected override void OnPortfolioValueChanged(Position position)
		{
			this.klBiFcxZsD.OnPositionValueChanged(position);
			this.csNiLdTRqH[position.Instrument].OnPositionValueChanged();
		}
コード例 #27
0
ファイル: Portfolio.cs プロジェクト: smther/FreeOQ
 private void EmitPositionClosed(Position position)
 {
     if (this.PositionClosed != null)
         this.PositionClosed(this, new PositionEventArgs(position));
 }
コード例 #28
0
ファイル: StrategyBase.cs プロジェクト: heber/FreeOQ
 protected virtual void OnPortfolioValueChanged(Position position)
 {
 }
コード例 #29
0
ファイル: Portfolio.cs プロジェクト: smther/FreeOQ
 private void EmitValueChanged(Position position)
 {
     if (this.ValueChanged != null)
         this.ValueChanged(this, new PositionEventArgs(position));
 }
コード例 #30
0
ファイル: StrategyBase.cs プロジェクト: heber/FreeOQ
 protected virtual void OnPositionClosed(Position position)
 {
 }
コード例 #31
0
ファイル: RoundTrip.cs プロジェクト: heber/FreeOQ
    public RoundTrip(Position Position, Instrument Instrument, PositionSide TradePosition, double Amount, double EntryPrice, double ExitPrice, DateTime EntryDateTime, DateTime ExitDateTime)
			:base() 
		{
 
      this.position = Position;
      this.instrument = Instrument;
      this.tradePosition = TradePosition;
      this.amount = Amount;
      this.entryPrice = EntryPrice;
      this.exitPrice = ExitPrice;
      this.entryDateTime = EntryDateTime;
      this.exitDateTime = ExitDateTime;
      this.entryCost = 0.0;
      this.exitCost = 0.0;
      this.entryValue = EntryPrice * Amount;
      this.exitValue = ExitPrice * Amount;
      this.roundTripLowPrice = EntryPrice;
      this.roundTripHighPrice = EntryPrice;
      this.status = RoundTripStatus.Closed;
    }