public override bool ExitSuccessfull(MoveGenericActiveOrder order, DateTime now, double open, double close, double high, double low) { if (low <= _exitAt) return true; return false; }
public override bool ExitFailed(MoveGenericActiveOrder order, DateTime now, double open, double close, double high, double low) { if (high >= _exitAt) return true; return false; }
public override bool ExitFailed(MoveGenericActiveOrder order, DateTime now, double open, double close, double high, double low) { if (low <= _exitAt) { return(true); } return(false); }
public override bool ExitSuccessfull(MoveGenericActiveOrder order, DateTime now, double open, double close, double high, double low) { if (high >= _exitAt) { return(true); } return(false); }
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); }
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); }
public override bool SettlesSuccessFull(MoveGenericActiveOrder order, double close) { throw new NotImplementedException(); }
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); } }
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); }
public abstract bool ExitSuccessfull(MoveGenericActiveOrder order, DateTime now, double open, double close, double high, double low);
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); } }
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; }
public override bool SettlesSuccessFull(MoveGenericActiveOrder order, double close) { return(close < _settlesAt); }
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); }
private string GetStratName(MoveGenericActiveOrder order) { return(order.ExitStrategy.GetType().Name); }
public override bool SettlesSuccessFull(MoveGenericActiveOrder order, double close) { return close < _settlesAt; }
private string GetStratName(MoveGenericActiveOrder order) { return order.ExitStrategy.GetType().Name; }
public abstract bool SettlesSuccessFull(MoveGenericActiveOrder order, double close);