/// <summary> /// This method evaluates a symbol name and returns its value. /// </summary> /// <param name="name">Name of symbol</param> /// <param name="pos">Position at start of symbol</param> /// <returns></returns> protected object EvaluateSymbol(string name, int pos) { object result = default(double); // We found a symbol reference SymbolStatus status = SymbolStatus.UndefinedSymbol; if (ProcessSymbol != null) { SymbolEventArgs args = new SymbolEventArgs(); args.Name = name; args.Result = result; args.Status = SymbolStatus.OK; ProcessSymbol(this, args); result = args.Result; status = args.Status; } if (status == SymbolStatus.UndefinedSymbol) { throw new EvalException(String.Format(ErrorMessages.ErrUndefinedSymbol, name), name, pos); } if (status == SymbolStatus.UndefinedVariable) { throw new EvalException(String.Format(ErrorMessages.ErrDataVariable, name), name, pos); } return(result); }
public static void Enable(string enabled, string disabled) { CompilerSymbolManager.Load(); string[] symbols; // enabled symbols = enabled.Split(';'); foreach (string symbol in symbols) { SymbolStatus sym = new SymbolStatus(); sym.name = symbol; sym.oldValue = CompilerSymbolManager.ActivateSymbol(symbol, true); Symbols.Add(sym); Debug.Log("ENABLE: " + sym.name + "=" + sym.oldValue); } // disabled symbols = disabled.Split(';'); foreach (string symbol in symbols) { SymbolStatus sym = new SymbolStatus(); sym.name = symbol; sym.oldValue = CompilerSymbolManager.ActivateSymbol(symbol, false); Symbols.Add(sym); Debug.Log("DISABLE: " + sym.name + "=" + sym.oldValue); } CompilerSymbolManager.Save(); }
public void IsValid() { const SymbolStatus status = SymbolStatus.Trading; var quoteAsset = Asset.USDT; var quantityRange = new InclusiveRange(0.01m, 10.0m, 0.01m); var priceRange = new InclusiveRange(0.01m, 100.0m, 0.01m); const decimal minNotionalValue = 0.001m; const bool isIcebergAllowed = true; var orderTypes = new [] { OrderType.Limit, OrderType.Market }; var validSymbol = Symbol.BTC_USDT; var invalidSymbol = new Symbol(status, new Asset("...", 0), quoteAsset, quantityRange, priceRange, minNotionalValue, isIcebergAllowed, orderTypes); Assert.True(Symbol.IsValid(validSymbol)); Assert.False(Symbol.IsValid(invalidSymbol)); }
public static void Enable(string _symbolsString) { CompilerSymbolManager.Load(); string[] symbols = _symbolsString.Split(';'); foreach (string symbol in symbols) { SymbolStatus sym = new SymbolStatus(); sym.name = symbol; sym.oldValue = CompilerSymbolManager.ActivateSymbol(symbol, true); Symbols.Add(sym); Debug.Log("ENABLE: " + sym.name + "=" + sym.oldValue); } CompilerSymbolManager.Save(); }
public void Throws() { const SymbolStatus status = SymbolStatus.Trading; var baseAsset = Asset.BTC; var quoteAsset = Asset.USDT; var quantityRange = new InclusiveRange(0.01m, 10.0m, 0.01m); var priceRange = new InclusiveRange(0.01m, 100.0m, 0.01m); const decimal minNotionalValue = 0.001m; const bool isIcebergAllowed = true; var orderTypes = new OrderType[] { OrderType.Limit, OrderType.Market }; Assert.Throws <ArgumentNullException>("baseAsset", () => new Symbol(status, null, quoteAsset, quantityRange, priceRange, minNotionalValue, isIcebergAllowed, orderTypes)); Assert.Throws <ArgumentNullException>("quoteAsset", () => new Symbol(status, baseAsset, null, quantityRange, priceRange, minNotionalValue, isIcebergAllowed, orderTypes)); Assert.Throws <ArgumentNullException>("quantity", () => new Symbol(status, baseAsset, quoteAsset, null, priceRange, minNotionalValue, isIcebergAllowed, orderTypes)); Assert.Throws <ArgumentNullException>("price", () => new Symbol(status, baseAsset, quoteAsset, quantityRange, null, minNotionalValue, isIcebergAllowed, orderTypes)); Assert.Throws <ArgumentNullException>("orderTypes", () => new Symbol(status, baseAsset, quoteAsset, quantityRange, priceRange, minNotionalValue, isIcebergAllowed, null)); }
public static void Disable(string _symbolsString) { System.Threading.Thread.Sleep(500); CompilerSymbolManager.Load(); string[] symbols = _symbolsString.Split(';'); foreach (string symbol in symbols) { SymbolStatus sym = new SymbolStatus(); sym.name = symbol; sym.oldValue = CompilerSymbolManager.ActivateSymbol(symbol, false); Symbols.Add(sym); Debug.Log("DISABLE: " + sym.name + "=" + sym.oldValue); } CompilerSymbolManager.Save(); }
private async Task <SymbolStatus> IndexSymbol(IStorageFeed feed, PackageName packageName, IBinaryInfo binaryInfo) { var symbolStatus = new SymbolStatus(new SymbolName(binaryInfo.Name, binaryInfo.SymbolInfo.Hash)); try { Debug.WriteLine("Indexing symbol {0}", symbolStatus.SymbolName); await RequestOrSkip(string.Format("pdb/{0}", symbolStatus.SymbolName), async() => { Debug.WriteLine("Storing symbol {0}", symbolStatus.SymbolName); var symbolItem = feed.GetSymbol(packageName, symbolStatus.SymbolName); var pdbstrSection = CreatePdbStrSection(binaryInfo); using (var inputStream = binaryInfo.SymbolInfo.File.GetStream()) using (var tempStream = new MemoryStream()) using (var outputStream = await symbolItem.Put()) { pdbStoreManager.WriteSrcSrv(inputStream, tempStream, pdbstrSection); tempStream.Position = 0; var symbolFileName = Path.GetFileName(binaryInfo.SymbolInfo.File.FullPath); fileCompressor.Compress(symbolFileName, tempStream, outputStream); } }); symbolStatus.Stored = true; Debug.WriteLine("Stored symbol {0}", symbolStatus.SymbolName); } catch (Exception e) { support.TrackException(e, new { packageName }); symbolStatus.Exception = new ExceptionStatus(e); } if (binaryInfo.SymbolInfo.SourceInfos != null) { symbolStatus.SourceStatuses = await ProcessThrottled( 5, binaryInfo.SymbolInfo.SourceInfos, async s => await IndexSource(feed, packageName, s)); } return(symbolStatus); }
public void Properties() { const SymbolStatus status = SymbolStatus.Trading; var baseAsset = Asset.BTC; var quoteAsset = Asset.USDT; var quantityRange = new InclusiveRange(0.01m, 10.0m, 0.01m); var priceRange = new InclusiveRange(0.01m, 100.0m, 0.01m); const decimal minNotionalValue = 0.001m; const bool isIcebergAllowed = true; var orderTypes = new OrderType[] { OrderType.Limit, OrderType.Market }; var symbol = new Symbol(status, baseAsset, quoteAsset, quantityRange, priceRange, minNotionalValue, isIcebergAllowed, orderTypes); Assert.Equal(status, symbol.Status); Assert.Equal(baseAsset, symbol.BaseAsset); Assert.Equal(quoteAsset, symbol.QuoteAsset); Assert.Equal(quantityRange, symbol.Quantity); Assert.Equal(priceRange, symbol.Price); Assert.Equal(minNotionalValue, symbol.NotionalMinimumValue); Assert.Equal(orderTypes, symbol.OrderTypes); }
/// <summary> /// Constructor. /// </summary> /// <param name="status">The symbol status.</param> /// <param name="baseAsset">The symbol base asset.</param> /// <param name="quoteAsset">The symbol quote asset.</param> /// <param name="quantity">The minimum, maximum, and incremental quantity values.</param> /// <param name="price">The minimum, maximum, and incremental price values.</param> /// <param name="notionalMinimumValue">The minimum notional value.</param> /// <param name="isIcebergAllowed">The flag indicating if iceberg orders are allowed.</param> /// <param name="orderTypes">The list of allowed order types.</param> public Symbol(SymbolStatus status, Asset baseAsset, Asset quoteAsset, InclusiveRange quantity, InclusiveRange price, decimal notionalMinimumValue, bool isIcebergAllowed, IEnumerable <OrderType> orderTypes) { Throw.IfNull(baseAsset, nameof(baseAsset)); Throw.IfNull(quoteAsset, nameof(quoteAsset)); Throw.IfNull(quantity, nameof(quantity)); Throw.IfNull(price, nameof(price)); Throw.IfNull(orderTypes, nameof(orderTypes)); Status = status; BaseAsset = baseAsset; QuoteAsset = quoteAsset; Quantity = quantity; Price = price; NotionalMinimumValue = notionalMinimumValue; IsIcebergAllowed = isIcebergAllowed; OrderTypes = orderTypes; _symbol = $"{baseAsset}{quoteAsset}"; }
private async Task <SymbolStatus> DeleteSymbol(IStorageFeed feed, PackageName packageName, SymbolStatus symbolStatus) { var newSymbolStatus = new SymbolStatus(symbolStatus.SymbolName); if (symbolStatus.Stored) { try { Debug.WriteLine("Deleting symbol {0}", symbolStatus.SymbolName); newSymbolStatus.Stored = true; await RequestOrSkip(string.Format("pdb/{0}", symbolStatus.SymbolName), async() => { var symbolItem = feed.GetSymbol(packageName, symbolStatus.SymbolName); await symbolItem.Delete(); }); newSymbolStatus.Stored = false; Debug.WriteLine("Deleted symbol {0}", symbolStatus.SymbolName); } catch (Exception e) { support.TrackException(e, new { packageName }); newSymbolStatus.Exception = new ExceptionStatus(e); } } if (symbolStatus.SourceStatuses != null) { newSymbolStatus.SourceStatuses = await ProcessThrottled( 5, symbolStatus.SourceStatuses, async s => await DeleteSource(feed, packageName, s)); } return(newSymbolStatus); }
/// <summary> /// Creates a new <see cref="SymbolEventArgs"/> instance. /// </summary> /// <param name="name">The symbol name.</param> /// <param name="result">Returns the resulting value.</param> /// <param name="status">Returns the resulting status.</param> public SymbolEventArgs(string name, Variable result, SymbolStatus status = SymbolStatus.OK) { Name = name; Result = result; Status = status; }