public async Task <ProfitAndLoss> GetPnLInfo(string ccy1, string ccy2)
        {
            var tradesForPair = _databaseService.GetTradesForPair(ccy1, ccy2);
            var profitAndLoss = ProfitCalculator.GetProfitAndLossForPair(tradesForPair, ccy1, ccy2);

            var dollarAmount = await _priceService.GetDollarAmount(profitAndLoss.Profit);

            profitAndLoss.DollarProfit = dollarAmount;

            _databaseService.SaveProfitAndLoss(profitAndLoss);

            return(profitAndLoss);
        }
        public async Task <ProfitAndLoss> GetPnLInfo(string ccy1, string ccy2, string exchange)
        {
            var tradesForPair = await _databaseService.GetTradesForPair(ccy1, ccy2);

            var profitAndLoss = ProfitCalculator.GetProfitAndLossForPair(tradesForPair, new Currency {
                Base = ccy1, Terms = ccy2
            });

            var dollarAmount = await _priceService.GetDollarAmount(ccy1, profitAndLoss.Profit, exchange);

            profitAndLoss.DollarProfit = dollarAmount;

            await _databaseService.SaveProfitAndLoss(profitAndLoss);

            return(profitAndLoss);
        }
Beispiel #3
0
        public async Task <ProfitAndLoss> GetPnLInfo(string ccy1, string ccy2)
        {
            var tradesForPair = await _databaseService.GetTradesForPair(ccy1, ccy2);

            var profitAndLoss = ProfitCalculator.GetProfitAndLossForPair(tradesForPair, new Currency {
                Base = ccy1, Terms = ccy2
            });

            // TODO: Ideally use each trade's exchange to get dollar amounts
            var dollarAmount = await _priceService.GetDollarAmount(ccy1, profitAndLoss.Profit, Constants.Bittrex);

            profitAndLoss.DollarProfit = dollarAmount;

            await _databaseService.SaveProfitAndLoss(profitAndLoss);

            return(profitAndLoss);
        }
Beispiel #4
0
        public async Task <ProfitAndLoss> GetPnLInfo(string ccy1, string ccy2, string exchange)
        {
            var tradesForPair = await _databaseService.GetTradesForPair(ccy1, ccy2);

            var profitAndLoss = ProfitCalculator.GetProfitAndLossForPair(tradesForPair, new Currency {
                Base = ccy1, Terms = ccy2
            });

            var reportingCurrency = _config.ReportingCurrency;
            var reportingAmount   = await _priceService.GetReportingAmount(ccy1, profitAndLoss.Profit, reportingCurrency, exchange);

            profitAndLoss.ReportingProfit   = reportingAmount;
            profitAndLoss.ReportingCurrency = reportingCurrency;

            await _databaseService.SaveProfitAndLoss(profitAndLoss);

            return(profitAndLoss);
        }