private async Task ReserveClientFundsAsync(Settlement settlement) { IndexSettings indexSettings = await _indexSettingsService.GetByIndexAsync(settlement.IndexName); // TODO: Use internal asset AssetSettings assetSettings = (await _instrumentService.GetAssetsAsync()) .Single(o => o.Exchange == ExchangeNames.Lykke && o.AssetId == indexSettings.AssetId); try { await _settlementTransferService.ReserveClientFundsAsync(settlement.WalletId, assetSettings.Asset, settlement.Amount, settlement.ClientId, settlement.Id); settlement.Status = SettlementStatus.Reserved; _log.InfoWithDetails("Funds reserved from client wallet", new { SettlementId = settlement.Id, indexSettings.AssetId, settlement.Amount, settlement.WalletId }); } catch (NotEnoughFundsException) { settlement.Error = SettlementError.NotEnoughFunds; _log.WarningWithDetails("Not enough funds to reserve from client wallet", new { SettlementId = settlement.Id, indexSettings.AssetId, settlement.Amount, settlement.WalletId }); } catch (Exception exception) { settlement.Error = SettlementError.Unknown; _log.ErrorWithDetails(exception, "An error occurred while reserving funds from client wallet", new { SettlementId = settlement.Id, indexSettings.AssetId, settlement.Amount, settlement.WalletId }); } await _settlementRepository.UpdateAsync(settlement); }
private async Task ValidateAsync(IndexSettings indexSettings) { // TODO: Use internal asset id AssetSettings assetSettings = (await _instrumentService.GetAssetsAsync()) .Single(o => o.Exchange == ExchangeNames.Lykke && o.AssetId == indexSettings.AssetId); if (assetSettings == null) { throw new InvalidOperationException("Asset settings not found"); } AssetPairSettings assetPairSettings = await _instrumentService.GetAssetPairAsync(indexSettings.AssetPairId, ExchangeNames.Lykke); if (assetPairSettings == null) { throw new InvalidOperationException("Asset pair settings not found"); } if (indexSettings.SellVolume / indexSettings.SellLimitOrdersCount < assetPairSettings.MinVolume) { throw new InvalidOperationException("Sell limit order volume is less than min volume"); } if (indexSettings.BuyVolume / indexSettings.BuyLimitOrdersCount < assetPairSettings.MinVolume) { throw new InvalidOperationException("Buy limit order volume is less than min volume"); } }
public Market AddMarket(AssetSettings asset) { var market = asset.CreateMarket(OrderMap); Markets.Add(asset.Id, market); return(market); }
public ExchangeMarket AddMarket(AssetSettings asset, bool useLegacyOrderbook = false) { var market = asset.CreateMarket(OrderMap, useLegacyOrderbook); Markets.Add(asset.Id, market); return(market); }
public ResizeImageCommandHandler(IOptions <AssetSettings> configuration, IFileRepository fileRepository, IImageService imageService) { _configuration = configuration.Value; _fileRepository = fileRepository; _imageService = imageService; }
public static Asset ToAsset(this AssetSettings assetSettings) { if (assetSettings.IsXlm) { return(new AssetTypeNative()); } return(Asset.CreateNonNativeAsset(assetSettings.Code, assetSettings.Issuer.ToString())); }
public GetResizedFileByIdQueryHandler(IOptions <AssetSettings> configuration, IImageService imageService, IFileReadRepository fileReadRepository) { _configuration = configuration.Value; _imageService = imageService; _fileReadRepository = fileReadRepository; }
/// <summary> /// File Controller. /// </summary> /// <param name="mediator">The mediator.</param> /// <param name="config">The config.</param> /// <param name="mimeTypeFactory">Mime Type Factory.</param> public FileController(IMediator mediator, IOptions <AssetSettings> config, MimeTypeFactory mimeTypeFactory) { _mediator = mediator; _configuration = config.Value; _mimeTypeFactory = mimeTypeFactory; }
public void default_content_files() { var settings = new AssetSettings(); settings.ContentMatches.ShouldContain(".htm"); settings.ContentMatches.ShouldContain(".html"); settings.ContentMatches.ShouldContain(".txt"); }
public FileProcessingHostedService(ILogger <FileProcessingHostedService> logger, IOptions <AssetSettings> config, IServiceScopeFactory serviceScopeFactory) { _logger = logger; _configuration = config.Value; _serviceScopeFactory = serviceScopeFactory; _timer = new Timer(callback: async _ => await DoWorkAsync()); }
public void adds_the_user_supplied_extensions() { var settings = new AssetSettings(); var manifest = settings.CreateFileWatcherManifest(FubuApplicationFiles.ForDefault()); manifest.AssetExtensions.ShouldContain(".svg"); manifest.AssetExtensions.ShouldContain(".ttf"); manifest.AssetExtensions.ShouldContain(".eot"); }
public void Update(AssetSettings assetSettings) { LykkeAssetId = assetSettings.LykkeAssetId; QuoteSource = assetSettings.QuoteSource; ExternalAssetPairId = assetSettings.ExternalAssetPairId; IsInverse = assetSettings.IsInverse; DisplayAccuracy = assetSettings.DisplayAccuracy; IsCrypto = assetSettings.IsCrypto; }
public Task UpdateAsync(AssetSettings assetSettings) { return(_storage.MergeAsync(GetPartitionKey(assetSettings.Exchange), GetRowKey(assetSettings.Asset), entity => { Mapper.Map(assetSettings, entity); return entity; })); }
public void no_public_folder_if_in_anywhere_mode() { var settings = new AssetSettings { Mode = SearchMode.Anywhere }; settings.CreateFileWatcherManifest(FubuApplicationFiles.ForDefault()).PublicAssetFolder.ShouldBeEmpty(); }
public static Asset FromAssetSettings(AssetSettings assetSettings) { return(new Asset { Id = assetSettings.Id, Code = assetSettings.Code, Issuer = assetSettings.IsXlm ? null : ((KeyPair)assetSettings.Issuer).AccountId }); }
private AuthorizationRight forFile(string filename) { var file = new FubuFile(filename); var owinSettings = new AssetSettings(); owinSettings.StaticFileRules.Add(new AssetSettings()); return(owinSettings.DetermineStaticFileRights(file)); }
public async Task InsertAsync(AssetSettings assetSettings) { var entity = new AssetSettingsEntity(GetPartitionKey(assetSettings.Exchange), GetRowKey(assetSettings.Asset)); Mapper.Map(assetSettings, entity); await _storage.InsertAsync(entity); }
public void add_exclusions() { var settings = new AssetSettings(); settings.Exclude("something.js"); settings.Exclude("node-content"); settings.CreateAssetSearch().Exclude.ShouldBe("node_modules/*;something.js;node-content"); }
public void default_allowable_mimetypes_includes_fonts() { var settings = new AssetSettings(); var search = settings.CreateAssetSearch(); search.Include.ShouldContain(".svg"); search.Include.ShouldContain(".eot"); search.Include.ShouldContain(".ttf"); search.Include.ShouldContain(".woff"); }
public void AssetsNullValueSerializationTest() { var asset = new AssetSettings { Code = "XLM" }; var rawData = XdrConverter.Serialize(asset); asset = XdrConverter.Deserialize <AssetSettings>(rawData); Assert.AreEqual(null, asset.Issuer); }
public async Task <IActionResult> Add([FromBody] AssetSettings settings) { settings = Mapper.Map <AssetSettings>(await _assetSettingsService.AddAsync(settings)); return(Created ( uri: $"api/v2/asset-settings/{settings.Asset}", value: settings )); }
private void ValidateBalance(IReadOnlyCollection <LimitOrder> limitOrders, AssetSettings baseAssetSettings, AssetSettings quoteAssetSettings) { List <LimitOrder> sellLimitOrders = limitOrders .Where(o => o.Error == LimitOrderError.None) .Where(o => o.Type == LimitOrderType.Sell) .OrderBy(o => o.Price) .ToList(); List <LimitOrder> buyLimitOrders = limitOrders .Where(o => o.Error == LimitOrderError.None) .Where(o => o.Type == LimitOrderType.Buy) .OrderByDescending(o => o.Price) .ToList(); if (sellLimitOrders.Any()) { decimal balance = _balanceService.GetByAssetId(ExchangeNames.Lykke, baseAssetSettings.AssetId).Amount; foreach (LimitOrder limitOrder in sellLimitOrders) { decimal amount = limitOrder.Volume.TruncateDecimalPlaces(baseAssetSettings.Accuracy, true); if (balance - amount < 0) { decimal volume = balance.TruncateDecimalPlaces(baseAssetSettings.Accuracy); limitOrder.UpdateVolume(volume); } balance = Math.Max(balance - amount, 0); } } if (buyLimitOrders.Any()) { decimal balance = _balanceService.GetByAssetId(ExchangeNames.Lykke, quoteAssetSettings.AssetId).Amount; foreach (LimitOrder limitOrder in buyLimitOrders) { decimal amount = (limitOrder.Price * limitOrder.Volume) .TruncateDecimalPlaces(quoteAssetSettings.Accuracy, true); if (balance - amount < 0) { decimal volume = (balance / limitOrder.Price).TruncateDecimalPlaces(baseAssetSettings.Accuracy); limitOrder.UpdateVolume(volume); } balance = Math.Max(balance - amount, 0); } } }
public void adds_all_the_default_asset_extensions() { var settings = new AssetSettings(); var manifest = settings.CreateFileWatcherManifest(FubuApplicationFiles.ForDefault()); manifest.AssetExtensions.ShouldContain(".js"); manifest.AssetExtensions.ShouldContain(".css"); manifest.AssetExtensions.ShouldContain(".jpeg"); manifest.AssetExtensions.ShouldContain(".jpg"); manifest.AssetExtensions.ShouldContain(".bmp"); }
public async Task <AssetSettingsModel> GetByIdAsync(string assetId) { AssetSettings assetSettings = await _assetSettingsService.GetByIdAsync(assetId); if (assetSettings == null) { throw new ValidationApiException(HttpStatusCode.NotFound, "Asset settings do not exist."); } return(Mapper.Map <AssetSettingsModel>(assetSettings)); }
public void adds_content_extensions() { var settings = new AssetSettings(); settings.ContentMatches.Add(".foo"); var manifest = settings.CreateFileWatcherManifest(FubuApplicationFiles.ForDefault()); manifest.ContentMatches.ShouldContain(".foo"); manifest.ContentMatches.ShouldContain(".htm"); manifest.ContentMatches.ShouldContain(".html"); }
public void headers_in_production_mode() { FubuMode.Reset(); var settings = new AssetSettings(); settings.Headers.GetAllKeys() .ShouldHaveTheSameElementsAs(HttpRequestHeaders.CacheControl, HttpRequestHeaders.Expires); settings.Headers[HttpRequestHeaders.CacheControl]().ShouldEqual("private, max-age=86400"); settings.Headers[HttpRequestHeaders.Expires]().ShouldNotBeNull(); }
public UploadFilesCommandHandler(IFileRepository fileRepository, IOptions <AssetSettings> config, IMapper mapper, IImageService imageService, IFileSystemService fileSystemService) { _fileRepository = fileRepository; _configuration = config.Value; _mapper = mapper; _imageService = imageService; _fileSystemService = fileSystemService; }
public PreGeneratorService(IOptions <AssetSettings> config, IFileRepository fileRepository, ILogger <PreGeneratorService> logger, IImageService imageService, ISqlConnectionFactory sqlConnectionFactory) { _configuration = config.Value; _fileRepository = fileRepository; _logger = logger; _imageService = imageService; _sqlConnectionFactory = sqlConnectionFactory; }
// TODO: Move to LykkeExchangeService private async Task <string> GetAssetId(string asset) { AssetSettings assetSettings = await _instrumentService.GetAssetAsync(asset, ExchangeNames.Lykke); if (assetSettings == null) { _log.WarningWithDetails("No asset setting", asset); throw new InvalidOperationException("No asset setting"); } return(assetSettings.AssetId); }
private AddressableAssetGroup CreateGroup <TSchemaType>(string groupName, AddressableAssetGroupTemplate groupTemplate) { var group = AssetSettings.CreateGroup(groupName, false, false, false, new List <AddressableAssetGroupSchema> { AssetSettings.DefaultGroup.Schemas[0] }, typeof(TSchemaType)); if (groupTemplate != null) { groupTemplate.ApplyToAddressableAssetGroup(group); } return(group); }