public override void OnReceiveEvent(string[] param) { if (int.TryParse(param[6], out int volume)) { slim.Wait(); SendConsecutive?.Invoke(this, new SendConsecutive(new Charts { Date = param[0], Price = param[1].StartsWith("-") ? param[1].Substring(1) : param[1], Volume = volume })); if (slim.Release() > 0) { Console.WriteLine(string.Concat(GetType().FullName, '_', Code)); } } if (param.Length == 0x20 && double.TryParse(param[1].StartsWith("-") ? param[1].Substring(1) : param[1], out double price)) { Current = price; Revenue = (long)((price - Purchase) * Quantity * TransactionMultiplier); Rate = (price / Purchase - 1) * (Quantity > 0 ? 1 : -1); } else if (int.TryParse(param[1].StartsWith("-") ? param[1].Substring(1) : param[1], out int current)) { Current = current; Revenue = (current - Purchase) * Quantity; Rate = current / (double)Purchase - 1; } SendStocks?.Invoke(this, new SendHoldingStocks(Code, Quantity, Purchase, Current, Revenue, Rate, Base, Secondary, AdjustTheColorAccordingToTheCurrentSituation(WaitOrder, OrderNumber.Count))); }
public override void OnReceiveEvent(string[] param) { if (int.TryParse(string.Concat(param[8], param[9]), out int volume)) { SendConsecutive?.Invoke(this, new SendConsecutive(new Charts { Date = param[0], Price = param[4], Volume = volume })); } if (double.TryParse(param[4], out double current)) { Current = current; Revenue = (long)((current - (Purchase ?? 0D)) * Quantity * transactionMultiplier); Rate = (Quantity > 0 ? current / (double)Purchase : Purchase / (double)current) - 1; if (OrderNumber.Count > 0 && strategics is TrendFollowingBasicFutures && OrderNumber.ContainsValue(Bid) == false && OrderNumber.ContainsValue(Offer) == false) { foreach (var kv in OrderNumber) { if (kv.Value < Bid || kv.Value > Offer) { SendBalance?.Invoke(this, new SendSecuritiesAPI(new Catalog.XingAPI.Order { FnoIsuNo = Code, OrgOrdNo = kv.Key, OrdQty = "1" })); } } } } if (param[0].CompareTo(end) > 0 && uint.TryParse(param[0], out uint remain) && (RollOver == false || Temporary.RemainingDay.Contains(remain))) { var quantity = Math.Abs(Quantity); RollOver = Temporary.RemainingDay.Remove(remain); if (RollOver == false) { RollOver = true; } while (quantity > 0) { SendBalance?.Invoke(this, new SendSecuritiesAPI(new Catalog.XingAPI.Order { FnoIsuNo = Code, BnsTpCode = Quantity > 0 ? "1" : "2", FnoOrdprcPtnCode = ((int)Catalog.XingAPI.FnoOrdprcPtnCode.시장가).ToString("D2"), OrdPrc = Purchase.ToString("F2"), OrdQty = "1" })); quantity--; } } SendStocks?.Invoke(this, new SendHoldingStocks(Code, Quantity, Purchase, Current, Revenue, Rate, Base, Secondary, AdjustTheColorAccordingToTheCurrentSituation(WaitOrder, OrderNumber.Count))); }
public override void OnReceiveEvent(string[] param) { if (int.TryParse(string.Concat(param[8], param[9]), out int volume)) { SendConsecutive?.Invoke(this, new SendConsecutive(new Charts { Date = param[0], Price = param[4], Volume = volume })); } if (double.TryParse(param[4], out double current)) { Current = current; Revenue = (long)((current - Purchase) * Quantity * transactionMutiplier); Rate = (Quantity > 0 ? current / (double)Purchase : Purchase / (double)current) - 1; } SendStocks?.Invoke(this, new SendHoldingStocks(Code, Quantity, Purchase, Current, Revenue, Rate, Base, Secondary, AdjustTheColorAccordingToTheCurrentSituation(WaitOrder, OrderNumber.Count))); }
public override void OnReceiveEvent(string[] param) { if (int.TryParse(param[6], out int volume)) { SendConsecutive?.Invoke(this, new SendConsecutive(new Charts { Date = param[0], Price = param[1].StartsWith("-") ? param[1].Substring(1) : param[1], Volume = volume })); } if (int.TryParse(param[1].StartsWith("-") ? param[1].Substring(1) : param[1], out int current)) { Current = current; Revenue = (current - Purchase) * Quantity; Rate = current / (double)Purchase - 1; } SendStocks?.Invoke(this, new SendHoldingStocks(Code, Quantity, Purchase, Current, Revenue, Rate, Base, Secondary, AdjustTheColorAccordingToTheCurrentSituation(WaitOrder, OrderNumber.Count))); }