private IList<IPriceValue> GetDiscountPrices(IList<IPriceValue> prices, MarketId marketId, Currency currency) { currency = GetCurrency(currency, marketId); var priceValues = new List<IPriceValue>(); _promotionHelper.Reset(); foreach (var entry in GetEntries(prices)) { var price = prices .OrderBy(x => x.UnitPrice.Amount) .FirstOrDefault(x => x.CatalogKey.CatalogEntryCode.Equals(entry.Code) && x.UnitPrice.Currency.Equals(currency)); if (price == null) { continue; } priceValues.Add(_promotionEntryService.GetDiscountPrice( price, entry, currency, _promotionHelper)); } return priceValues; }
public static IPriceValue GetMsrpPrice(string entryCode, MarketId marketId, Currency currency) { var filter = new PriceFilter() { CustomerPricing = new List <CustomerPricing> { new CustomerPricing((CustomerPricing.PriceType) 4, string.Empty), }, Currencies = new List <Currency> { currency }, ReturnCustomerPricing = true }; var prices = _priceService.Service.GetPrices(marketId, DateTime.Now, new CatalogKey(entryCode), filter); if (prices.Any()) { return(prices.OrderBy(x => x.UnitPrice.Amount).First()); } else { return(null); } }
private IEnumerable <ShippingMethodViewModel> CreateShippingMethodViewModels(MarketId marketId, Currency currency, IShipment shipment) { var shippingRates = GetShippingRates(marketId, currency, shipment); if (shipment.LineItems.Count(o => o.IsVirtualVariant()) == shipment.LineItems.Count) { shippingRates = shippingRates.Where(o => o.Money == 0); } else { shippingRates = shippingRates.Where(o => o.Money > 0); } var models = shippingRates.Select(r => new ShippingMethodViewModel { Id = r.Id, DisplayName = r.Name, Price = r.Money }) .ToList(); if (shipment.ShippingMethodId == InStorePickupInfoModel.MethodId) { models.Insert(0, new ShippingMethodViewModel { Id = InStorePickupInfoModel.MethodId, DisplayName = $"In store pickup - ({shipment.ShippingAddress.Line1} , {shipment.ShippingAddress.City} , {shipment.ShippingAddress.RegionName})", Price = new Money(0m, currency), IsInstorePickup = true }); } return(models); }
private static void CreateMarkets() { var usMarketId = new MarketId("US"); var euMarketId = new MarketId("EU"); var marketService = ServiceLocator.Current.GetInstance <IMarketService>(); UsMarket = marketService.GetMarket(usMarketId); if (UsMarket == null) { marketService.CreateMarket(new MarketImpl(usMarketId) { DefaultCurrency = Currency.USD, DefaultLanguage = new CultureInfo("en"), MarketName = "United States", MarketDescription = String.Empty }); UsMarket = marketService.GetMarket(usMarketId); } EuMarket = marketService.GetMarket(euMarketId); if (EuMarket == null) { marketService.CreateMarket(new MarketImpl(euMarketId) { DefaultCurrency = Currency.EUR, DefaultLanguage = new CultureInfo("en"), MarketName = "European Union", MarketDescription = String.Empty }); EuMarket = marketService.GetMarket(euMarketId); } }
public async Task Handle(ExchangeOrderBookUpdatedIntegrationEvent @event) { try { var quoteCurrency = @event.QuoteCurrency.ToUpper() == "USDT" ? "USD" : @event.QuoteCurrency.ToUpper(); var baseCurrency = @event.BaseCurrency.ToUpper(); var marketId = new MarketId(baseCurrency, quoteCurrency); var market = await _marketRepository.GetAsync(marketId); var exchange = await _exchangeRepository.GetAsync(@event.ExchangeId); var bids = @event.OrderBook.bids.AsEnumerable().Take(1).ToOrderPriceAndQuantitys(); var asks = @event.OrderBook.asks.AsEnumerable().Take(1).ToOrderPriceAndQuantitys(); market.UpdateExchangeMarket(exchange, bids, asks); await _marketRepository.Update(market); } catch (Exception ex) { Debug.Write("Handle Event: ExchangeOrderBookUpdatedIntegrationEvent." + "Result: Failure." + "Error Message: " + ex.Message ); throw ex; } //var askList = @event.OrderBook.asks; }
/// <summary> /// get prices /// </summary> /// <param name="market">market id</param> /// <param name="validOn">valid on</param> /// <param name="catalogKey">catalog key</param> /// <param name="filter">price filter</param> /// <returns>list of <c>IPriceValue</c></returns> public IEnumerable <IPriceValue> GetPrices(MarketId market, DateTime validOn, CatalogKey catalogKey, PriceFilter filter) { List <IPriceValue> prices = new List <IPriceValue>(); prices.Add(XPriceParser.GetPrice(catalogKey, MarketId.Empty, new Currency("GBP"))); return(prices); }
public async Task <List <MarketTrade> > GetMarketTrades(MarketId marketId) { PreludeMarketId preludeMarketId = (PreludeMarketId)marketId; return(PreludeMarketTrade.Parse(marketId, await CallPublic <JObject>(Method.last, preludeMarketId))); }
public BterMarketTrade(TradeId tradeId, OrderType tradeType, DateTime dateTime, decimal price, decimal quantity, MarketId marketId) : base(tradeId, dateTime, price, quantity, marketId) { this.TradeType = tradeType; }
public override string ToString() { return(MarketId.ToString() + "," + MarketOffDatetime.ToString("yyyy-MM-dd HH:mm:ss") + "," + SnapshotDatetime.ToString("yyyy-MM-dd HH:mm:ss") + "," + SecondsBeforeOff.ToString() + "," + SelectionId.ToString() + "," + SelectionName.ToString() + "," + (Back3 == 0 ? @"\N" : Back3.ToString()) + "," + (Back3Vol == 0 ? @"\N" : Back3Vol.ToString()) + "," + (Back2 == 0 ? @"\N" : Back2.ToString()) + "," + (Back2Vol == 0 ? @"\N" : Back2Vol.ToString()) + "," + (Back == 0 ? @"\N" : Back.ToString()) + "," + (BackVol == 0 ? @"\N" : BackVol.ToString()) + "," + (Lay == 0 ? @"\N" : Lay.ToString()) + "," + (LayVol == 0 ? @"\N" : LayVol.ToString()) + "," + (Lay2 == 0 ? @"\N" : Lay2.ToString()) + "," + (Lay2Vol == 0 ? @"\N" : Lay2Vol.ToString()) + "," + (Lay3 == 0 ? @"\N" : Lay3.ToString()) + "," + (Lay3Vol == 0 ? @"\N" : Lay3Vol.ToString()) + "," + (Trade ? "1" : "0") + "," + (LastTradedPrice == 0 ? @"\N" : LastTradedPrice.ToString()) + "," + CumulTradedVolSelection.ToString() + "," + CumulTradedVolMarket.ToString() + "," + (BecomesNonRunner ? "1" : "0") + "," + (ReductionFactorToApply > 0 ? ReductionFactorToApply.ToString() : @"\N") + "," + (Midpoint == 0 ? @"\N" : Midpoint.ToString()) + "," + (WeightedAverage == 0 ? @"\N" : WeightedAverage.ToString()) ); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Event notification for status of authentication. </summary> //////////////////////////////////////////////////////////////////////////////////////////////////// public void m_api_TTAPIStatusUpdate(object sender, TTAPIStatusUpdateEventArgs e) { Console.WriteLine("TTAPIStatusUpdate: {0}", e); if (e.IsReady == false) { // TODO: Do any connection lost processing here return; } // TODO: Do any connection up processing here // note: can happen multiple times with your application life cycle // can get status multiple times - do not create subscription if it exists // if (object.ReferenceEquals(m_instrLookupRequest, null) == false) { return; } // Status is up and we have not started a subscription yet // connection to TT is established Console.WriteLine("TTAPI Authenticated"); MarketId marketKey = Market.GetMarketIdFromName(m_market); ProductType productType = Product.GetProductTypeFromName(m_prodType); // lookup an instrument m_instrLookupRequest = new InstrumentLookup(tt_net_sdk.Dispatcher.Current, marketKey, productType, m_product, m_alias); m_instrLookupRequest.OnData += m_instrLookupRequest_OnData; m_instrLookupRequest.GetAsync(); }
public static IPriceValue GetSalePrice(string entryCode, MarketId marketId, Currency currency) { var customerPricing = new List <CustomerPricing> { new CustomerPricing(CustomerPricing.PriceType.AllCustomers, string.Empty), new CustomerPricing(CustomerPricing.PriceType.UserName, PrincipalInfo.Current.Name) }; if (CustomerContext.Current.CurrentContact != null) { customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.PriceGroup, CustomerContext.Current.CurrentContact.EffectiveCustomerGroup)); } var filter = new PriceFilter() { CustomerPricing = customerPricing, Currencies = new List <Currency> { currency }, ReturnCustomerPricing = true }; var prices = _priceService.Service.GetPrices(marketId, DateTime.Now, new CatalogKey(entryCode), filter); if (prices.Any()) { return(prices.OrderBy(x => x.UnitPrice.Amount).First()); } else { return(null); } }
public static Book ParseMarketDepthBook(JObject bookJson, MarketId marketId) { JToken buyJson = bookJson["buy"]; JToken sellJson = bookJson["sell"]; if (buyJson.Type != JTokenType.Array) { throw new CryptsyResponseException("Expected array for buy-side market depth, found \"" + Enum.GetName(typeof(JTokenType), buyJson.Type) + "\"."); } if (sellJson.Type != JTokenType.Array) { throw new CryptsyResponseException("Expected array for sell-side market depth, found \"" + Enum.GetName(typeof(JTokenType), sellJson.Type) + "\"."); } JArray buyArray = (JArray)buyJson; JArray sellArray = (JArray)sellJson; List <MarketDepth> buy = buyArray.Select( depth => (MarketDepth)CryptsyMarketDepth.ParseMarketDepth(depth as JArray) ).ToList(); List <MarketDepth> sell = sellArray.Select( depth => (MarketDepth)CryptsyMarketDepth.ParseMarketDepth(depth as JArray) ).ToList(); return(new Book(sell, buy)); }
public virtual double GetTaxValue(MarketId marketId, string countryCode, string regionCode, string postalCode, string city, TaxType taxType, int?taxCategoryId) { var regionIdentifier = GetCacheRegionIdentifier(postalCode, city, regionCode, countryCode); var key = GetCacheKey <TaxValue>(marketId, regionIdentifier, taxType, taxCategoryId); if (_objectInstanceCache.Get(key) != null) { return((double)_objectInstanceCache.Get(key)); } var percentage = 0.0; if (taxCategoryId.HasValue) { var taxCategoryName = _catalogTaxManagerFacade.GetTaxCategoryNameById(taxCategoryId.Value); // TODO: refactor tax retrieval #pragma warning disable 618 var taxValues = OrderContext.Current.GetTaxes(Guid.Empty, taxCategoryName, marketId.Value, countryCode, regionCode, postalCode, null, null, city); #pragma warning restore 618 var taxValue = taxValues.FirstOrDefault(x => x.TaxType == taxType); percentage = taxValue?.Percentage ?? 0.0; } _objectInstanceCache.Insert(key, percentage, new CacheEvictionPolicy(new TimeSpan(1, 0, 0), CacheTimeoutType.Sliding)); return(percentage); }
public async Task <Model.Book> GetMarketDepth(MarketId marketId) { VircurexMarketId vircurexMarketId = (VircurexMarketId)marketId; return(VircurexParsers.ParseOrderBook(await CallPublic <JObject>(Method.orderbook, vircurexMarketId.BaseCurrencyCode, vircurexMarketId.QuoteCurrencyCode))); }
public async Task <List <MarketTrade> > GetMarketTrades(MarketId marketId) { BterMarketId bterMarketId = (BterMarketId)marketId; return(BterMarketTrade.Parse(marketId, await CallPublic <JObject>(Method.trade, bterMarketId))); }
public ActionResult Set(ContentReference contentLink, [FromForm] string marketId) { var newMarketId = new MarketId(marketId); _currentMarket.SetCurrentMarket(newMarketId); var currentMarket = _marketService.GetMarket(newMarketId); //var cart = _cartService.LoadCart(_cartService.DefaultCartName, true)?.Cart; //if (cart != null && cart.Currency != null) //{ // _currencyService.SetCurrentCurrency(cart.Currency); //} //else //{ //_currencyService.SetCurrentCurrency(currentMarket.DefaultCurrency); //} _languageService.SetRoutedContent(_contentRouteHelper.Content, currentMarket.DefaultLanguage.Name); var returnUrl = _urlResolver.GetUrl(Request, contentLink, currentMarket.DefaultLanguage.Name); return(new ContentResult { Content = JsonConvert.SerializeObject(new { returnUrl }), ContentType = "application/json", }); }
/// <summary> /// Constructs parameters to be sent as part of a request to Cryptsy. /// </summary> /// <param name="method">The API method to call</param> /// <param name="orderId">An optional order ID to be passed as a parameter to the method</param> /// <param name="marketId">An optional market ID to be passsed as a parameter to the method</param> /// <param name="limit">An optional limit on number of returned items, to be passed as a parameter to the method</param> /// <returns>An array of key-value pairs</returns> private KeyValuePair <string, string>[] GenerateParameters(CryptsyMethod method, OrderId orderId, MarketId marketId, int?limit) { List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>(PARAM_METHOD, System.Enum.GetName(typeof(CryptsyMethod), method)), new KeyValuePair <string, string>(PARAM_NONCE, GetNextNonce()) }; if (null != marketId) { parameters.Add(new KeyValuePair <string, string>(PARAM_MARKET_ID, marketId.ToString())); } if (null != orderId) { parameters.Add(new KeyValuePair <string, string>(PARAM_ORDER_ID, orderId.ToString())); } if (null != limit) { parameters.Add(new KeyValuePair <string, string>(PARAM_LIMIT, limit.ToString())); } return(parameters.ToArray()); }
public async Task <Book> GetMarketDepth(MarketId marketId) { JObject response = await this.CallPublic <JObject>(Method.orderbook, (VoSMarketId)marketId, DEFAULT_PRECISION); return(VoSParsers.ParseOrderBook(response)); }
public CurrentMarketFromGeolocation(IMarketService marketService, ICommerceGeolocationService commerceGeolocationService) { MarketService = marketService; DefaultMarketId = marketService.GetAllMarkets().FirstOrDefault(x => x.IsEnabled)?.MarketId ?? new MarketId("DEFAULT"); CommerceGeolocationService = commerceGeolocationService; }
public async Task CancelMarketOrders(MarketId marketId) { FormUrlEncodedContent request = new FormUrlEncodedContent(GenerateParameters(CryptsyMethod.cancelmarketorder, (CryptsyOrderId)null, marketId, null)); await CallPrivate(request); }
public void SetCurrentMarket(MarketId marketId) { var market = GetMarket(marketId); SiteContext.Current.Currency = market.DefaultCurrency; _cookieService.Set(MarketCookie, marketId.Value); }
public static Book ParseMarketDepthBook(JObject bookJson, MarketId marketId) { JToken buyJson = bookJson["buy"]; JToken sellJson = bookJson["sell"]; if (buyJson.Type != JTokenType.Array) { throw new CryptsyResponseException("Expected array for buy-side market depth, found \"" + Enum.GetName(typeof(JTokenType), buyJson.Type) + "\"."); } if (sellJson.Type != JTokenType.Array) { throw new CryptsyResponseException("Expected array for sell-side market depth, found \"" + Enum.GetName(typeof(JTokenType), sellJson.Type) + "\"."); } JArray buyArray = (JArray)buyJson; JArray sellArray = (JArray)sellJson; List<MarketDepth> buy = buyArray.Select( depth => (MarketDepth)CryptsyMarketDepth.ParseMarketDepth(depth as JArray) ).ToList(); List<MarketDepth> sell = sellArray.Select( depth => (MarketDepth)CryptsyMarketDepth.ParseMarketDepth(depth as JArray) ).ToList(); return new Book(sell, buy); }
public IEnumerable <IPriceValue> GetPrices(MarketId market, DateTime validOn, CatalogKey catalogKey, PriceFilter filter) { List <IPriceValue> prices = new List <IPriceValue>(); prices.Add(GetRandomPrice(market, catalogKey)); return(prices); }
private CheckoutOptions GetOptions(MarketId marketId) { var configuration = GetConfiguration(marketId); var options = new PatchedCheckoutOptions { RequireValidateCallbackSuccess = configuration.RequireValidateCallbackSuccess, AllowSeparateShippingAddress = configuration.AllowSeparateShippingAddress, ColorButton = GetColor(configuration.WidgetButtonColor), ColorButtonText = GetColor(configuration.WidgetButtonTextColor), ColorCheckbox = GetColor(configuration.WidgetCheckboxColor), ColorCheckboxCheckmark = GetColor(configuration.WidgetCheckboxCheckmarkColor), ColorHeader = GetColor(configuration.WidgetHeaderColor), ColorLink = GetColor(configuration.WidgetLinkColor), RadiusBorder = configuration.WidgetBorderRadius, DateOfBirthMandatory = configuration.DateOfBirthMandatory, ShowSubtotalDetail = configuration.ShowSubtotalDetail, TitleMandatory = configuration.TitleMandatory, ShippingDetails = configuration.ShippingDetailsText }; var additionalCheckboxText = configuration.AdditionalCheckboxText; if (!string.IsNullOrEmpty(additionalCheckboxText)) { options.AdditionalCheckbox = new AdditionalCheckbox { Text = additionalCheckboxText, Checked = configuration.AdditionalCheckboxDefaultChecked, Required = configuration.AdditionalCheckboxRequired }; } return(options); }
public async override Task <Book> GetMarketDepth(MarketId marketId) { FormUrlEncodedContent request = new FormUrlEncodedContent(GenerateParameters(CryptsyMethod.depth, (CryptsyOrderId)null, marketId, null)); JObject returnObj = await CallPrivate <JObject>(request); return(CryptsyParsers.ParseMarketDepthBook(returnObj, marketId)); }
public async Task <Book> GetMarketOrders(MarketId marketId) { FormUrlEncodedContent request = new FormUrlEncodedContent(GenerateParameters(CryptsyMethod.marketorders, (CryptsyOrderId)null, marketId, null)); JObject marketOrdersJson = await CallPrivate <JObject>(request); return(CryptsyParsers.ParseMarketOrders(marketOrdersJson)); }
public IEnumerable <IPriceValue> GetPrices(IEnumerable <string> codes, MarketId marketId, Currency currency) { return(_priceService.GetPrices(marketId, DateTime.Now, codes.Select(x => new CatalogKey(x)), new PriceFilter() { Currencies = currency.Yield() }) .GetLowesPrice()); }
private void SaveMarketInProfile(MarketId marketId) { if (ProfileStorage != null) { ProfileStorage[_marketIdKey] = marketId.Value; ProfileStorage.Save(); } }
public async Task <List <MarketTrade> > GetMarketTrades(MarketId marketId) { VircurexMarketId vircurexMarketId = (VircurexMarketId)marketId; return(VircurexParsers.ParseMarketTrades(marketId, await CallPublic <JArray>(Method.trades, vircurexMarketId.BaseCurrencyCode, vircurexMarketId.QuoteCurrencyCode, null))); }
public IEnumerable <EntryContentBase> GetEntriesByMarket(MarketId marketId) // ok { var result = _client.Search <EntryContentBase>() .Filter(c => c.Markets().MatchContained(x => x.Value, marketId.Value)) .GetContentResult(); return(null); // for now }
public void SetCurrentMarket(MarketId marketId) { var market = GetMarket(marketId); SiteContext.Current.Currency = market.DefaultCurrency; _cookieService.Set(MarketCookie, marketId.Value); MarketEvent.OnChangeMarket(market, new EventArgs()); }
public Market(MarketId setMarketId, string baseCurrencyCode, string quoteCurrencyCode, string label, MarketStatistics statistics) { this.MarketId = setMarketId; this.BaseCurrencyCode = baseCurrencyCode; this.QuoteCurrencyCode = quoteCurrencyCode; this.Label = label; this.Statistics = statistics; }
private MarketImpl CreateMarketImpl(MarketId marketId, string marketName, bool isEnabled) { return(new MarketImpl(marketId) { DefaultLanguage = CultureInfo.GetCultureInfo(_language), IsEnabled = isEnabled, MarketName = marketName }); }
public CryptsyMarketTrade(TradeId tradeId, OrderType tradeType, DateTime dateTime, decimal price, decimal quantity, decimal fee, MarketId marketId) : base(tradeId, dateTime, price, quantity, marketId) { this.TradeType = tradeType; this.Fee = fee; }
public MyOrder(OrderId orderId, OrderType orderType, DateTime created, decimal price, decimal quantity, decimal originalQuantity, MarketId marketId) : base(orderType, price, quantity) { this.OrderId = orderId; this.Created = created; this.OriginalQuantity = originalQuantity; this.MarketId = marketId; }
/// <summary> /// Sets the current market, if <paramref name="marketId"/> represents a valid market; /// otherwise, performs no action. /// </summary> /// <param name="marketId">The market id.</param> /// <remarks>This will also set the current currency for the ECF context.</remarks> public void SetCurrentMarket(MarketId marketId) { var market = _marketService.GetMarket(marketId); if (market != null) { UpdateProfile(market); SiteContext.Current.Currency = market.DefaultCurrency; Globalization.ContentLanguage.PreferredCulture = market.DefaultLanguage; } }
public MyTrade(TradeId tradeId, OrderType tradeType, DateTime dateTime, decimal price, decimal? fee, decimal quantity, MarketId marketId, OrderId orderId) : base(tradeId, dateTime, price, quantity, marketId) { this.Fee = fee; this.OrderId = orderId; this.TradeType = tradeType; }
public Money? GetPrice(string code, MarketId marketId, Currency currency) { var prices = GetPriceList(code, marketId, new PriceFilter { Currencies = new[] { currency } }); return prices.Any() ? prices.First().UnitPrice : (Money?)null; }
public Trade(TradeId tradeId, DateTime dateTime, decimal price, decimal quantity, MarketId marketId) { this.Price = price; this.Quantity = quantity; this.TradeId = tradeId; this.DateTime = dateTime; this.MarketId = marketId; }
public IList<IPriceValue> GetPriceList(string code, MarketId marketId, PriceFilter priceFilter) { if (String.IsNullOrEmpty(code)) { throw new ArgumentNullException("code"); } var catalogKey = new CatalogKey(_appContext.ApplicationId, code); return _priceService.GetPrices(marketId, DateTime.Now, catalogKey, priceFilter) .OrderBy(x => x.UnitPrice.Amount) .ToList(); }
public static MyOrder ParseMyOrder(JObject myOrderJson, MarketId marketId, TimeZoneInfo timeZone) { DateTime created = DateTime.Parse(myOrderJson.Value<string>("created")); CryptsyOrderId orderId = CryptsyOrderId.Parse(myOrderJson["orderid"]); OrderType orderType = (OrderType)Enum.Parse(typeof(OrderType), myOrderJson.Value<string>("ordertype")); created = TimeZoneInfo.ConvertTimeToUtc(created, timeZone); return new MyOrder(orderId, orderType, created, myOrderJson.Value<decimal>("price"), myOrderJson.Value<decimal>("quantity"), myOrderJson.Value<decimal>("orig_quantity"), marketId ); }
public IList<IPriceValue> GetPriceList(IEnumerable<CatalogKey> catalogKeys, MarketId marketId, PriceFilter priceFilter) { if (catalogKeys == null) { throw new ArgumentNullException("catalogKeys"); } if (!catalogKeys.Any()) { return Enumerable.Empty<IPriceValue>().ToList(); } return _priceService.GetPrices(marketId, DateTime.Now, catalogKeys, priceFilter) .OrderBy(x => x.UnitPrice.Amount) .ToList(); }
public IPriceValue GetDefaultPrice(MarketId market, DateTime validOn, CatalogKey catalogKey, Currency currency) { PriceFilter filter = new PriceFilter() { Quantity = new Decimal?(new Decimal(0)), Currencies = (IEnumerable<Mediachase.Commerce.Currency>)new Mediachase.Commerce.Currency[1] { currency }, CustomerPricing = (IEnumerable<CustomerPricing>)new CustomerPricing[1] { CustomerPricing.AllCustomers } }; return GetPrices(market, validOn, catalogKey, filter).FirstOrDefault(); }
public static CryptsyMarketTrade Parse(JObject jsonTrade, MarketId defaultMarketId, TimeZoneInfo timeZone) { DateTime tradeDateTime = DateTime.Parse(jsonTrade.Value<string>("datetime")); JToken marketIdToken = jsonTrade["marketid"]; MarketId marketId = null == marketIdToken ? defaultMarketId : CryptsyMarketId.Parse(marketIdToken); CryptsyTradeId tradeId = CryptsyTradeId.Parse(jsonTrade["tradeid"]); OrderType orderType = (OrderType)Enum.Parse(typeof(OrderType), jsonTrade.Value<string>("initiate_ordertype")); tradeDateTime = TimeZoneInfo.ConvertTimeToUtc(tradeDateTime, timeZone); return new CryptsyMarketTrade(tradeId, orderType, tradeDateTime, jsonTrade.Value<decimal>("tradeprice"), jsonTrade.Value<decimal>("quantity"), jsonTrade.Value<decimal>("fee"), marketId ); }
public ActionResult Set(string marketId, ContentReference contentLink) { var newMarketId = new MarketId(marketId); _currentMarket.SetCurrentMarket(newMarketId); var currentMarket = _marketService.GetMarket(newMarketId); var cart = _cartService.LoadCart(_cartService.DefaultCartName); if (cart != null && cart.Currency != null) { _currencyService.SetCurrentCurrency(cart.Currency); } else { _currencyService.SetCurrentCurrency(currentMarket.DefaultCurrency); } _languageService.SetCurrentLanguage(currentMarket.DefaultLanguage.Name); var returnUrl = _urlResolver.GetUrl(Request, contentLink, currentMarket.DefaultLanguage.Name); return Json(new { returnUrl }); }
public IList<IPriceValue> GetDiscountPriceList(IEnumerable<CatalogKey> catalogKeys, MarketId marketId, Currency currency) { if (_marketService.GetMarket(marketId) == null) { throw new ArgumentException(string.Format("market '{0}' does not exist", marketId)); } var priceFilter = new PriceFilter { CustomerPricing = new[] { CustomerPricing.AllCustomers }, Quantity = 1, ReturnCustomerPricing = true, }; if (currency != Currency.Empty) { priceFilter.Currencies = new[] { currency }; } var prices = catalogKeys.SelectMany(x => _pricingService.GetPriceList(x.CatalogEntryCode, marketId, priceFilter)); return GetDiscountPrices(prices.ToList(), marketId, currency); }
private static async Task<MarketDepth> GetBestBid(IExchange exchange, MarketId marketId) { Book book = await exchange.GetMarketDepth(marketId); MarketDepth bestBid = null; foreach (MarketDepth bid in book.Bids) { if (null == bestBid || bid.Price > bestBid.Price) { bestBid = bid; } } return bestBid; }
public void SetCurrentMarket(MarketId marketId) { // Nope - no can do - we read it from the current context throw new NotImplementedException("Cannot set current market, it is resolved from the start page."); }
internal static PreludeMarketTrade ParseSingle(MarketId marketId, JObject trade) { return new PreludeMarketTrade(new PreludeFakeTradeId(), PreludeParsers.ParseDateTime(trade.Value<int>("timestamp")), trade.Value<decimal>("rate"), trade.Value<decimal>("amount"), marketId); }
public static List<MarketTrade> Parse(MarketId marketId, JObject tradesJson) { return tradesJson.Value<JArray>("orders").Select( trade => (MarketTrade)ParseSingle(marketId, (JObject)trade) ).ToList(); }
public PreludeMarketTrade(TradeId tradeId, DateTime dateTime, decimal price, decimal quantity, MarketId marketId) : base(tradeId, dateTime, price, quantity, marketId) { }
public abstract Task<List<MyOrder>> GetMyActiveOrders(MarketId marketId, int? limit);
public abstract Task<Book> GetMarketDepth(MarketId marketId);
public VoSMyOrder(OrderId orderId, OrderType orderType, DateTime created, decimal price, decimal quantity, decimal originalQuantity, MarketId marketId) : base(orderId, orderType, created, price, quantity, originalQuantity, marketId) { }
private IMarket GetMarket(MarketId marketId) { return _marketService.GetMarket(marketId) ?? _marketService.GetMarket(DefaultMarketId); }
private void SetupGetDiscountPrice(CatalogKey catalogKey, MarketId marketId, Money money) { _promotionServiceMock.Setup( x => x.GetDiscountPrice( catalogKey, marketId, money.Currency)) .Returns(new PriceValue { UnitPrice = money }); }
public IList<IPriceDetailValue> List(ContentReference catalogContentReference, MarketId marketId, PriceFilter filter, int offset, int count, out int totalCount) { var prices = List(catalogContentReference).ToList(); foreach (var price in prices.ToList()) { if (marketId != MarketId.Empty && price.MarketId != marketId) { prices.Remove(price); continue; } if (filter.Quantity != null) { if (price.MinQuantity > filter.Quantity) { prices.Remove(price); continue; } } if (filter.CustomerPricing != null && filter.CustomerPricing.Any()) { if (!filter.CustomerPricing.Contains(price.CustomerPricing)) { prices.Remove(price); continue; } } } totalCount = prices.Count(); var returnVal = prices.AsQueryable().Skip(offset).Take(count); return returnVal.ToList(); }
private static async Task<MarketDepth> GetBestAsk(IExchange exchange, MarketId marketId) { Book book = await exchange.GetMarketDepth(marketId); MarketDepth bestAsk = null; foreach (MarketDepth ask in book.Asks) { if (null == bestAsk || ask.Price < bestAsk.Price) { bestAsk = ask; } } return bestAsk; }
private static void CreateMarkets() { var usMarketId = new MarketId("US"); var euMarketId = new MarketId("EU"); var marketService = ServiceLocator.Current.GetInstance<IMarketService>(); UsMarket = marketService.GetMarket(usMarketId); if (UsMarket == null) { marketService.CreateMarket(new MarketImpl(usMarketId) { DefaultCurrency = Currency.USD, DefaultLanguage = new CultureInfo("en"), MarketName = "United States", MarketDescription = String.Empty }); UsMarket = marketService.GetMarket(usMarketId); } EuMarket = marketService.GetMarket(euMarketId); if (EuMarket == null) { marketService.CreateMarket(new MarketImpl(euMarketId) { DefaultCurrency = Currency.EUR, DefaultLanguage = new CultureInfo("en"), MarketName = "European Union", MarketDescription = String.Empty }); EuMarket = marketService.GetMarket(euMarketId); } }