public override void Submit() { // string redirectUrl = string.Concat(GetConfigEntry("paymentGatewayUrl"), "?process_id="); string redirectUrl = _configHelper.GetConfigEntry("paymentGatewayUrl"); string redirectUrlProcessId = _configHelper.GetConfigEntry("paymentGatewayProcessIdUrl"); string returnUrlApproved = string.Concat(RootUrl, _configHelper.GetConfigEntry("paymentGatewayReturnUrlApproved")); string approvedUrl = string.Format("{0}?Agency=Bancard&OrderId={1}&rsp=rsprdtc", returnUrlApproved, this.OrderNumber); string returnUrlDeclined = string.Concat(RootUrl, _configHelper.GetConfigEntry("paymentGatewayReturnUrlCanceled")); string declinedUrl = string.Format("{0}?Agency=Bancard&OrderId={1}", returnUrlDeclined, this.OrderNumber); string publicKey = _configHelper.GetConfigEntry("public_key"); string privateKey = _configHelper.GetConfigEntry("private_Key"); string dataProcessId = string.Empty; string processId = string.Empty; string token = string.Empty; NumberFormatInfo nfi = new NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; nfi.NumberGroupSeparator = ""; string amount = this._orderAmount.ToString("0.00", nfi); token = GenetateMD5(privateKey, OrderNumber.Remove(0, 2).TrimStart('0'), amount); dataProcessId = PrepareProcessIdData(publicKey, token, OrderNumber.Remove(0, 2).TrimStart('0'), amount, approvedUrl, declinedUrl); processId = getProcessId(dataProcessId); // Post and redirect to WebPay website HttpContext.Current.Response.Clear(); StringBuilder sb = new StringBuilder(); sb.Append("<html>"); sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>"); sb.AppendFormat("<form name='form' action='{0}' method='get'>", redirectUrl); sb.AppendFormat("<input type='hidden' name='process_id' value='{0}'>", processId); sb.Append("</form>"); sb.Append("</body>"); sb.Append("</html>"); string response = sb.ToString(); PaymentGatewayInvoker.LogMessage(PaymentGatewayLogEntryType.Request, this.OrderNumber, this._distributorId, this._gatewayName, PaymentGatewayRecordStatusType.Unknown, response); HttpContext.Current.Response.Write(response); HttpContext.Current.Response.End(); }
public override void OnReceiveConclusion(string[] param) { if (param.Length == 0x2E && uint.TryParse(param[0xA], out uint order) && OrderNumber.Remove(order.ToString()) && param[0xD].Equals("2") && uint.TryParse(param[9], out uint number) && double.TryParse(param[0x10], out double price)) { OrderNumber[number.ToString()] = price; } else if ((param[8].Equals(Enum.GetName(typeof(TR), TR.SONBT001)) || param[8].Equals(Enum.GetName(typeof(TR), TR.CONET801))) && double.TryParse(param[0x3C], out double nPrice)) { OrderNumber[param[0x2D]] = nPrice; SendBalance?.Invoke(this, new SendSecuritiesAPI(param[0x67], param[0x6C])); } else if (uint.TryParse(param[0x2F], out uint oNum) && OrderNumber.Remove(oNum.ToString()) && param[0x38].Equals("1") && uint.TryParse(param[0x2D], out uint nNum) && double.TryParse(param[0x3C], out double oPrice)) { OrderNumber[nNum.ToString()] = oPrice; } }
public override void OnReceiveBalance(string[] param) { var cme = param.Length > 0x1C; if (param[cme ? 0x33 : 0xB].Length == 8 && int.TryParse(param[cme ? 0x53 : 0xE], out int quantity) && double.TryParse(param[cme ? 0x52 : 0xD], out double current) && int.TryParse(param[cme ? 0x2D : 9], out int number) && OrderNumber.Remove(number.ToString())) { var gb = param[cme ? 0x37 : 0x14]; Current = current; Purchase = gb.Equals("2") && Quantity >= 0 ? ((Purchase ?? 0D) * Quantity + current * quantity) / (quantity + Quantity) : (gb.Equals("1") && Quantity <= 0 ? (current * quantity - (Purchase ?? 0D) * Quantity) / (quantity - Quantity) : (Purchase ?? 0D)); Quantity += gb.Equals("1") ? -quantity : quantity; Revenue = (long)(current - Purchase) * Quantity * TransactionMultiplier; Rate = (Quantity > 0 ? current / (double)Purchase : Purchase / (double)current) - 1; } SendBalance?.Invoke(this, new SendSecuritiesAPI(new Tuple <string, string, int, dynamic, dynamic, long, double>(param[cme ? 0x33 : 0xB], param[cme ? 0x34 : 0xB], Quantity, Purchase, Current, Revenue, Rate))); SendBalance?.Invoke(this, new SendSecuritiesAPI(true)); }
public override void OnReceiveConclusion(string[] param) { switch (param[param.Length - 1]) { case "EU0": case "EU1": switch (param[37]) { case "HO01": Console.WriteLine(param[37] + "_" + param.Length); break; case "CH01": Console.WriteLine(param[37] + "_" + param.Length); break; } break; } if (param.Length == 0x2E && uint.TryParse(param[0xA], out uint order) && OrderNumber.Remove(order.ToString()) && param[0xD].Equals("2") && uint.TryParse(param[9], out uint number) && double.TryParse(param[0x10], out double price)) { OrderNumber[number.ToString()] = price; } else if ((param[8].Equals(Enum.GetName(typeof(TR), TR.SONBT001)) || param[8].Equals(Enum.GetName(typeof(TR), TR.CONET801))) && double.TryParse(param[0x3C], out double nPrice)) { OrderNumber[param[0x2D]] = nPrice; SendBalance?.Invoke(this, new SendSecuritiesAPI(param[0x67], param[0x6C])); WaitOrder = true; } else if (param.Length > 0x38 && uint.TryParse(param[0x2F], out uint oNum) && OrderNumber.Remove(oNum.ToString()) && param[0x38].Equals("1") && uint.TryParse(param[0x2D], out uint nNum) && double.TryParse(param[0x3C], out double oPrice)) { OrderNumber[nNum.ToString()] = oPrice; } }
public override void OnReceiveDrawChart(object sender, SendConsecutive e) { if (GetCheckOnDate(e.Date)) { Short.Pop(); Long.Pop(); Trend.Pop(); } Trend.Push(Trend.Count > 0 ? EMA.Make(Line.Item3, Trend.Count, e.Price, Trend.Peek()) : EMA.Make(e.Price)); Short.Push(Short.Count > 0 ? EMA.Make(Line.Item1, Short.Count, e.Price, Short.Peek()) : EMA.Make(e.Price)); Long.Push(Long.Count > 0 ? EMA.Make(Line.Item2, Long.Count, e.Price, Long.Peek()) : EMA.Make(e.Price)); if (e.Volume != 0 && e.Date.Length > 8 && Short.Count > 1 && Long.Count > 1) { double popShort = Short.Pop(), popLong = Long.Pop(), gap = popShort - popLong - (Short.Peek() - Long.Peek()); Short.Push(popShort); Long.Push(popLong); var date = e.Date.Substring(6, 4); if (date.CompareTo(Base.Start) > 0 && date.CompareTo(Base.Transmit) < 0 && Strategics is Catalog.TrendsToCashflow tc && DateTime.TryParseExact(e.Date.Substring(0, 12), Base.FullDateFormat, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime cInterval)) { if (Balance.Quantity > tc.ReservationQuantity - 1 && (Offer ?? int.MaxValue) < e.Price && OrderNumber.Any(o => o.Key[0] == '8' && o.Value == e.Price - GetQuoteUnit(e.Price, Market))) { CumulativeFee += (uint)(e.Price * tc.ReservationQuantity * (Commission + Base.Tax)); Balance.Revenue += (long)((e.Price - (Balance.Purchase ?? 0D)) * tc.ReservationQuantity); Balance.Quantity -= tc.ReservationQuantity; var profit = OrderNumber.First(o => o.Key.StartsWith("8") && o.Value == e.Price - GetQuoteUnit(e.Price, Market)); if (OrderNumber.Remove(profit.Key)) { Capital -= profit.Value * tc.ReservationQuantity; Offer = profit.Value; } } else if ((Bid ?? int.MinValue) > e.Price && OrderNumber.Any(o => o.Key[0] == '7' && o.Value == e.Price + GetQuoteUnit(e.Price, Market))) { CumulativeFee += (uint)(e.Price * Commission * tc.ReservationQuantity); Balance.Purchase = (double)((e.Price * tc.ReservationQuantity + (Balance.Purchase ?? 0D) * Balance.Quantity) / (Balance.Quantity + tc.ReservationQuantity)); Balance.Quantity += tc.ReservationQuantity; var profit = OrderNumber.First(o => o.Key.StartsWith("7") && o.Value == e.Price + GetQuoteUnit(e.Price, Market)); if (OrderNumber.Remove(profit.Key)) { Capital += profit.Value * tc.ReservationQuantity; Bid = profit.Value; } } else if (Balance.Quantity > tc.TradingQuantity - 1 && OrderNumber.Any(o => o.Key[0] == '2' && o.Value == e.Price - GetQuoteUnit(e.Price, Market))) { CumulativeFee += (uint)(e.Price * tc.TradingQuantity * (Commission + Base.Tax)); Balance.Revenue += (long)((e.Price - (Balance.Purchase ?? 0D)) * tc.TradingQuantity); Balance.Quantity -= tc.TradingQuantity; var profit = OrderNumber.First(o => o.Key.StartsWith("2") && o.Value == e.Price - GetQuoteUnit(e.Price, Market)); if (OrderNumber.Remove(profit.Key)) { Capital -= profit.Value * tc.TradingQuantity; } } else if (OrderNumber.Any(o => o.Key.StartsWith("1") && o.Value == e.Price + GetQuoteUnit(e.Price, Market))) { CumulativeFee += (uint)(e.Price * Commission * tc.TradingQuantity); Balance.Purchase = (double)((e.Price * tc.TradingQuantity + (Balance.Purchase ?? 0D) * Balance.Quantity) / (Balance.Quantity + tc.TradingQuantity)); Balance.Quantity += tc.TradingQuantity; var profit = OrderNumber.First(o => o.Key.StartsWith("1") && o.Value == e.Price + GetQuoteUnit(e.Price, Market)); if (OrderNumber.Remove(profit.Key)) { Capital += profit.Value * tc.TradingQuantity; } } else if (Balance.Quantity > tc.TradingQuantity - 1 && OrderNumber.ContainsValue(e.Price) == false && e.Price > Trend.Peek() * (1 + tc.PositionRevenue) && e.Price > (Balance.Purchase ?? 0D) && gap < 0 && (tc.Interval == 0 || tc.Interval > 0 && cInterval.CompareTo(NextOrderTime) > 0)) { var unit = GetQuoteUnit(e.Price, Market); if (OrderNumber.ContainsValue(e.Price + unit) == false) { OrderNumber[Base.GetOrderNumber((int)OrderType.신규매도)] = e.Price + unit; } if (tc.Interval > 0) { NextOrderTime = Base.MeasureTheDelayTime(tc.Interval, cInterval); } } else if (tc.TradingQuantity > 0 && OrderNumber.ContainsValue(e.Price) == false && e.Price < Trend.Peek() * (1 - tc.PositionAddition) && gap > 0 && (tc.Interval == 0 || tc.Interval > 0 && cInterval.CompareTo(NextOrderTime) > 0)) { var unit = GetQuoteUnit(e.Price, Market); if (OrderNumber.ContainsValue(e.Price - unit) == false) { OrderNumber[Base.GetOrderNumber((int)OrderType.신규매수)] = e.Price - unit; } if (tc.Interval > 0) { NextOrderTime = Base.MeasureTheDelayTime(tc.Interval, cInterval); } } } else if (date.CompareTo(Base.Transmit) > 0 && Strategics is Catalog.TrendsToCashflow cf) { OrderNumber.Clear(); long revenue = Balance.Revenue - CumulativeFee, unrealize = (long)((e.Price - (Balance.Purchase ?? 0D)) * Balance.Quantity); var avg = EMA.Make(++Accumulative, revenue - TodayRevenue + unrealize - TodayUnrealize, Before); if (cf.ReservationQuantity > 0 && Balance.Quantity > cf.ReservationQuantity - 1) { var stock = Market; int quantity = Balance.Quantity / cf.ReservationQuantity, price = e.Price, sell = (int)((Balance.Purchase ?? 0D) * (1 + cf.ReservationRevenue)), buy = (int)((Balance.Purchase ?? 0D) * (1 - cf.Addition)), upper = (int)(price * 1.3), lower = (int)(price * 0.7), bPrice = Base.GetStartingPrice(lower, stock), sPrice = Base.GetStartingPrice(sell, stock); sPrice = sPrice < lower ? lower + GetQuoteUnit(sPrice, stock) : sPrice; while (sPrice < upper && quantity-- > 0) { OrderNumber[Base.GetOrderNumber((int)OrderType.예약매도)] = sPrice; for (int i = 0; i < cf.Unit; i++) { sPrice += GetQuoteUnit(sPrice, stock); } } while (bPrice < upper && bPrice < buy) { OrderNumber[Base.GetOrderNumber((int)OrderType.예약매수)] = bPrice; for (int i = 0; i < cf.Unit; i++) { bPrice += GetQuoteUnit(bPrice, stock); } } Bid = OrderNumber.Count > 0 && OrderNumber.Any(o => o.Key.StartsWith("7")) ? OrderNumber.Where(o => o.Key.StartsWith("7")).Max(o => o.Value) : 0; Offer = OrderNumber.Count > 0 && OrderNumber.Any(o => o.Key.StartsWith("8")) ? OrderNumber.Where(o => o.Key.StartsWith("8")).Min(o => o.Value) : 0; } SendMessage = new Catalog.Strategics.Statistics { Key = string.Concat("TC.", cf.AnalysisType), Date = e.Date.Substring(0, 6), Cumulative = revenue + unrealize, Base = SendMessage.Base > Capital ? SendMessage.Base : Capital, Statistic = (int)avg, Price = (int)Trend.Peek() }; Before = avg; TodayRevenue = revenue; TodayUnrealize = unrealize; } }
internal void OnReceiveTrendsInPrices(SendConsecutive e, double gap, double sShort, double sLong, double trend) { var date = e.Date.Substring(6, 4); switch (strategics) { case ScenarioAccordingToTrend st: if (e.Date.Length > 8 && date.CompareTo(start) > 0 && date.CompareTo(transmit) < 0 && DateTime.TryParseExact(e.Date.Substring(0, 12), format, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime interval)) { if (NextOrderTime == null) { NextOrderTime = interval; } else if (Quantity > st.Quantity - 1 && OrderNumber.Any(o => o.Key.StartsWith("2") && o.Value == e.Price - GetQuoteUnit(e.Price, Market))) { CumulativeFee += (uint)(e.Price * st.Quantity * (Commission + tax)); Revenue += (long)((e.Price - (Purchase ?? 0D)) * st.Quantity); Quantity -= st.Quantity; var profit = OrderNumber.First(o => o.Key.StartsWith("2") && o.Value == e.Price - GetQuoteUnit(e.Price, Market)); if (OrderNumber.Remove(profit.Key) && Verify) { OnReceiveBalance(new string[] { string.Concat(interval.ToShortDateString(), " ", interval.ToLongTimeString()), profit.Key, profit.Value.ToString("N0") }); } Base -= profit.Value * st.Quantity; } else if (OrderNumber.Any(o => o.Key.StartsWith("1") && o.Value == e.Price + GetQuoteUnit(e.Price, Market))) { CumulativeFee += (uint)(e.Price * Commission * st.Quantity); Purchase = (double)((e.Price * st.Quantity + (Purchase ?? 0D) * Quantity) / (Quantity + st.Quantity)); Quantity += st.Quantity; var profit = OrderNumber.First(o => o.Key.StartsWith("1") && o.Value == e.Price + GetQuoteUnit(e.Price, Market)); if (OrderNumber.Remove(profit.Key) && Verify) { OnReceiveBalance(new string[] { string.Concat(interval.ToShortDateString(), " ", interval.ToLongTimeString()), profit.Key, profit.Value.ToString("N0") }); } Base += profit.Value * st.Quantity; } else if (Quantity > st.Quantity - 1 && OrderNumber.ContainsValue(e.Price) == false && e.Price > trend * (1 + st.ErrorRange) && e.Price > (Purchase ?? 0D) && gap < 0 && (st.IntervalInSeconds == 0 || st.IntervalInSeconds > 0 && interval.CompareTo(NextOrderTime) > 0)) { var unit = GetQuoteUnit(e.Price, Market); if (Verify && VerifyAmount > Quantity && DateTime.TryParseExact(e.Date.Substring(0, 12), format, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime dt)) { OnReceiveConclusion(new string[] { string.Concat(OpenOrderType.신규매도, " ", dt.ToShortDateString(), " ", dt.ToLongTimeString(), " ", NextOrderTime), Quantity.ToString("N0"), (Purchase ?? 0D).ToString("N2"), (e.Price + unit).ToString("N0"), (Revenue - CumulativeFee).ToString("C0"), OrderNumber.Max(o => o.Key) }); VerifyAmount = Quantity; } if (OrderNumber.ContainsValue(e.Price + unit) == false) { OrderNumber[GetOrderNumber((int)OpenOrderType.신규매도)] = e.Price + unit; } if (st.IntervalInSeconds > 0) { NextOrderTime = MeasureTheDelayTime(st.IntervalInSeconds, interval); } } else if (OrderNumber.ContainsValue(e.Price) == false && e.Price < trend * (1 - st.ErrorRange) && gap > 0 && (st.IntervalInSeconds == 0 || st.IntervalInSeconds > 0 && interval.CompareTo(NextOrderTime) > 0)) { var unit = GetQuoteUnit(e.Price, Market); if (Verify && VerifyAmount < Quantity && DateTime.TryParseExact(e.Date.Substring(0, 12), format, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime dt)) { OnReceiveConclusion(new string[] { string.Concat(OpenOrderType.신규매수, " ", dt.ToShortDateString(), " ", dt.ToLongTimeString(), " ", NextOrderTime), Quantity.ToString("N0"), (Purchase ?? 0D).ToString("N2"), (e.Price - unit).ToString("N0"), (Revenue - CumulativeFee).ToString("C0"), OrderNumber.Where(o => o.Key.StartsWith("1")).Max(o => o.Key) }); VerifyAmount = Quantity; } if (OrderNumber.ContainsValue(e.Price - unit) == false) { OrderNumber[GetOrderNumber((int)OpenOrderType.신규매수)] = e.Price - unit; } if (st.IntervalInSeconds > 0) { NextOrderTime = MeasureTheDelayTime(st.IntervalInSeconds, interval); } } } else if (date.CompareTo(transmit) > 0) { OrderNumber.Clear(); Count = 0; long revenue = Revenue - CumulativeFee, unrealize = (long)((e.Price - (Purchase ?? 0D)) * Quantity); var avg = EMA.Make(++Accumulative, revenue - TodayRevenue + unrealize - TodayUnrealize, Before); SendMessage = new Statistics { Date = e.Date.Substring(0, 6), Cumulative = (revenue + unrealize) / st.Quantity, Base = SendMessage.Base > Base / st.Quantity ? SendMessage.Base : Base / st.Quantity, Statistic = (int)(avg / st.Quantity), Price = e.Price }; SendStocks?.Invoke(this, new SendHoldingStocks(e.Date, e.Price, sShort, sLong, trend, revenue + unrealize, (long)(Base > 0 ? Base : 0))); Before = avg; TodayRevenue = revenue; TodayUnrealize = unrealize; } break; case TrendsInStockPrices ts: if (e.Date.Length > 8 && date.CompareTo(start) > 0 && date.CompareTo(transmit) < 0) { if (Quantity > ts.Quantity - 1 && OrderNumber.Any(o => o.Key.StartsWith("2") && o.Value == e.Price - GetQuoteUnit(e.Price, Market))) { CumulativeFee += (uint)(e.Price * ts.Quantity * (Commission + tax)); Revenue += (long)((e.Price - (Purchase ?? 0D)) * ts.Quantity); Quantity -= ts.Quantity; var profit = OrderNumber.First(o => o.Key.StartsWith("2") && o.Value == e.Price - GetQuoteUnit(e.Price, Market)); if (OrderNumber.Remove(profit.Key) && Verify && DateTime.TryParseExact(e.Date.Substring(0, 12), format, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime dt)) { OnReceiveBalance(new string[] { string.Concat(dt.ToShortDateString(), " ", dt.ToLongTimeString()), profit.Key, profit.Value.ToString("N0") }); } Base -= profit.Value * ts.Quantity; } else if (OrderNumber.Any(o => o.Key.StartsWith("1") && o.Value == e.Price + GetQuoteUnit(e.Price, Market))) { CumulativeFee += (uint)(e.Price * Commission * ts.Quantity); Purchase = (double)((e.Price * ts.Quantity + (Purchase ?? 0D) * Quantity) / (Quantity + ts.Quantity)); Quantity += ts.Quantity; var profit = OrderNumber.First(o => o.Key.StartsWith("1") && o.Value == e.Price + GetQuoteUnit(e.Price, Market)); if (OrderNumber.Remove(profit.Key) && Verify && DateTime.TryParseExact(e.Date.Substring(0, 12), format, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime dt)) { OnReceiveBalance(new string[] { string.Concat(dt.ToShortDateString(), " ", dt.ToLongTimeString()), profit.Key, profit.Value.ToString("N0") }); } Base += profit.Value * ts.Quantity; } else if (Quantity > ts.Quantity - 1 && OrderNumber.ContainsValue(e.Price) == false && e.Price > trend * (1 + ts.RealizeProfit) && e.Price > (Purchase ?? 0D) && gap < 0) { var quote = 0; for (int i = 0; i < ts.QuoteUnit; i++) { quote += GetQuoteUnit(e.Price, Market); } if (Verify && VerifyAmount > Quantity && DateTime.TryParseExact(e.Date.Substring(0, 12), format, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime dt)) { OnReceiveConclusion(new string[] { string.Concat(OpenOrderType.신규매도, " ", dt.ToShortDateString(), " ", dt.ToLongTimeString()), Quantity.ToString("N0"), (Purchase ?? 0D).ToString("N2"), (e.Price + quote).ToString("N0"), (Revenue - CumulativeFee).ToString("C0"), OrderNumber.Max(o => o.Key) }); VerifyAmount = Quantity; } if (OrderNumber.ContainsValue(e.Price + quote) == false) { OrderNumber[GetOrderNumber((int)OpenOrderType.신규매도)] = e.Price + quote; } } else if (OrderNumber.ContainsValue(e.Price) == false && e.Price < trend * (1 - ts.AdditionalPurchase) && gap > 0) { var quote = 0; for (int i = 0; i < ts.QuoteUnit; i++) { quote += GetQuoteUnit(e.Price, Market); } if (Verify && VerifyAmount < Quantity && DateTime.TryParseExact(e.Date.Substring(0, 12), format, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime dt)) { OnReceiveConclusion(new string[] { string.Concat(OpenOrderType.신규매수, " ", dt.ToShortDateString(), " ", dt.ToLongTimeString()), Quantity.ToString("N0"), (Purchase ?? 0D).ToString("N2"), (e.Price - quote).ToString("N0"), (Revenue - CumulativeFee).ToString("C0"), OrderNumber.Where(o => o.Key.StartsWith("1")).Max(o => o.Key) }); VerifyAmount = Quantity; } if (OrderNumber.ContainsValue(e.Price - quote) == false) { OrderNumber[GetOrderNumber((int)OpenOrderType.신규매수)] = e.Price - quote; } } } else if (date.CompareTo(transmit) > 0) { OrderNumber.Clear(); Count = 0; long revenue = Revenue - CumulativeFee, unrealize = (long)((e.Price - (Purchase ?? 0D)) * Quantity); var avg = EMA.Make(++Accumulative, revenue - TodayRevenue + unrealize - TodayUnrealize, Before); if (ts.Setting.Equals(Setting.Reservation) && Quantity > ts.Quantity - 1) { var stock = Market; int quantity = Quantity / ts.Quantity, price = e.Price, sell = (int)((Purchase ?? 0D) * (1 + ts.RealizeProfit)), buy = (int)((Purchase ?? 0D) * (1 - ts.AdditionalPurchase)), upper = (int)(price * 1.3), lower = (int)(price * 0.7), bPrice = GetStartingPrice(lower, stock), sPrice = GetStartingPrice(sell, stock); sPrice = sPrice < lower ? lower + GetQuoteUnit(sPrice, stock) : sPrice; while (sPrice < upper && quantity-- > 0) { OrderNumber[GetOrderNumber((int)OpenOrderType.신규매도)] = sPrice; for (int i = 0; i < ts.QuoteUnit; i++) { sPrice += GetQuoteUnit(sPrice, stock); } } while (bPrice < upper && bPrice < buy) { OrderNumber[GetOrderNumber((int)OpenOrderType.신규매수)] = bPrice; for (int i = 0; i < ts.QuoteUnit; i++) { bPrice += GetQuoteUnit(bPrice, stock); } } if (Verify && DateTime.TryParseExact(e.Date.Substring(0, 12), format, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime dt)) { OnReceiveEvent(new string[] { string.Concat(dt.ToShortDateString(), " ", dt.ToLongTimeString()), OrderNumber.Where(o => o.Key.StartsWith("1")).Max(o => o.Key), OrderNumber.Where(o => o.Key.StartsWith("2")).Max(o => o.Key) }); } } SendMessage = new Statistics { Date = e.Date.Substring(0, 6), Cumulative = (revenue + unrealize) / ts.Quantity, Base = SendMessage.Base > Base / ts.Quantity ? SendMessage.Base : Base / ts.Quantity, Statistic = (int)(avg / ts.Quantity) }; SendStocks?.Invoke(this, new SendHoldingStocks(e.Date, e.Price, sShort, sLong, trend, revenue + unrealize, (long)(Base > 0 ? Base : 0))); Before = avg; TodayRevenue = revenue; TodayUnrealize = unrealize; } break; case TrendFollowingBasicFutures tf: break; } }