public static GameEntity SetMarkets(NicheType nicheType,
                                            int startDate,
                                            int duration,
                                            GameContext gameContext,
                                            MarketProfile settings
                                            )
        {
            var nicheId = GetNicheId(nicheType);

            var clients = GetFullAudience(settings, nicheId);

            var techCost = GetTechCost(settings, nicheId);
            var adCosts  = GetAdCost(settings, nicheId);
            var price    = GetProductPrice(settings, adCosts, nicheId);


            var n = SetNicheCosts(nicheType, price, clients, techCost, adCosts, gameContext);

            Marketing.GetAudienceInfos();

            var positionings = GetStandardPositionings(nicheType);

            var clientsContainer = new Dictionary <int, long>
            {
                [0] = clients
            };

            n.ReplaceNicheSegments(positionings);
            n.ReplaceNicheClientsContainer(clientsContainer);
            n.ReplaceNicheLifecycle(GetYear(startDate), n.nicheLifecycle.Growth, GetYear(duration));
            n.ReplaceNicheBaseProfile(settings);

            return(n);
        }
    private void InitializeFundamentalIndustry()
    {
        var niches = new NicheType[] {
            NicheType.Tech_SearchEngine,
            NicheType.Tech_OSDesktop,
            NicheType.Tech_Clouds,
            NicheType.Tech_Browser,
            NicheType.Tech_MobileOS,
        };

        AttachNichesToIndustry(IndustryType.Technology, niches);

        var cloud =
            new MarketProfile(AudienceSize.SmallEnterprise, Monetisation.Enterprise, Margin.High, AppComplexity.Hard, NicheSpeed.Year);
        var searchEngine =
            new MarketProfile(AudienceSize.Global, Monetisation.Adverts, Margin.High, AppComplexity.Humongous, NicheSpeed.ThreeYears);
        var desktop =
            new MarketProfile(AudienceSize.Global, Monetisation.Paid, Margin.High, AppComplexity.Humongous, NicheSpeed.ThreeYears);
        var browser =
            new MarketProfile(AudienceSize.Global, Monetisation.Adverts, Margin.High, AppComplexity.Hard, NicheSpeed.Year);

        SetMarkets(NicheType.Tech_OSDesktop, 1980, 2040, desktop);
        SetMarkets(NicheType.Tech_Browser, 1990, 2050, browser);
        SetMarkets(NicheType.Tech_SearchEngine, 1995, 2040, searchEngine);

        SetMarkets(NicheType.Tech_MobileOS, 2005, 2070, desktop);
        SetMarkets(NicheType.Tech_Clouds, 2006, 2050, cloud);
    }
    public void ReplaceNicheBaseProfile(MarketProfile newProfile)
    {
        var index     = GameComponentsLookup.NicheBaseProfile;
        var component = (NicheBaseProfileComponent)CreateComponent(index, typeof(NicheBaseProfileComponent));

        component.Profile = newProfile;
        ReplaceComponent(index, component);
    }
        public static float GetProductPrice(MarketProfile profile, float adCost, int nicheId)
        {
            Monetisation monetisationType = profile.MonetisationType;
            Margin       margin           = profile.Margin;

            var baseCost = adCost * (100 + (int)margin);

            return(baseCost / 100f);
        }
        public static float GetAdCost(MarketProfile profile, int nicheId)
        {
            Monetisation monetisationType = profile.MonetisationType;

            var baseValue = (int)monetisationType;

            //var repaymentTime = GetSelfPaymentTime(monetisationType);
            //baseValue *= repaymentTime;

            return(Randomise(baseValue * 1000, nicheId) / 12f / 1000f);
        }
Beispiel #6
0
        public async Task <Quote> GetAsync(string baseAssetId, string quoteAssetId)
        {
            string directAssetPairId = $"{baseAssetId}{quoteAssetId}";

            if (baseAssetId == quoteAssetId)
            {
                return(new Quote(directAssetPairId, DateTime.UtcNow, 1, 1));
            }

            IReadOnlyCollection <AssetPair> assetPairs = await _assetsServiceWithCache.GetAllAssetPairsAsync();

            bool inverted = false;

            AssetPair assetPair = assetPairs
                                  .SingleOrDefault(o => o.BaseAssetId == baseAssetId && o.QuotingAssetId == quoteAssetId);

            if (assetPair == null)
            {
                inverted = true;

                assetPair = assetPairs
                            .SingleOrDefault(o => o.BaseAssetId == quoteAssetId && o.QuotingAssetId == baseAssetId);
            }

            if (assetPair == null)
            {
                throw new InvalidOperationException($"Asset pair does not exist for '{baseAssetId}'/'{quoteAssetId}'");
            }

            MarketProfile marketProfile = await GetMarketProfileAsync();

            FeedData feedData = marketProfile.Profile.FirstOrDefault(o => o.Asset == assetPair.Id);

            if (feedData == null)
            {
                throw new InvalidOperationException($"No quote for asset pair '{assetPair.Id}'");
            }

            if (inverted)
            {
                return(new Quote(assetPair.Id, feedData.DateTime, 1 / (decimal)feedData.Ask,
                                 1 / (decimal)feedData.Bid));
            }

            return(new Quote(assetPair.Id, feedData.DateTime, (decimal)feedData.Ask,
                             (decimal)feedData.Bid));
        }
        public static void InitializeEcommerceIndustry(GameContext gameContext)
        {
            var niches = new NicheType[] {
                NicheType.ECom_Marketplace,
                NicheType.ECom_OnlineTaxi,
            };

            AttachNichesToIndustry(IndustryType.Ecommerce, niches, gameContext);

            var marketplace =
                new MarketProfile(AudienceSize.Million100, Monetisation.Service, Margin.High, AppComplexity.Hard, NicheSpeed.Year);

            var taxi =
                new MarketProfile(AudienceSize.Global, Monetisation.Service, Margin.Low, AppComplexity.Hard, NicheSpeed.Year);

            SetMarkets(NicheType.ECom_Marketplace, 1995, 2050, gameContext, marketplace);
            SetMarkets(NicheType.ECom_OnlineTaxi, 1995, 2050, gameContext, taxi);
        }
Beispiel #8
0
    private void InitializeEntertainmentIndustry()
    {
        var niches = new NicheType[] {
            // gambling
            NicheType.Ent_Betting,
            NicheType.Ent_Casino,
            //NicheType.Ent_Lottery,
            NicheType.Ent_Poker,

            // gaming
            //NicheType.Ent_FreeToPlay,
            //NicheType.Ent_MMOs,
            //NicheType.Ent_Publishing,

            // Video Streaming
            NicheType.Ent_VideoHosting,
            NicheType.Ent_StreamingService,
            NicheType.Ent_TVStreamingService,
        };

        AttachNichesToIndustry(IndustryType.Entertainment, niches);

        var videoHosting = new MarketProfile(AudienceSize.Global, Monetisation.Adverts, Margin.Low, AppComplexity.Hard, NicheSpeed.ThreeYears);

        var streaming   = new MarketProfile(AudienceSize.Million100, Monetisation.Service, Margin.Low, AppComplexity.Average, NicheSpeed.Year);
        var tvStreaming = new MarketProfile(AudienceSize.Million100, Monetisation.Service, Margin.Mid, AppComplexity.Average, NicheSpeed.Year);

        //SetMarkets(NicheType.Ent_Lottery, 2000, 2018, GetGamblingCompanyProfile);
        SetMarkets(NicheType.Ent_Casino, 2001, 2020, GetGamblingCompanyProfile);
        SetMarkets(NicheType.Ent_Betting, 2000, 2020, GetGamblingCompanyProfile);
        SetMarkets(NicheType.Ent_Poker, 2001, 2025, GetGamblingCompanyProfile);

        //SetMarkets(NicheType.Ent_FreeToPlay, 2001, 2100,
        //    AudienceSize.Million100, Monetisation.Adverts, Margin.Mid, NicheSpeed.Year, AppComplexity.Average);

        //SetMarkets(NicheType.Ent_MMOs, 2000, 2030,
        //    AudienceSize.Million, Monetisation.Service, Margin.Mid, NicheSpeed.Year, AppComplexity.Average);


        SetMarkets(NicheType.Ent_VideoHosting, 2004, 2030, videoHosting);

        SetMarkets(NicheType.Ent_StreamingService, 2011, 2030, streaming);
        SetMarkets(NicheType.Ent_TVStreamingService, 2013, 2030, tvStreaming);
    }
        public static GameEntity SetMarkets(
            NicheType nicheType,
            int startDate,
            int duration,
            GameContext gameContext,
            AudienceSize AudienceSize, Monetisation MonetisationType, Margin Margin, NicheSpeed Iteration, AppComplexity ProductComplexity
            )
        {
            var profile = new MarketProfile
            {
                AudienceSize     = AudienceSize,
                NicheSpeed       = Iteration,
                Margin           = Margin,
                MonetisationType = MonetisationType,
                AppComplexity    = ProductComplexity
            };

            return(SetMarkets(nicheType, startDate, duration, gameContext, profile));
        }
        public static void InitializeTourismIndustry(GameContext gameContext)
        {
            var niches = new NicheType[] {
                NicheType.ECom_BookingTransportTickets,
                NicheType.ECom_BookingHotels,
                NicheType.ECom_BookingTours,
                NicheType.ECom_BookingAppartments,
            };

            AttachNichesToIndustry(IndustryType.Tourism, niches, gameContext);

            var booking =
                new MarketProfile(AudienceSize.Million100, Monetisation.Service, Margin.Low, AppComplexity.Average, NicheSpeed.Year);

            SetMarkets(NicheType.ECom_BookingTransportTickets, 1998, 2030, gameContext, booking);
            SetMarkets(NicheType.ECom_BookingHotels, 1998, 2030, gameContext, booking);
            SetMarkets(NicheType.ECom_BookingTours, 1998, 2030, gameContext, booking);
            SetMarkets(NicheType.ECom_BookingAppartments, 2008, 2050, gameContext, booking);
        }
        public static void InitializeCommunicationsIndustry(GameContext gameContext)
        {
            var niches = new NicheType[] {
                NicheType.Com_Messenger,        // chatting***, info
                NicheType.Com_SocialNetwork,    // users, chatting, info
                NicheType.Com_Blogs,            // info, users, chatting
                NicheType.Com_Forums,           // info, chatting
                NicheType.Com_Email,            // chatting

                NicheType.Com_Dating,
            };

            AttachNichesToIndustry(IndustryType.Communications, niches, gameContext);


            var socialNetworks =
                new MarketProfile(AudienceSize.Global, Monetisation.Adverts, Margin.Mid, AppComplexity.Hard, NicheSpeed.Year);

            //        var payment =
            //new MarketProfile(AudienceSize.Million100, Monetisation.Service, Margin.Low, AppComplexity.Average, NicheSpeed.HalfYear);

            var messenger = socialNetworks.Copy().IncomeLow().WebService().Dynamic();

            SetMarkets(NicheType.Com_Email, 1990, 2020, gameContext, GetPopularUsefulAppProfile);
            SetMarkets(NicheType.Com_Forums, 1990, 2020, gameContext, GetPopularRarelyUsedAppProfile);
            SetMarkets(NicheType.Com_Blogs, 1995, 2020, gameContext, GetPopularRarelyUsedAppProfile);
            SetMarkets(NicheType.Com_Dating, 2000, 2020, gameContext, GetPopularUsefulAppProfile);

            SetMarkets(NicheType.Com_Messenger, 2000, 2030, gameContext, messenger);
            SetMarkets(NicheType.Com_SocialNetwork, 1998, 2030, gameContext, socialNetworks);
            //SetMarkets(NicheType.Com_SocialNetwork, 2003, 2025, gameContext, socialNetworks);



            //new ProductPositioning[] {
            //    //new ProductPositioning { name = "Basic social network", marketShare = 100 }, // fb
            //    //new ProductPositioning { name = "Corporate social network", marketShare = 3, priceModifier = 10 }, // linkedIn
            //    //new ProductPositioning { name = "Text focused social network", marketShare = 15, priceModifier = 1.75f }, // twitter
            //    //new ProductPositioning { name = "Image focused social network", marketShare = 85 }, // insta
            //},
        }
Beispiel #12
0
    GameEntity SetMarkets(NicheType nicheType,
                          int startDate,
                          int duration,
                          MarketProfile settings
                          )
    {
        var nicheId = GetNicheId(nicheType);

        var clients  = GetFullAudience(settings, nicheId);
        var techCost = GetTechCost(settings, nicheId);
        var adCosts  = GetAdCost(settings, nicheId);
        var price    = GetProductPrice(settings, adCosts, nicheId);


        var n = SetNicheCosts(nicheType, price, clients, techCost, adCosts);


        var positionings = new Dictionary <int, ProductPositioning>
        {
            [0] = new ProductPositioning
            {
                isCompetitive = false,
                marketShare   = 100,
                name          = Enums.GetSingleFormattedNicheName(nicheType)
            }
        };

        var clientsContainer = new Dictionary <int, long>
        {
            [0] = clients
        };

        n.ReplaceNicheSegments(positionings);
        n.ReplaceNicheClientsContainer(clientsContainer);
        n.ReplaceNicheLifecycle(GetYear(startDate), n.nicheLifecycle.Growth, GetYear(duration));
        n.ReplaceNicheBaseProfile(settings);

        return(n);
    }
        public static void InitializeFinancesIndustry(GameContext gameContext)
        {
            var niches = new NicheType[] {
                NicheType.ECom_MoneyExchange,
                NicheType.ECom_OnlineBanking,
                NicheType.ECom_PaymentSystem,

                //NicheType.ECom_Blockchain,
                //NicheType.ECom_TradingBot,
            };

            AttachNichesToIndustry(IndustryType.Finances, niches, gameContext);

            var payment =
                new MarketProfile(AudienceSize.Million100, Monetisation.Service, Margin.Low, AppComplexity.Average, NicheSpeed.HalfYear);

            var banking = payment.Copy().Global().IncomeMid().Dynamic();

            SetMarkets(NicheType.ECom_OnlineBanking, 1992, 2030, gameContext, banking);
            SetMarkets(NicheType.ECom_PaymentSystem, 1995, 2030, gameContext, payment);

            SetMarkets(NicheType.ECom_MoneyExchange, 1998, 2030, gameContext, payment);
        }
Beispiel #14
0
        private async Task <MarketProfile> GetMarketProfileAsync()
        {
            if ((DateTime.UtcNow - _marketProfileDate).TotalSeconds > MarketMakerProfileLiveTimeSeconds)
            {
                await _semaphore.WaitAsync();

                try
                {
                    if ((DateTime.UtcNow - _marketProfileDate).TotalSeconds > MarketMakerProfileLiveTimeSeconds)
                    {
                        _marketProfile = await _rateCalculatorClient.GetMarketProfileAsync();

                        _marketProfileDate = DateTime.UtcNow;
                    }
                }
                finally
                {
                    _semaphore.Release();
                }
            }

            return(_marketProfile);
        }
Beispiel #15
0
        public async Task <double> GetAmountInBase(string assetFrom, double amount, string assetTo,
                                                   MarketProfile marketProfile = null)
        {
            var marketProfileData = marketProfile ?? await _bestPriceRepository.GetAsync();

            if (assetFrom == assetTo)
            {
                return(amount);
            }

            if (Math.Abs(amount) < double.Epsilon)
            {
                return(0);
            }

            var assetPair = (await _assetPairsDict.Values()).PairWithAssets(assetFrom, assetTo);
            var askPrice  = marketProfileData.Profile.First(x => x.Asset == assetPair.Id).Ask;
            var toAsset   = await _assetsDict.GetItemAsync(assetTo);

            var price = assetPair.BaseAssetId == assetFrom ? askPrice : 1 / askPrice;

            return((price * amount).TruncateDecimalPlaces(toAsset.Accuracy));
        }
Beispiel #16
0
    private void InitializeUsefulAppsIndustry()
    {
        var niches = new NicheType[] {
            NicheType.Qol_PdfReader,         // pdf readers
            NicheType.Qol_DocumentEditors,   // micr office
            NicheType.Qol_GraphicalEditor,   // Photoshop
            NicheType.Qol_3DGraphicalEditor, // 3d max
            NicheType.Qol_VideoEditingTool,  // average


            NicheType.Qol_AdBlocker,           // small
            NicheType.Qol_DiskFormattingUtils, // small
            NicheType.Qol_RSSReader,           // small
            NicheType.Qol_Archivers,           // small-average

            //NicheType.Qol_MusicPlayers, // small-average
            //NicheType.Qol_VideoPlayers, // average
            NicheType.Qol_MusicSearch,
            NicheType.Qol_Maps,

            NicheType.Qol_Encyclopedia,
            //NicheType.Qol_Antivirus,

            NicheType.Qol_OnlineEducation,
            //NicheType.Qol_OnlineGenealogy,


            NicheType.ECom_OnlineTaxi,
        };

        AttachNichesToIndustry(IndustryType.WorkAndLife, niches);

        var smallUtil =
            new MarketProfile(AudienceSize.Million, Monetisation.Adverts, Margin.Low, AppComplexity.Solo, NicheSpeed.ThreeYears);

        var encyclopedia =
            new MarketProfile(AudienceSize.Million100, Monetisation.Adverts, Margin.Mid, AppComplexity.Easy, NicheSpeed.ThreeYears);

        // paid?
        var officeDocumentEditor =
            new MarketProfile(AudienceSize.Million100, Monetisation.Service, Margin.Mid, AppComplexity.Average, NicheSpeed.ThreeYears);

        var education =
            new MarketProfile(AudienceSize.Million, Monetisation.Service, Margin.High, AppComplexity.Easy, NicheSpeed.Year);

        var musicSearch =
            new MarketProfile(AudienceSize.Million100, Monetisation.Adverts, Margin.Low, AppComplexity.Easy, NicheSpeed.Year);

        var maps =
            new MarketProfile(AudienceSize.Global, Monetisation.Adverts, Margin.Low, AppComplexity.Hard, NicheSpeed.ThreeYears);

        //var genealogySite =
        //    new MarketProfile(AudienceSize.Million, Monetisation.Adverts, Margin.Low, AppComplexity.Easy, NicheSpeed.ThreeYears);

        var taxi =
            new MarketProfile(AudienceSize.Global, Monetisation.Service, Margin.Low, AppComplexity.Average, NicheSpeed.Year);



        SetMarkets(NicheType.Qol_DocumentEditors, 1980, 2040, officeDocumentEditor);
        SetMarkets(NicheType.Qol_GraphicalEditor, 1990, 2040, officeDocumentEditor);

        SetMarkets(NicheType.Qol_3DGraphicalEditor, 1990, 2050, officeDocumentEditor);


        SetMarkets(NicheType.Qol_DiskFormattingUtils, 1999, 2030, smallUtil);
        SetMarkets(NicheType.Qol_RSSReader, 1999, 2030, smallUtil);
        SetMarkets(NicheType.Qol_Archivers, 1999, 2030, smallUtil);

        SetMarkets(NicheType.Qol_PdfReader, 2000, 2030, officeDocumentEditor);
        SetMarkets(NicheType.Qol_VideoEditingTool, 2000, 2050, officeDocumentEditor);


        SetMarkets(NicheType.Qol_Encyclopedia, 2002, 2050, encyclopedia);
        SetMarkets(NicheType.Qol_AdBlocker, 2003, 2040, smallUtil);
        //SetMarkets(NicheType.Qol_OnlineGenealogy,       2003, 2040, genealogySite);


        SetMarkets(NicheType.Qol_Maps, 2005, 2040, maps);
        SetMarkets(NicheType.Qol_MusicSearch, 2009, 2040, musicSearch);

        SetMarkets(NicheType.ECom_OnlineTaxi, 1998, 2030, taxi);

        //SetMarkets(NicheType.Qol_MusicPlayers,          2003, 2040, smallUtil);
        //SetMarkets(NicheType.Qol_VideoPlayers,          2003, 2040, smallUtil);
        //SetMarkets(NicheType.Qol_Antivirus,             2003, 2040, smallUtil);
        SetMarkets(NicheType.Qol_OnlineEducation, 2008, 2040, education);
    }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='assetFrom'>
 /// </param>
 /// <param name='assetTo'>
 /// </param>
 /// <param name='amount'>
 /// </param>
 /// <param name='marketProfile'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <double?> ApiRateCalculatorGetAmountInBaseWithProfileByAssetFromByAssetToByAmountPostAsync(this IRateCalculatorAPI operations, string assetFrom, string assetTo, double amount, MarketProfile marketProfile = default(MarketProfile), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ApiRateCalculatorGetAmountInBaseWithProfileByAssetFromByAssetToByAmountPostWithHttpMessagesAsync(assetFrom, assetTo, amount, marketProfile, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='assetFrom'>
 /// </param>
 /// <param name='assetTo'>
 /// </param>
 /// <param name='amount'>
 /// </param>
 /// <param name='marketProfile'>
 /// </param>
 public static double?ApiRateCalculatorGetAmountInBaseWithProfileByAssetFromByAssetToByAmountPost(this IRateCalculatorAPI operations, string assetFrom, string assetTo, double amount, MarketProfile marketProfile = default(MarketProfile))
 {
     return(operations.ApiRateCalculatorGetAmountInBaseWithProfileByAssetFromByAssetToByAmountPostAsync(assetFrom, assetTo, amount, marketProfile).GetAwaiter().GetResult());
 }
 public static IEnumerable <ApiMarketData> ToApiModel(this IEnumerable <IMarketData> marketData,
                                                      MarketProfile marketProfile)
 {
     return(marketData.Select(x => x.ToApiModel(marketProfile.Profile.First(y => y.Asset == x.AssetPairId))));
 }
 public static IEnumerable <ApiAssetPairRateModel> ToApiModel(this MarketProfile marketProfile)
 {
     return(marketProfile.Profile.Select(x => x.ToApiModel()));
 }
Beispiel #21
0
        private ConversionResult GetMarketAmountInBase(OrderAction orderAction, IEnumerable <ILimitOrder> limitOrders, AssetWithAmount from,
                                                       string assetTo, IDictionary <string, IAsset> assetsDict, IEnumerable <IAssetPair> assetPairs, MarketProfile marketProfile)
        {
            var result    = new ConversionResult();
            var assetPair = assetPairs.PairWithAssets(from.AssetId, assetTo);

            if (!IsInputValid(from, assetTo, assetsDict) || assetPair == null)
            {
                result.SetResult(OperationResult.InvalidInputParameters);
                return(result);
            }

            if (from.AssetId == assetTo)
            {
                result.From  = result.To = from;
                result.Price = result.VolumePrice = 1;
                result.SetResult(OperationResult.Ok);
                return(result);
            }

            limitOrders = limitOrders.Where(x => x.AssetPairId == assetPair.Id).GetAsync(orderAction, assetPair.IsInverted(assetTo));

            double sum      = 0;
            double priceSum = 0;
            int    n        = 0;

            var neededSum = double.MaxValue;

            foreach (var order in limitOrders)
            {
                if (n != 0 && sum >= neededSum)
                {
                    break;
                }

                sum      += Math.Abs(order.Volume);
                priceSum += order.Price;
                n++;
                neededSum = from.Amount * GetRate(assetTo, assetPair, priceSum / n);
            }

            if (n == 0)
            {
                result.SetResult(OperationResult.NoLiquidity);
                return(result);
            }

            var price = priceSum / n;

            result.From = from;
            var rate        = GetRate(assetTo, assetPair, price);
            var displayRate = GetRate(from.AssetId, assetPair, price);

            result.To = new AssetWithAmount
            {
                AssetId = assetTo,
                Amount  = (rate * from.Amount).TruncateDecimalPlaces(assetsDict[assetTo].Accuracy, orderAction == OrderAction.Buy)
            };
            result.SetResult(sum < neededSum ? OperationResult.NoLiquidity : OperationResult.Ok);
            result.Price       = GetRate(from.AssetId, assetPair, marketProfile.GetPrice(assetPair.Id, orderAction).GetValueOrDefault());
            result.VolumePrice = displayRate;

            return(result);
        }
        // Full Audience
        public static long GetFullAudience(MarketProfile profile, int nicheId)
        {
            AudienceSize audienceSize = profile.AudienceSize;

            return(Randomise((long)audienceSize, nicheId));
        }
 public static int GetTechCost(MarketProfile profile, int nicheId)
 {
     return((int)Randomise((int)profile.AppComplexity, nicheId));
 }
        public async Task <double> GetAmountInBaseWithProfileAsync(string assetFrom, double amount, string assetTo, MarketProfile marketProfile)
        {
            try
            {
                return(await _service.ApiRateCalculatorGetAmountInBaseWithProfileByAssetFromByAssetToByAmountPostAsync(assetFrom, assetTo, amount, marketProfile) ?? 0);
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(RateCalculatorClient), nameof(GetAmountInBaseAsync), $"assetFrom = {assetFrom}, assetTo = {assetTo}, amount = {amount}", ex);
            }

            return(0);
        }
        public MarketProfile Profile()
        {
            var resp    = this.steam.Request(Urls.Market, Method.GET, Urls.Market, useAuthCookie: true, proxy: this.Proxy);
            var content = resp.Data.Content;

            var doc = new HtmlDocument();

            doc.LoadHtml(content);

            var userLoginNode = doc.DocumentNode.SelectSingleNode("//span[@id='market_buynow_dialog_myaccountname']");

            if (userLoginNode == null)
            {
                throw new SteamException("Unable to load profile");
            }

            var userLogin = userLoginNode.InnerText;

            var userIdMatch = Regex.Match(content, "(?<=g_steamID = \")(.*)(?=\";)").Value;

            if (string.IsNullOrEmpty(userIdMatch))
            {
                throw new SteamException("Unable to load profile (User ID)");
            }

            var userIdParse = long.TryParse(userIdMatch, out var userId);

            if (!userIdParse)
            {
                throw new SteamException("Unable to parse user ID)");
            }

            var userAvatarNode = doc.DocumentNode.SelectSingleNode("//span[@class='avatarIcon']");

            if (userAvatarNode == null)
            {
                throw new SteamException("Unable to load profile (User avatar node)");
            }

            var userAvatarImgNode = userAvatarNode.ChildNodes[1];

            if (userAvatarImgNode == null)
            {
                throw new SteamException("Unable to load profile (User avatar img node");
            }

            var userAvatarSrc = userAvatarImgNode.Attributes["src"].Value;

            if (string.IsNullOrEmpty(userAvatarSrc))
            {
                throw new SteamException("Unable to load profile (User avatar img source");
            }

            var walletInfoMatch = Regex.Match(content, "(?<=g_rgWalletInfo = )(.*)(?=;)").Value;

            if (string.IsNullOrEmpty(walletInfoMatch))
            {
                throw new SteamException("Unable to parse wallet info");
            }

            var walletInfo = this.WalletInfo(walletInfoMatch);

            var marketProfile = new MarketProfile
            {
                AvatarUrl  = userAvatarSrc,
                Id         = userId,
                Login      = userLogin,
                WalletInfo = walletInfo
            };

            return(marketProfile);
        }