public DoorBusinessObject(int id, string name, LockStatus lockStatus, OpenStatus openStatus) { Id = id; Name = name; LockStatus = lockStatus; OpenStatus = openStatus; UpdateActionList(); }
/// <summary> /// Returns true if BankingAccount instances are equal /// </summary> /// <param name="other">Instance of BankingAccount to be compared</param> /// <returns>Boolean</returns> public bool Equals(BankingAccount other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( AccountId == other.AccountId || AccountId != null && AccountId.Equals(other.AccountId) ) && ( DisplayName == other.DisplayName || DisplayName != null && DisplayName.Equals(other.DisplayName) ) && ( Nickname == other.Nickname || Nickname != null && Nickname.Equals(other.Nickname) ) && ( MaskedNumber == other.MaskedNumber || MaskedNumber != null && MaskedNumber.Equals(other.MaskedNumber) ) && ( OpenStatus == other.OpenStatus || OpenStatus != null && OpenStatus.Equals(other.OpenStatus) ) && ( IsOwned == other.IsOwned || IsOwned != null && IsOwned.Equals(other.IsOwned) ) && ( ProductCategory == other.ProductCategory || ProductCategory != null && ProductCategory.Equals(other.ProductCategory) ) && ( ProductName == other.ProductName || ProductName != null && ProductName.Equals(other.ProductName) )); }
void AfterCloseLetter() { m_CanAcceptInput = !IsFirstOrLastIndex(); m_CurrentPosition = m_ClosedPosition; transform.position = m_ClosedPosition; m_OpenStatus = OpenStatus.Closed; EventManager.Instance.Notify(GameEvents.Letter.Close, m_CurrentIndex); RunIfFirstOrLastLetter(); }
void AfterOpenLetter() { m_CurrentPosition = m_OpenedPosition; transform.position = m_OpenedPosition; m_OpenStatus = OpenStatus.Opened; m_CanAcceptInput = !IsFirstOrLastIndex(); if (!m_CanAcceptInput) { StartCoroutine(DelayToAcceptInput(m_FirstLastInputDelaySeconds)); } }
public static void OpenResponse(OpenStatus status) { ModelHelper.Log(LogType.TestInfo, "Open {0}.", Open == null ? "does not exist" : "exists"); if (null == Open) { Condition.IsTrue(status == OpenStatus.OpenClosed); } else { Condition.IsTrue(status == OpenStatus.OpenNotClosed); } }
IEnumerator CloseLetter() { EventManager.Instance.Notify(GameEvents.Audio.Play, "SFX_PaperOut"); m_OpenStatus = OpenStatus.Closing; while (Vector3.Distance(m_CurrentPosition, m_ClosedPosition) > 0.01f) { m_CurrentPosition = Vector3.Lerp(m_CurrentPosition, m_ClosedPosition, m_OpenCloseLerpPercentage); transform.position = m_CurrentPosition; yield return(new WaitForEndOfFrame()); } AfterCloseLetter(); }
public static void InsertData(OpenStatus openStatus, string sIP, string eIP, bool IsSystemSet) { using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn)) { string sql = $"IF Not EXISTS (SELECT 1 FROM IntraIPlimit WHERE IP_Begin=@IP_Begin and IP_End=@IP_End ) " + " INSERT INTO IntraIPlimit(OpenStatus, IP_Begin, IP_End, IP_BeginNum, IP_EndNum , Creator , CreateTime, IsSystemSet) VALUES(@OpenStatus, @IP_Begin, @IP_End, @IP_BeginNum, @IP_EndNum , @Creator , @CreateTime, @IsSystemSet)"; string IP_BeginNum = WorkLib.GetItem.GetIPNum(sIP).ToString(); string IP_EndNum = "0"; if (!string.IsNullOrEmpty(eIP)) { IP_EndNum = WorkLib.GetItem.GetIPNum(eIP).ToString(); } long Creator = MemberDAO.SysCurrent.Id; DateTime CreateTime = DateTime.Now; conn.Execute(sql, new { OpenStatus = (int)openStatus, IP_Begin = sIP, IP_End = eIP, IP_BeginNum = IP_BeginNum, IP_EndNum = IP_EndNum, Creator = Creator, CreateTime = CreateTime, IsSystemSet = IsSystemSet }); } }
public TradePoints(OpenPoint openpoint, double stoplossPercent) { this.tradeGuid = Guid.NewGuid(); this.enterPoint = openpoint; if (this.enterPoint.OpenType == OpenType.Buy) { this.stopLossPrice = Math.Round(this.enterPoint.OpenPrice * (1 - stoplossPercent / 100), 2, MidpointRounding.AwayFromZero); } else { this.stopLossPrice = Math.Round(this.enterPoint.OpenPrice * (1 + stoplossPercent / 100), 2, MidpointRounding.AwayFromZero); } //this.closed = false; this.status = OpenStatus.Open; //this.lastRaisePrice = 0; this.returnToLeave = false; this.leavePoint = 0; this.preHigh = 0; this.returned = false; }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (AccountId != null) { hashCode = hashCode * 59 + AccountId.GetHashCode(); } if (DisplayName != null) { hashCode = hashCode * 59 + DisplayName.GetHashCode(); } if (Nickname != null) { hashCode = hashCode * 59 + Nickname.GetHashCode(); } if (MaskedNumber != null) { hashCode = hashCode * 59 + MaskedNumber.GetHashCode(); } if (OpenStatus != null) { hashCode = hashCode * 59 + OpenStatus.GetHashCode(); } if (IsOwned != null) { hashCode = hashCode * 59 + IsOwned.GetHashCode(); } if (ProductCategory != null) { hashCode = hashCode * 59 + ProductCategory.GetHashCode(); } if (ProductName != null) { hashCode = hashCode * 59 + ProductName.GetHashCode(); } return(hashCode); } }
void SetIndex(int index) { if (index < m_Height.Length) { m_CurrentIndex = index; m_OpenedPosition.y = m_Height[m_CurrentIndex]; m_ClosedPosition.y = m_Height[m_CurrentIndex]; m_ClosedPosition.z = m_OriginalZ; m_CurrentPosition = m_ClosedPosition; transform.position = m_ClosedPosition; m_OpenStatus = OpenStatus.Closed; m_Material.SetInt(m_MaterialProperty, m_CurrentIndex); } else { //gameObject.SetActive(false); SetColliderAndMesh(false); } }
private bool DoesMarketMatchRequestedOpenStatus(IMarket market, OpenStatus openStatus) { if (openStatus == OpenStatus.OpenOrClosed) { return(true); } var dayOfWeekInQuestion = DateTime.Now.DayOfWeek; var dateInQuestion = DateTime.Now.Day; if (openStatus == OpenStatus.OpenTomorrow) { dayOfWeekInQuestion++; dateInQuestion++; } var isMarketEverOpenOnDayOfWeek = market.OpeningTimes.TryGetValue(dayOfWeekInQuestion, out var openingTimes); if (!isMarketEverOpenOnDayOfWeek) { return(false); } if (openingTimes.RepeatRule.RepeatType == RepeatType.Monthly) { var currentWeekOfMonth = ((dateInQuestion) / 7) + 1; if (currentWeekOfMonth != openingTimes.RepeatRule.WeekOfMonth) { return(false); } } if (openStatus == OpenStatus.OpenToday || openStatus == OpenStatus.OpenTomorrow) { return(openingTimes.OpenTime < openingTimes.CloseTime); } return(openingTimes.OpenTime.Hours > DateTime.Now.Hour && openingTimes.CloseTime.Hours < DateTime.Now.Hour); }
public override void Notify(Guid tradeGuid, OpenStatus status, double dealQty = 0, double dealPrice = 0, string weituobianhao = "", string pendWeituobianhao = "") { lock (lock_tps) { for (int i = 0; i < tps.ToArray().Count(); i++) { var t = tps[i]; if (t.TradeGuid == tradeGuid) { if (status == OpenStatus.Opened) { t.EnterPoint.OpenPrice = dealPrice; decimal realDealQty = (decimal)dealQty + (decimal)t.EnterPoint.PartDealQty - (decimal)t.EnterPoint.DealQty; holdHands += realDealQty; t.Status = OpenStatus.Opened; frozenBuyHands -= realDealQty; t.EnterPoint.DealQty = (double)((decimal)dealQty + (decimal)t.EnterPoint.PartDealQty); RaiseMessage(new PolicyMessageEventArgs("策略已接受开仓通知")); if (t.EnterPoint.SecInfo.Key == eosbtcsi.Key) { double huanbiqty = Math.Floor(dealPrice * (double)realDealQty * SecInfo.JingDu) / SecInfo.JingDu; double eosqty = Math.Floor((double)realDealQty * eosusdtsi.JingDu) / eosusdtsi.JingDu; if (t.EnterPoint.OpenType == OpenType.Buy) { if ((double)realDealQty > eosusdtsi.MinQty) { OpenArgs oa = new OpenArgs( eosusdt.Bid, eosqty, OpenType.Sell, eosusdtsi, eosusdt, t.TpRemark); OpenDelete od = new OpenDelete(OpenThread); od.BeginInvoke(oa, null, null); EosUsdtStatus = false; } if (huanbiqty >= SecInfo.MinQty) { OpenArgs oa2 = new OpenArgs( currentTick.Ask, huanbiqty, OpenType.Buy, SecInfo, currentTick, t.TpRemark); OpenDelete od2 = new OpenDelete(OpenThread); od2.BeginInvoke(oa2, null, null); BtcUsdtStatus = false; } } else { if ((double)realDealQty > eosusdtsi.MinQty) { OpenArgs oa = new OpenArgs( eosusdt.Ask, eosqty, OpenType.Buy, eosusdtsi, eosusdt, t.TpRemark); OpenDelete od = new OpenDelete(OpenThread); od.BeginInvoke(oa, null, null); EosUsdtStatus = false; } if (huanbiqty >= SecInfo.MinQty) { OpenArgs oa2 = new OpenArgs( currentTick.Bid, huanbiqty, OpenType.Sell, SecInfo, currentTick, t.TpRemark); OpenDelete od2 = new OpenDelete(OpenThread); od2.BeginInvoke(oa2, null, null); BtcUsdtStatus = false; } } EosBtcStatus = true; } else if (t.EnterPoint.SecInfo.Key == eosusdtsi.Key) { EosUsdtStatus = true; } else if (t.EnterPoint.SecInfo.Key == SecInfo.Key) { BtcUsdtStatus = true; } } else if (status == OpenStatus.Open) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受开仓下单通知", this.policyName))); } else if (status == OpenStatus.Close) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受平仓下单通知", this.policyName))); } else if (status == OpenStatus.Closed) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受平仓通知", this.policyName))); } else if (status == OpenStatus.OpenPending) { t.EnterPoint.PartDealQty = t.EnterPoint.DealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略HoldHands:{1}", this.policyName, holdHands))); } else if (status == OpenStatus.ClosePending) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略HoldHands:{1}", this.policyName, holdHands))); } else if (status == OpenStatus.Failed) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受失败通知", this.policyName))); } else if (status == OpenStatus.PartOpend) { if (dealQty > (t.EnterPoint.DealQty - t.EnterPoint.PartDealQty)) { decimal realDealQty = (decimal)dealQty + (decimal)t.EnterPoint.PartDealQty - (decimal)t.EnterPoint.DealQty; holdHands += realDealQty; frozenBuyHands -= realDealQty; t.EnterPoint.DealQty = dealQty + t.EnterPoint.PartDealQty; if (t.EnterPoint.SecInfo.Key == eosbtcsi.Key) { double huanbiqty = Math.Floor(dealPrice * (double)realDealQty * SecInfo.JingDu) / SecInfo.JingDu; double eosqty = Math.Floor((double)realDealQty * eosusdtsi.JingDu) / eosusdtsi.JingDu; if (t.EnterPoint.OpenType == OpenType.Buy) { if ((double)realDealQty > eosusdtsi.MinQty) { OpenArgs oa = new OpenArgs( eosusdt.Bid, eosqty, OpenType.Sell, eosusdtsi, eosusdt, t.TpRemark); OpenDelete od = new OpenDelete(OpenThread); od.BeginInvoke(oa, null, null); EosUsdtStatus = false; } if (huanbiqty >= SecInfo.MinQty) { OpenArgs oa2 = new OpenArgs( currentTick.Ask, huanbiqty, OpenType.Buy, SecInfo, currentTick, t.TpRemark); OpenDelete od2 = new OpenDelete(OpenThread); od2.BeginInvoke(oa2, null, null); BtcUsdtStatus = false; } } else { if ((double)realDealQty > eosusdtsi.MinQty) { OpenArgs oa = new OpenArgs( eosusdt.Ask, eosqty, OpenType.Buy, eosusdtsi, eosusdt, t.TpRemark); OpenDelete od = new OpenDelete(OpenThread); od.BeginInvoke(oa, null, null); EosUsdtStatus = false; } if (huanbiqty >= SecInfo.MinQty) { OpenArgs oa2 = new OpenArgs( currentTick.Bid, huanbiqty, OpenType.Sell, SecInfo, currentTick, t.TpRemark); OpenDelete od2 = new OpenDelete(OpenThread); od2.BeginInvoke(oa2, null, null); BtcUsdtStatus = false; } } EosBtcStatus = true; } RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受部分入场成交通知,成交数量:{1}", this.policyName, dealQty))); } } else if (status == OpenStatus.PartClosed) { if (dealQty > (t.OutPoint.DealQty - t.OutPoint.PartDealQty)) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受部分出场成交通知,成交数量:{1}", this.policyName, dealQty))); decimal realDealQty = (decimal)dealQty + (decimal)t.OutPoint.PartDealQty - (decimal)t.OutPoint.DealQty; holdHands -= realDealQty; frozenSellHands -= realDealQty; t.OutPoint.DealQty = dealQty + t.OutPoint.PartDealQty; } } else if (status == OpenStatus.OpenCanceled) { if (t.EnterPoint.SecInfo.Key == eosbtcsi.Key) { EosBtcStatus = true; } RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受入场撤单通知", this.policyName))); } else if (status == OpenStatus.CloseCanceled) { frozenSellHands -= (decimal)dealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受出场撤单通知", this.policyName))); } else if (status == OpenStatus.OpenRest) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接收开仓剩余通知,数量:{1}", this.policyName, dealQty))); } else if (status == OpenStatus.CloseRest) { holdHands -= (decimal)dealQty; frozenSellHands -= (decimal)dealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接收平仓剩余通知,数量:{1}", this.policyName, dealQty))); } } } } }
public override void Notify(Guid tradeGuid, OpenStatus status, double dealQty = 0, double dealPrice = 0, string weituobianhao = "", string pendWeituobianhao = "") { for (int i = 0; i < tps.ToArray().Count(); i++) { var t = tps[i]; if (t.TradeGuid == tradeGuid && currentTick.IsReal) { if (status == OpenStatus.Opened) { t.EnterPoint.OpenPrice = dealPrice; decimal realDealQty = (decimal)dealQty + (decimal)t.EnterPoint.PartDealQty - (decimal)t.EnterPoint.DealQty; t.EnterPoint.DealQty = (double)((decimal)dealQty + (decimal)t.EnterPoint.PartDealQty); t.Status = OpenStatus.Opened; openComplete = true; openHands = 0; RaiseMessage(new PolicyMessageEventArgs("策略已接受开仓通知")); } else if (status == OpenStatus.Open) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受开仓下单通知", this.policyName))); } else if (status == OpenStatus.Close) { OpenPointWeiTuo opwt = new OpenPointWeiTuo(); opwt.Weituobianhao = weituobianhao; opwt.OpenQty = dealQty; t.OutPoint.OpenPointWeiTuo.Add(opwt); RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受平仓下单通知", this.policyName))); } else if (status == OpenStatus.Closed) { double RealTotalDeal = 0; bool find = false; for (int j = 0; j < t.OutPoint.OpenPointWeiTuo.Count; j++) { if (t.OutPoint.OpenPointWeiTuo[j].Weituobianhao == weituobianhao) { OpenPointWeiTuo opwt = t.OutPoint.OpenPointWeiTuo[j]; decimal realDealQty = (decimal)dealQty + (decimal)opwt.PartDealQty - (decimal)opwt.DealQty; t.OutPoint.OpenPointWeiTuo[j].DealQty = dealQty + opwt.PartDealQty; find = true; } RealTotalDeal += t.OutPoint.OpenPointWeiTuo[j].DealQty; } if (t.EnterPoint.DealQty == RealTotalDeal) { closeComplete = true; t.Finished = true; } RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受平仓通知-{1}-有单子:{2}", this.policyName, weituobianhao, find.ToString()))); } else if (status == OpenStatus.OpenPending) { t.EnterPoint.PartDealQty = t.EnterPoint.DealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略HoldHands:{1}", this.policyName, holdHands))); } else if (status == OpenStatus.ClosePending) { for (int j = 0; j < t.OutPoint.OpenPointWeiTuo.Count; j++) { if (t.OutPoint.OpenPointWeiTuo[j].Weituobianhao == weituobianhao) { t.OutPoint.OpenPointWeiTuo[j].PartDealQty = t.OutPoint.OpenPointWeiTuo[j].DealQty; t.OutPoint.OpenPointWeiTuo[j].Weituobianhao = pendWeituobianhao; } } RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略HoldHands:{1}", this.policyName, holdHands))); } else if (status == OpenStatus.Failed) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受失败通知", this.policyName))); } else if (status == OpenStatus.PartOpend) { if (dealQty > (t.EnterPoint.DealQty - t.EnterPoint.PartDealQty)) { decimal realDealQty = (decimal)dealQty + (decimal)t.EnterPoint.PartDealQty - (decimal)t.EnterPoint.DealQty; t.EnterPoint.DealQty = dealQty + t.EnterPoint.PartDealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受部分入场成交通知,成交数量:{1}", this.policyName, dealQty))); } } else if (status == OpenStatus.PartClosed) { for (int j = 0; j < t.OutPoint.OpenPointWeiTuo.Count; j++) { if (t.OutPoint.OpenPointWeiTuo[j].Weituobianhao == weituobianhao) { OpenPointWeiTuo opwt = t.OutPoint.OpenPointWeiTuo[j]; if (dealQty > (opwt.DealQty - opwt.PartDealQty)) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受部分出场成交通知,成交数量:{1}", this.policyName, dealQty))); decimal realDealQty = (decimal)dealQty + (decimal)opwt.PartDealQty - (decimal)opwt.DealQty; t.OutPoint.OpenPointWeiTuo[j].DealQty = dealQty + opwt.PartDealQty; } break; } } } else if (status == OpenStatus.OpenCanceled) { if (t.EnterPoint.DealQty == 0) { t.Finished = true; openSide = 0; openComplete = true; openHands = 0; } RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受入场撤单通知", this.policyName))); } else if (status == OpenStatus.CloseCanceled) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受出场撤单通知", this.policyName))); } } } }
//public abstract void Notify(Guid tradeGuid,OpenStatus status,int dealQty); public abstract void Notify(Guid tradeGuid, OpenStatus status, double dealQty = 0, double dealPrice = 0, string weituobianhao = "", string pendWeituobianhao = "");
public override void Notify(Guid tradeGuid, OpenStatus status, double dealQty = 0, double dealPrice = 0, string weituobianhao = "", string pendWeituobianhao = "") { for (int i = 0; i < tps.ToArray().Count(); i++) { var t = tps[i]; if (t.TradeGuid == tradeGuid) { if (status == OpenStatus.Opened) { decimal realDealQty = (decimal)dealQty + (decimal)t.EnterPoint.PartDealQty - (decimal)t.EnterPoint.DealQty; t.EnterPoint.DealQty = (double)((decimal)dealQty + (decimal)t.EnterPoint.PartDealQty); t.EnterPoint.DealPrice = (dealPrice + t.EnterPoint.OpenPrice) / t.EnterPoint.DealQty; holdHands += realDealQty; if (t.EnterPoint.OpenType == OpenType.KaiDuo) { long_position += (int)dealQty; } else if (t.EnterPoint.OpenType == OpenType.KaiKong) { short_position += (int)dealQty; } if (long_position == (int)parameter.qty || short_position == (int)parameter.qty) { open_complete = 0; } t.Status = OpenStatus.Opened; frozenOpenHands -= realDealQty; RaiseMessage(new PolicyMessageEventArgs("策略已接受开仓通知")); } else if (status == OpenStatus.Open) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受开仓下单通知", this.policyName))); } else if (status == OpenStatus.Close) { OpenPointWeiTuo opwt = new OpenPointWeiTuo(); opwt.Weituobianhao = weituobianhao; opwt.OpenQty = dealQty; t.OutPoint.OpenPointWeiTuo.Add(opwt); RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受平仓下单通知", this.policyName))); } else if (status == OpenStatus.Closed) { double RealTotalDeal = 0; bool find = false; for (int j = 0; j < t.OutPoint.OpenPointWeiTuo.Count; j++) { if (t.OutPoint.OpenPointWeiTuo[j].Weituobianhao == weituobianhao) { OpenPointWeiTuo opwt = t.OutPoint.OpenPointWeiTuo[j]; decimal realDealQty = (decimal)dealQty + (decimal)opwt.PartDealQty - (decimal)opwt.DealQty; frozenCloseHands -= realDealQty; holdHands -= realDealQty; t.OutPoint.OpenPointWeiTuo[j].DealQty = dealQty + opwt.PartDealQty; find = true; } RealTotalDeal += t.OutPoint.OpenPointWeiTuo[j].DealQty; } if (t.OutPoint.OpenType == OpenType.PingDuo) { long_position -= (int)dealQty; } else if (t.OutPoint.OpenType == OpenType.PingKong) { short_position -= (int)dealQty; } if (long_position == 0 || short_position == 0) { close_complete = 0; } if (t.EnterPoint.DealQty == RealTotalDeal) { t.Finished = true; } RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受平仓通知-{1}-有单子:{2}", this.policyName, weituobianhao, find.ToString()))); } else if (status == OpenStatus.OpenPending) { t.EnterPoint.PartDealQty = t.EnterPoint.DealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接收入场追单通知-HoldHands:{1}", this.policyName, holdHands))); } else if (status == OpenStatus.ClosePending) { OpenPointWeiTuo opwt = new OpenPointWeiTuo(); opwt.Weituobianhao = pendWeituobianhao; opwt.OpenQty = dealQty; t.OutPoint.OpenPointWeiTuo.Add(opwt); RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接收出场追单通知HoldHands:{1}", this.policyName, holdHands))); } else if (status == OpenStatus.Failed) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受失败通知", this.policyName))); } else if (status == OpenStatus.PartOpend) { if (dealQty > (t.EnterPoint.DealQty - t.EnterPoint.PartDealQty)) { decimal realDealQty = (decimal)dealQty + (decimal)t.EnterPoint.PartDealQty - (decimal)t.EnterPoint.DealQty; t.EnterPoint.DealQty = dealQty + t.EnterPoint.PartDealQty; frozenOpenHands -= realDealQty; holdHands += realDealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受部分入场成交通知,成交数量:{1}", this.policyName, dealQty))); } long_position += (int)dealQty; short_position += (int)dealQty; } else if (status == OpenStatus.PartClosed) { for (int j = 0; j < t.OutPoint.OpenPointWeiTuo.Count; j++) { if (t.OutPoint.OpenPointWeiTuo[j].Weituobianhao == weituobianhao) { OpenPointWeiTuo opwt = t.OutPoint.OpenPointWeiTuo[j]; if (dealQty > (opwt.DealQty - opwt.PartDealQty)) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受部分出场成交通知,成交数量:{1}", this.policyName, dealQty))); decimal realDealQty = (decimal)dealQty + (decimal)opwt.PartDealQty - (decimal)opwt.DealQty; frozenCloseHands -= realDealQty; holdHands -= realDealQty; t.OutPoint.OpenPointWeiTuo[j].DealQty = dealQty + opwt.PartDealQty; } break; } } long_position -= (int)dealQty; short_position -= (int)dealQty; } else if (status == OpenStatus.OpenCanceled) { frozenOpenHands -= (decimal)dealQty; if (t.EnterPoint.DealQty == 0) { t.Finished = true; } open_complete = 0; close_complete = 0; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受入场撤单通知", this.policyName))); } else if (status == OpenStatus.CloseCanceled) { frozenCloseHands -= (decimal)dealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受出场撤单通知", this.policyName))); } } } }
public override void Notify(Guid tradeGuid, OpenStatus status, double dealQty = 0, double dealPrice = 0, string weituobianhao = "", string pendWeituobianhao = "") { if (tps.ContainsKey(tradeGuid)) { PTradePoints t = tps[tradeGuid]; if (status == OpenStatus.Opened) { decimal realDealQty = (decimal)dealQty + (decimal)t.EnterPoint.PartDealQty - (decimal)t.EnterPoint.DealQty; t.EnterPoint.DealQty = (double)((decimal)dealQty + (decimal)t.EnterPoint.PartDealQty); if (t.EnterPoint.OpenType == OpenType.KaiDuo) { DuoHands += (Decimal)t.EnterPoint.DealQty; FrozenDuoHands -= (Decimal)t.EnterPoint.DealQty; } else { KongHands += (Decimal)t.EnterPoint.DealQty; FrozenKongHands -= (Decimal)t.EnterPoint.DealQty; } if (currentTick.IsReal) { t.Status = OpenStatus.Opened; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受开仓通知,成交数量:{1}", this.policyName, dealQty))); } } else if (status == OpenStatus.Open) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受开仓下单通知", this.policyName))); } else if (status == OpenStatus.Close) { OpenPointWeiTuo opwt = new OpenPointWeiTuo(); opwt.Weituobianhao = weituobianhao; opwt.OpenQty = dealQty; t.OutPoint.OpenPointWeiTuo.Add(opwt); if (currentTick.IsReal) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受平仓下单通知", this.policyName))); } } else if (status == OpenStatus.Closed) { double RealTotalDeal = 0; bool find = false; for (int j = 0; j < t.OutPoint.OpenPointWeiTuo.Count; j++) { if (t.OutPoint.OpenPointWeiTuo[j].Weituobianhao == weituobianhao) { OpenPointWeiTuo opwt = t.OutPoint.OpenPointWeiTuo[j]; decimal realDealQty = (decimal)dealQty + (decimal)opwt.PartDealQty - (decimal)opwt.DealQty; t.OutPoint.OpenPointWeiTuo[j].DealQty = dealQty + opwt.PartDealQty; find = true; } RealTotalDeal += t.OutPoint.OpenPointWeiTuo[j].DealQty; } if (t.EnterPoint.DealQty == RealTotalDeal) { if (t.EnterPoint.OpenType == OpenType.KaiDuo) { DuoHands -= (decimal)RealTotalDeal; } else { KongHands -= (decimal)RealTotalDeal; } t.Finished = true; PTradePoints tptemp; tps.TryRemove(tradeGuid, out tptemp); } if (currentTick.IsReal) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受平仓通知-{1}-有单子:{2}", this.policyName, weituobianhao, find.ToString()))); } } else if (status == OpenStatus.OpenPending) { t.EnterPoint.PartDealQty = t.EnterPoint.DealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接收入场追单通知", this.policyName))); } else if (status == OpenStatus.ClosePending) { OpenPointWeiTuo opwt = new OpenPointWeiTuo(); opwt.Weituobianhao = pendWeituobianhao; opwt.OpenQty = dealQty; t.OutPoint.OpenPointWeiTuo.Add(opwt); RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接收出场追单通知", this.policyName))); } else if (status == OpenStatus.Failed) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受失败通知", this.policyName))); } else if (status == OpenStatus.PartOpend) { if (dealQty > (t.EnterPoint.DealQty - t.EnterPoint.PartDealQty)) { decimal realDealQty = (decimal)dealQty + (decimal)t.EnterPoint.PartDealQty - (decimal)t.EnterPoint.DealQty; t.EnterPoint.DealQty = dealQty + t.EnterPoint.PartDealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受部分入场成交通知,成交数量:{1}", this.policyName, dealQty))); } } else if (status == OpenStatus.PartClosed) { for (int j = 0; j < t.OutPoint.OpenPointWeiTuo.Count; j++) { if (t.OutPoint.OpenPointWeiTuo[j].Weituobianhao == weituobianhao) { OpenPointWeiTuo opwt = t.OutPoint.OpenPointWeiTuo[j]; if (dealQty > (opwt.DealQty - opwt.PartDealQty)) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受部分出场成交通知,成交数量:{1}", this.policyName, dealQty))); decimal realDealQty = (decimal)dealQty + (decimal)opwt.PartDealQty - (decimal)opwt.DealQty; t.OutPoint.OpenPointWeiTuo[j].DealQty = dealQty + opwt.PartDealQty; } break; } } } else if (status == OpenStatus.OpenCanceled) { if (t.EnterPoint.DealQty == 0) { t.Finished = true; } RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受入场撤单通知", this.policyName))); } else if (status == OpenStatus.CloseCanceled) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受出场撤单通知", this.policyName))); } } }
public override void Notify(Guid tradeGuid, OpenStatus status, double dealQty = 0, double dealPrice = 0, string weituobianhao = "", string pendWeituobianhao = "") { if (tps.ContainsKey(tradeGuid)) { TradePoints t = tps[tradeGuid]; if (t.TradeGuid == tradeGuid) { if (status == OpenStatus.Opened) { if (t.EnterPoint.SecInfo.Key == SecInfo.Key) { firstDeal = true; } if (t.EnterPoint.SecInfo.Key == SecondSi.Key) { secondDeal = true; } t.Status = OpenStatus.Opened; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受开仓通知,成交数量:{1}", this.policyName, dealQty))); } else if (status == OpenStatus.Open) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受开仓下单通知", this.policyName))); } else if (status == OpenStatus.OpenPending) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接收入场追单通知", this.policyName))); } else if (status == OpenStatus.Failed) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受失败通知", this.policyName))); } else if (status == OpenStatus.PartOpend) { if (dealQty > (t.EnterPoint.DealQty - t.EnterPoint.PartDealQty)) { decimal realDealQty = (decimal)dealQty + (decimal)t.EnterPoint.PartDealQty - (decimal)t.EnterPoint.DealQty; t.EnterPoint.DealQty = dealQty + t.EnterPoint.PartDealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受部分入场成交通知,成交数量:{1}", this.policyName, dealQty))); } } else if (status == OpenStatus.OpenRest) { if (t.EnterPoint.SecInfo.Key == SecInfo.Key) { firstDeal = true; } if (t.EnterPoint.SecInfo.Key == SecondSi.Key) { secondDeal = true; } if (t.EnterPoint.DealQty == 0) { t.Finished = true; } RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受入场撤单通知", this.policyName))); } else if (status == OpenStatus.OpenCanceled) { if (t.EnterPoint.SecInfo.Key == SecInfo.Key) { double openPrice = 0; if (t.EnterPoint.OpenType == OpenType.Buy) { openPrice = currentTick.Ask; } else { openPrice = currentTick.Bid; } OpenArgs oa = new OpenArgs( openPrice, parameter.qty, t.EnterPoint.OpenType, SecInfo, currentTick, t.TpRemark); OpenDelete od = new OpenDelete(OpenThread); od.BeginInvoke(oa, null, null); } if (t.EnterPoint.SecInfo.Key == SecondSi.Key) { double openPrice = 0; if (t.EnterPoint.OpenType == OpenType.Buy) { openPrice = SecondTick.Ask; } else { openPrice = SecondTick.Bid; } OpenArgs oa = new OpenArgs( openPrice, parameter.qty, t.EnterPoint.OpenType, SecondSi, SecondTick, t.TpRemark); OpenDelete od = new OpenDelete(OpenThread); od.BeginInvoke(oa, null, null); } RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受入场撤单通知", this.policyName))); } else if (status == OpenStatus.CloseCanceled) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受出场撤单通知", this.policyName))); } } } }
public async Task <IEnumerable <IMarket> > GetMarketsWithinDistance(double latitude, double longitude, int distance, OpenStatus openStatus) { var markets = await GetAllMarkets(); var marketsWithinDistance = new List <IMarket>(); foreach (var market in markets) { var distanceToMarket = GetDistanceBetweenPoints(latitude, longitude, market.Latitude, market.Longitude); if (distanceToMarket > distance) { continue; } var marketMatchesRequestedOpenStatus = DoesMarketMatchRequestedOpenStatus(market, openStatus); if (!marketMatchesRequestedOpenStatus) { continue; } market.Distance = distanceToMarket; marketsWithinDistance.Add(market); } return(SortSearchResults(marketsWithinDistance)); }
public async Task <string> GetMarketsNearLocation(double lat, double longi, int distance, OpenStatus openStatus) { var nearbyMarkets = await _marketService.GetMarketsWithinDistance(lat, longi, distance, openStatus); return(JsonConvert.SerializeObject(nearbyMarkets)); }
public PolicyNotifyEventArgs(object policy, Guid guid, OpenStatus openstatus) { this.policy = policy; this.tradeGuid = guid; this.openStatus = openstatus; }