public void GetSecurities() { List <Security> securities = new List <Security>();// TryToLoadSecurities(); /* if (securities != null) * { * SecurityEvent?.Invoke(securities); * SendLogMessage("Securities downloaded. Count: " + securities.Count, LogMessageType.System); * return; * }*/ SendLogMessage("Securities downloading...", LogMessageType.System); List <string> engines = GetEngines(); List <string> markets = GetMarkets(engines); List <string> classes = GetClasses(markets); securities = GetSecurities(classes); securities = CreateFuturesSection(securities); SecurityEvent?.Invoke(securities); SendLogMessage("Securities downloaded. Count: " + securities.Count, LogMessageType.System); //SaveSecurities(securities); }
/// <summary> /// получены инструменты с сервера /// </summary> /// <param name="products"></param> private void ClientReceivedSecurities(RootProducts products) { List <Security> securities = new List <Security>(); foreach (var product in products.Data) { var newSec = new Security(); newSec.Name = product.Symbol; newSec.NameClass = product.QuoteAsset; newSec.NameFull = product.Symbol; newSec.NameId = product.Symbol; newSec.Decimals = product.TickSize.DecimalsCount(); newSec.SecurityType = SecurityType.CurrencyPair; newSec.State = product.Status == "Normal" ? SecurityStateType.Activ : SecurityStateType.Close; newSec.Lot = 1; newSec.PriceStep = product.TickSize.ToDecimal(); newSec.PriceStepCost = newSec.PriceStep; newSec.Go = product.MinNotional.ToDecimal(); securities.Add(newSec); } SecurityEvent?.Invoke(securities); }
/// <summary> /// пришел список инструментов биржи /// </summary> private void ClientOnUpdatedSecurities(List <Instrument> securities) { if (_securities == null) { _securities = new List <Security>(); } for (int sec = 0; sec < securities.Count; sec++) { var lmaxSec = securities[sec]; if (_securities.Find(s => s.Name == lmaxSec.Name.Replace("/", "-")) != null) { _securities.Add( new Security { Name = lmaxSec.Name.Replace("/", "-") + "_2", NameId = lmaxSec.Id.ToString(), NameClass = lmaxSec.Contract.Currency, Lot = lmaxSec.OrderBook.QuantityIncrement, PriceStep = lmaxSec.OrderBook.PriceIncrement, PriceStepCost = lmaxSec.OrderBook.PriceIncrement, }); if (lmaxSec.OrderBook.PriceIncrement < 1) { _securities.Last().Decimals = lmaxSec.OrderBook.PriceIncrement.ToString(CultureInfo.InvariantCulture).Split('.')[1].Length; } continue; } _securities.Add( new Security { Name = lmaxSec.Name.Replace("/", "-"), NameId = lmaxSec.Id.ToString(), NameClass = lmaxSec.Contract.Currency, Lot = lmaxSec.OrderBook.QuantityIncrement, PriceStep = lmaxSec.OrderBook.PriceIncrement, PriceStepCost = lmaxSec.OrderBook.PriceIncrement }); if (lmaxSec.OrderBook.PriceIncrement < 1) { _securities.Last().Decimals = lmaxSec.OrderBook.PriceIncrement.ToString(CultureInfo.InvariantCulture).Split('.')[1].Length; } } SecurityEvent?.Invoke(_securities); }
public void GetSecurities() { SendLogMessage("Securities downloading...", LogMessageType.System); string requestString = "http://mfd.ru/export/"; string response = GetRequest(requestString); string[] lines = response.Split('\n'); List <string> classes = GetClasses(lines); List <Security> securities = new List <Security>(); for (int i = 0; i < classes.Count; i++) { securities.AddRange(GetAllSecuritiesToClass(classes[i])); } SecurityEvent?.Invoke(securities); SendLogMessage("Securities downloaded. Count: " + securities.Count, LogMessageType.System); }
/// <summary> /// получены инструменты с сервера /// </summary> /// <param name="products"></param> private void ClientReceivedSecurities(List <Product> products) { List <Security> securities = new List <Security>(); foreach (var product in products) { var newSec = new Security(); newSec.Name = product.baseAsset + "-" + product.quoteAsset; newSec.NameClass = product.quoteAsset; newSec.NameFull = product.symbol; newSec.NameId = product.symbol; newSec.Decimals = product.priceScale; newSec.SecurityType = SecurityType.CurrencyPair; newSec.State = product.status == "Normal" ? SecurityStateType.Activ : SecurityStateType.Close; newSec.Lot = GetValueByDecimals(product.qtyScale); newSec.PriceStep = GetValueByDecimals(product.priceScale); newSec.PriceStepCost = newSec.PriceStep; securities.Add(newSec); } SecurityEvent?.Invoke(securities); }
protected void OnSecurityEvent(List <Security> securities) { SecurityEvent?.Invoke(securities); }
private void HandleSecurities(List <TransaqEntity.Security> securities) { if (_securities == null) { _securities = new List <Security>(); } foreach (var securityData in securities) { try { if (securityData.Sectype != "FUT" && securityData.Sectype != "SHARE" && securityData.Sectype != "CURRENCY") { continue; } Security security = new Security(); security.Name = securityData.Seccode; security.NameFull = securityData.Shortname; security.NameClass = securityData.Board; security.NameId = securityData.Secid; // + "-" + securityData.Board; security.Decimals = Convert.ToInt32(securityData.Decimals); security.SecurityType = securityData.Sectype == "FUT" ? SecurityType.Futures : securityData.Sectype == "SHARE" ? SecurityType.Stock : securityData.Sectype == "OPT" ? SecurityType.Option : securityData.Sectype == "CURRENCY" ? SecurityType.CurrencyPair : SecurityType.None; security.Lot = Convert.ToDecimal(securityData.Lotsize.Replace(".", CultureInfo.InvariantCulture.NumberFormat.NumberDecimalSeparator), CultureInfo.InvariantCulture); security.PriceStep = Convert.ToDecimal(securityData.Minstep.Replace(".", CultureInfo.InvariantCulture.NumberFormat.NumberDecimalSeparator), CultureInfo.InvariantCulture); decimal pointCost; try { pointCost = Convert.ToDecimal(securityData.Point_cost.Replace( ".", CultureInfo.InvariantCulture.NumberFormat.NumberDecimalSeparator), CultureInfo.InvariantCulture); } catch (Exception e) { decimal.TryParse(securityData.Point_cost, NumberStyles.Float, CultureInfo.InvariantCulture, out pointCost); } security.PriceStepCost = security.PriceStep * pointCost / 100; security.State = securityData.Active == "true" ? SecurityStateType.Activ : SecurityStateType.Close; _securities.Add(security); } catch (Exception e) { SendLogMessage(e.Message, LogMessageType.Error); } } SecurityEvent?.Invoke(_securities); }