Ejemplo n.º 1
0
        public override bool ExitSuccessfull(MoveGenericActiveOrder order, DateTime now, double open, double close, double high, double low)
        {
            if (low <= _exitAt)
                return true;

            return false;

        }
Ejemplo n.º 2
0
        public override bool ExitFailed(MoveGenericActiveOrder order, DateTime now, double open, double close,
            double high, double low)
        {
            if (high >= _exitAt)
                return true;

            return false;
        }
Ejemplo n.º 3
0
        public override bool ExitFailed(MoveGenericActiveOrder order, DateTime now, double open, double close, double high, double low)
        {
            if (low <= _exitAt)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 4
0
        public override bool ExitSuccessfull(MoveGenericActiveOrder order, DateTime now, double open, double close,
                                             double high, double low)
        {
            if (high >= _exitAt)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
        public void AddOrder(MoveGenericActiveOrder order)
        {
            var stratName = GetStratName(order);

            if (!_strats.ContainsKey(stratName))
            {
                _strats.Add(stratName, new StratStats());
            }

            _strats[stratName].Count++;

            _activerOrders.Add(order.Id, order);
        }
Ejemplo n.º 6
0
        public void AddOrder(MoveGenericActiveOrder order)
        {
            var stratName = GetStratName(order);

            if (!_strats.ContainsKey(stratName))
            {
                _strats.Add(stratName, new StratStats());
            }

            _strats[stratName].Count++;

            _activerOrders.Add(order.Id, order);
        }
Ejemplo n.º 7
0
        private void SendNotification(MoveGenericActiveOrder order)
        {
            var instrumentName = Instrument.ToString().Replace("Default", "").Replace(" ", "").Replace("$", "");

            var mailSubject = string.Format("KC-SIGNAL-{0}:  {1} @  {2}", instrumentName,
                                            (order.IsLong) ? "BULL" : "BEAR",
                                            Close[0]);
            var mailContentTemplate = @"A {0} signal was observed in '{1}' at {2} at a closing price of {3}.
{4}
Strike Width: {5}
Strategy: {6}
";
            var mailContent         = string.Format(mailContentTemplate, (order.IsLong) ? "BULL" : "BEAR", Instrument, Time,
                                                    Close[0], order.ExitStrategy.ExitStategyDescr, order.StrikeWidth, order.ExitStrategy.GetType().Name);

            if (Historical)
            {
                return;
            }
            SendMail("*****@*****.**", "*****@*****.**", mailSubject, mailContent);
        }
Ejemplo n.º 8
0
 public override bool SettlesSuccessFull(MoveGenericActiveOrder order, double close)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
		protected override void OnBarUpdate()
		{
			try
			{
				var now = DateTime.Parse(Time.ToString());
				_activeOrderTracker.HandleCurrentOrders(now, Open[0], Close[0], High[0], Low[0]);

				
				Print(_activeOrderTracker.GetStatusReport());

			
				



				var isBull = IsBull();
				var isBear = IsBear();
				var volScore = GetVoltilityScore();


				if (isBull && volScore == Volatility.High && (new int[] { 10, 20, 30 }).Contains(now.Minute) && IsBullOtmReady())
				{
			 
					var expiryTime = now.AddHours(1);

					var
						order = new MoveGenericActiveOrder
						{
							Id = Guid.NewGuid(),
							Time = now,
							ExpiryHour = expiryTime.Hour,
							ExpiryDay = expiryTime.Day,
							EnteredAt = Close[0],
							StrikeWidth = _strikeWidth
						};

					order.IsLong = true;
					order.SuccessFullySettlesAt = Close[0] + (Math.Abs(_strikeWidth*.25));
					order.ExitStrategy = new BullishOtmExitStrategy(Close[0] + (Math.Abs(_strikeWidth) * 1.5), order.SuccessFullySettlesAt);
					SendNotification(order);
					_activeOrderTracker.AddOrder(order);
				}


				else if (isBear && volScore == Volatility.High && (new int[] { 10, 20, 30 }).Contains(now.Minute))
				{
					var expiryTime = now.AddHours(1);

					var
						order = new MoveGenericActiveOrder
						{
							Id = Guid.NewGuid(),
							Time = now,
							ExpiryHour = expiryTime.Hour,
							ExpiryDay = expiryTime.Day,
							EnteredAt = Close[0],
							StrikeWidth = _strikeWidth
						};


					order.IsLong = false;
					order.SuccessFullySettlesAt = Close[0] - (Math.Abs(_strikeWidth*.25));
					order.ExitStrategy = new BearishOtmExitStrategy(Close[0] - (Math.Abs(_strikeWidth) * 1.5), order.SuccessFullySettlesAt);
					SendNotification(order);
					_activeOrderTracker.AddOrder(order);
				}

				
				else if  (false && isBull && volScore == Volatility.Low && (new int[]{40,50}).Contains(now.Minute))
				{
					var expiryTime = now;

					var
						order = new MoveGenericActiveOrder
						{
							Id = Guid.NewGuid(),
							Time = now,
							ExpiryHour = expiryTime.Hour,
							ExpiryDay = expiryTime.Day,
							EnteredAt = Close[0],
							StrikeWidth = _strikeWidth,
							SuccessFullySettlesAt = Close[0] - (Math.Abs(_strikeWidth * .25)),
							IsLong = true,
							ExitStrategy = new BullishItmExitStrategy(Close[0] - (Math.Abs(_strikeWidth * 5)))
						};

					SendNotification(order);


					_activeOrderTracker.AddOrder(order);
				}
				else if (false && isBear && volScore == Volatility.Low && (new int[] { 50 }).Contains(now.Minute))
				{
					var expiryTime = now;

					var
						order = new MoveGenericActiveOrder
						{
							Id = Guid.NewGuid(),
							Time = now,
							ExpiryHour = expiryTime.Hour,
							ExpiryDay = expiryTime.Day,
							EnteredAt = Close[0],
							StrikeWidth = _strikeWidth,
							SuccessFullySettlesAt = Close[0] + (Math.Abs(_strikeWidth * .25)),
							IsLong = false,
							ExitStrategy = new BearishItmExitStrategy(Close[0] + (Math.Abs(_strikeWidth * 5)))
						};

					SendNotification(order);


					_activeOrderTracker.AddOrder(order);
				}
				 
			}
			catch (Exception e)
			{
				Print("error found:" + e.Message + " " + e.Source + " " + e.StackTrace);
				//Log("error found:" + e.Message + " " + e.Source + " " + e.StackTrace, LogLevel.Error);
			}
		}
Ejemplo n.º 10
0
		private void SendNotification(MoveGenericActiveOrder order)
		{
			var instrumentName = Instrument.ToString().Replace("Default", "").Replace(" ", "").Replace("$", "");

			var mailSubject = string.Format("KC-SIGNAL-{0}:  {1} @  {2}", instrumentName,
				(order.IsLong) ? "BULL" : "BEAR",
				Close[0]);
			var mailContentTemplate = @"A {0} signal was observed in '{1}' at {2} at a closing price of {3}.
{4}
Strike Width: {5}
Strategy: {6}
";
			var mailContent = string.Format(mailContentTemplate, (order.IsLong) ? "BULL" : "BEAR", Instrument, Time,
				Close[0], order.ExitStrategy.ExitStategyDescr, order.StrikeWidth, order.ExitStrategy.GetType().Name);

			if (Historical)
				return;
			SendMail("*****@*****.**", "*****@*****.**", mailSubject, mailContent);
		}
Ejemplo n.º 11
0
 public abstract bool ExitSuccessfull(MoveGenericActiveOrder order, DateTime now, double open, double close,
     double high, double low);
Ejemplo n.º 12
0
        protected override void OnBarUpdate()
        {
            try
            {
                var now = DateTime.Parse(Time.ToString());
                _activeOrderTracker.HandleCurrentOrders(now, Open[0], Close[0], High[0], Low[0]);


                Print(_activeOrderTracker.GetStatusReport());



                var isBull   = IsBull();
                var isBear   = IsBear();
                var volScore = GetVoltilityScore();


                if (isBull && volScore == Volatility.High && (new int[] { 10, 20, 30 }).Contains(now.Minute) && IsBullOtmReady())
                {
                    var expiryTime = now.AddHours(1);

                    var
                        order = new MoveGenericActiveOrder
                    {
                        Id          = Guid.NewGuid(),
                        Time        = now,
                        ExpiryHour  = expiryTime.Hour,
                        ExpiryDay   = expiryTime.Day,
                        EnteredAt   = Close[0],
                        StrikeWidth = _strikeWidth
                    };

                    order.IsLong = true;
                    order.SuccessFullySettlesAt = Close[0] + (Math.Abs(_strikeWidth * .25));
                    order.ExitStrategy          = new BullishOtmExitStrategy(Close[0] + (Math.Abs(_strikeWidth) * 1.5), order.SuccessFullySettlesAt);
                    SendNotification(order);
                    _activeOrderTracker.AddOrder(order);
                }


                else if (isBear && volScore == Volatility.High && (new int[] { 10, 20, 30 }).Contains(now.Minute))
                {
                    var expiryTime = now.AddHours(1);

                    var
                        order = new MoveGenericActiveOrder
                    {
                        Id          = Guid.NewGuid(),
                        Time        = now,
                        ExpiryHour  = expiryTime.Hour,
                        ExpiryDay   = expiryTime.Day,
                        EnteredAt   = Close[0],
                        StrikeWidth = _strikeWidth
                    };


                    order.IsLong = false;
                    order.SuccessFullySettlesAt = Close[0] - (Math.Abs(_strikeWidth * .25));
                    order.ExitStrategy          = new BearishOtmExitStrategy(Close[0] - (Math.Abs(_strikeWidth) * 1.5), order.SuccessFullySettlesAt);
                    SendNotification(order);
                    _activeOrderTracker.AddOrder(order);
                }


                else if (false && isBull && volScore == Volatility.Low && (new int[] { 40, 50 }).Contains(now.Minute))
                {
                    var expiryTime = now;

                    var
                        order = new MoveGenericActiveOrder
                    {
                        Id                    = Guid.NewGuid(),
                        Time                  = now,
                        ExpiryHour            = expiryTime.Hour,
                        ExpiryDay             = expiryTime.Day,
                        EnteredAt             = Close[0],
                        StrikeWidth           = _strikeWidth,
                        SuccessFullySettlesAt = Close[0] - (Math.Abs(_strikeWidth * .25)),
                        IsLong                = true,
                        ExitStrategy          = new BullishItmExitStrategy(Close[0] - (Math.Abs(_strikeWidth * 5)))
                    };

                    SendNotification(order);


                    _activeOrderTracker.AddOrder(order);
                }
                else if (false && isBear && volScore == Volatility.Low && (new int[] { 50 }).Contains(now.Minute))
                {
                    var expiryTime = now;

                    var
                        order = new MoveGenericActiveOrder
                    {
                        Id                    = Guid.NewGuid(),
                        Time                  = now,
                        ExpiryHour            = expiryTime.Hour,
                        ExpiryDay             = expiryTime.Day,
                        EnteredAt             = Close[0],
                        StrikeWidth           = _strikeWidth,
                        SuccessFullySettlesAt = Close[0] + (Math.Abs(_strikeWidth * .25)),
                        IsLong                = false,
                        ExitStrategy          = new BearishItmExitStrategy(Close[0] + (Math.Abs(_strikeWidth * 5)))
                    };

                    SendNotification(order);


                    _activeOrderTracker.AddOrder(order);
                }
            }
            catch (Exception e)
            {
                Print("error found:" + e.Message + " " + e.Source + " " + e.StackTrace);
                //Log("error found:" + e.Message + " " + e.Source + " " + e.StackTrace, LogLevel.Error);
            }
        }
Ejemplo n.º 13
0
 public override bool ExitFailed(MoveGenericActiveOrder order, DateTime now, double open, double close, double high, double low)
 {
     //always go to settlement if we have not exited.
     return false;
 }
Ejemplo n.º 14
0
 public override bool SettlesSuccessFull(MoveGenericActiveOrder order, double close)
 {
     return(close < _settlesAt);
 }
Ejemplo n.º 15
0
 public override bool ExitFailed(MoveGenericActiveOrder order, DateTime now, double open, double close, double high, double low)
 {
     //always go to settlement if we have not exited.
     return(false);
 }
Ejemplo n.º 16
0
 private string GetStratName(MoveGenericActiveOrder order)
 {
     return(order.ExitStrategy.GetType().Name);
 }
Ejemplo n.º 17
0
 public override bool SettlesSuccessFull(MoveGenericActiveOrder order, double close)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 18
0
 public override bool SettlesSuccessFull(MoveGenericActiveOrder order, double close)
 {
     return close < _settlesAt;
 }
Ejemplo n.º 19
0
 private string GetStratName(MoveGenericActiveOrder order)
 {
     return order.ExitStrategy.GetType().Name;
 }
Ejemplo n.º 20
0
 public abstract bool SettlesSuccessFull(MoveGenericActiveOrder order, double close);