test_class.declarator: PERCENT_OFFSET = offset(0.000000000001d)
test_class.modifier: private static final
test_class.original_string: private static final Offset<Double> PERCENT_OFFSET = offset(0.000000000001d);
test_class.type: Offset<Double>
test_class.var_name: PERCENT_OFFSET
test_class.declarator: portofolioService
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private PortofolioService portofolioService;
test_class.type: PortofolioService
test_class.var_name: portofolioService
test_class.declarator: portofolioRepo
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private PortofolioRepository portofolioRepo;
test_class.type: PortofolioRepository
test_class.var_name: portofolioRepo
test_class.file: trading-common/src/test/java/fr/ymanvieu/trading/common/portofolio/PortofolioServiceTest.java
test_class.identifier: PortofolioServiceTest
test_case.body: @Test
  	public void testGetPortofolio() {
  		String login = "user";
  
  		// FIXME add asserts
  
  		Portofolio result = portofolioService.getPortofolio(login);
  
  		assertThat(result.getPercentChange()).isCloseTo(13.47978618287961, PERCENT_OFFSET);
  		assertThat(result.getValueChange()).isCloseTo(922.8690277999999, PERCENT_OFFSET);
  
  		assertThat(result.getAssets()).extracting("symbol.code", "percentChange", "valueChange")
  				.containsExactlyInAnyOrder( //
  						tuple("UBI", -6.14999667, -184.4999), //
  						tuple("BRE", 39.33333333, 1180d), //
  						tuple("GBP", 5.54032065, 66.4838478));
  	}
test_case.class_method_signature: PortofolioServiceTest.testGetPortofolio()
test_case.full_signature: @Test public void testGetPortofolio()
test_case.identifier: testGetPortofolio
test_case.invocations: getPortofolio isCloseTo assertThat getPercentChange isCloseTo assertThat getValueChange containsExactlyInAnyOrder extracting assertThat getAssets tuple tuple tuple
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetPortofolio()
focal_class.declarator: userRepo
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private UserRepository userRepo;
focal_class.type: UserRepository
focal_class.var_name: userRepo
focal_class.declarator: portofolioRepo
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private PortofolioRepository portofolioRepo;
focal_class.type: PortofolioRepository
focal_class.var_name: portofolioRepo
focal_class.declarator: symbolRepo
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private SymbolRepository symbolRepo;
focal_class.type: SymbolRepository
focal_class.var_name: symbolRepo
focal_class.declarator: rateService
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private RateService rateService;
focal_class.type: RateService
focal_class.var_name: rateService
focal_class.declarator: symbolMapper
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private SymbolMapper symbolMapper;
focal_class.type: SymbolMapper
focal_class.var_name: symbolMapper
focal_class.file: trading-common/src/main/java/fr/ymanvieu/trading/common/portofolio/PortofolioService.java
focal_class.identifier: PortofolioService
focal_class.class_method_signature: PortofolioService.createPortofolio(String login, String baseCurrencyCode, int baseCurrencyAmount)
focal_class.full_signature: public Portofolio createPortofolio(String login, String baseCurrencyCode, int baseCurrencyAmount)
focal_class.identifier: createPortofolio
focal_class.modifiers: public
focal_class.parameters: (String login, String baseCurrencyCode, int baseCurrencyAmount)
focal_class.return: Portofolio
focal_class.signature: Portofolio createPortofolio(String login, String baseCurrencyCode, int baseCurrencyAmount)
focal_class.class_method_signature: PortofolioService.getBaseCurrency(String login)
focal_class.full_signature: public AssetInfo getBaseCurrency(String login)
focal_class.identifier: getBaseCurrency
focal_class.modifiers: public
focal_class.parameters: (String login)
focal_class.return: AssetInfo
focal_class.signature: AssetInfo getBaseCurrency(String login)
focal_class.class_method_signature: PortofolioService.getPortofolio(String login)
focal_class.full_signature: public Portofolio getPortofolio(String login)
focal_class.identifier: getPortofolio
focal_class.modifiers: public
focal_class.parameters: (String login)
focal_class.return: Portofolio
focal_class.signature: Portofolio getPortofolio(String login)
focal_class.class_method_signature: PortofolioService.getAsset(AssetEntity ae)
focal_class.full_signature: protected AssetInfo getAsset(AssetEntity ae)
focal_class.identifier: getAsset
focal_class.modifiers: protected
focal_class.parameters: (AssetEntity ae)
focal_class.return: AssetInfo
focal_class.signature: AssetInfo getAsset(AssetEntity ae)
focal_class.class_method_signature: PortofolioService.getOrderInfo(String login, String symbolCode, double quantity)
focal_class.full_signature: public OrderInfo getOrderInfo(String login, String symbolCode, double quantity)
focal_class.identifier: getOrderInfo
focal_class.modifiers: public
focal_class.parameters: (String login, String symbolCode, double quantity)
focal_class.return: OrderInfo
focal_class.signature: OrderInfo getOrderInfo(String login, String symbolCode, double quantity)
focal_class.class_method_signature: PortofolioService.getAvailableSymbols(String login)
focal_class.full_signature: public List<Symbol> getAvailableSymbols(String login)
focal_class.identifier: getAvailableSymbols
focal_class.modifiers: public
focal_class.parameters: (String login)
focal_class.return: List<Symbol>
focal_class.signature: List<Symbol> getAvailableSymbols(String login)
focal_class.class_method_signature: PortofolioService.buy(String login, String code, double quantity)
focal_class.full_signature: public Order buy(String login, String code, double quantity)
focal_class.identifier: buy
focal_class.modifiers: public
focal_class.parameters: (String login, String code, double quantity)
focal_class.return: Order
focal_class.signature: Order buy(String login, String code, double quantity)
focal_class.class_method_signature: PortofolioService.sell(String login, String code, double quantity)
focal_class.full_signature: public Order sell(String login, String code, double quantity)
focal_class.identifier: sell
focal_class.modifiers: public
focal_class.parameters: (String login, String code, double quantity)
focal_class.return: Order
focal_class.signature: Order sell(String login, String code, double quantity)
focal_method.body: public Portofolio getPortofolio(String login) {
  		PortofolioEntity portofolio = portofolioRepo.findByUserUsername(login);
  
  		AssetInfo baseCurrencyAsset = new AssetInfo(portofolio.getBaseCurrency(), null, portofolio.getAmount().doubleValue());
  		
  		List<AssetInfo> assets = new ArrayList<>();
  
  		double globalBaseCurrencyValueChange = 0f;
  		double globalBaseCurrencyInvestedValue = 0f;
  
  		for (AssetEntity ae : portofolio.getAssets()) {
  
  			AssetInfo asset = getAsset(ae);
  
  			String currencyCode = asset.getCurrency().getCode();
  
  			BigDecimal assetCurrencyToBaseCurrencyRate = rateService.getLatest(currencyCode, portofolio.getBaseCurrency().getCode()).getValue();
  			BigDecimal baseCurrencyValueChange = assetCurrencyToBaseCurrencyRate.multiply(BigDecimal.valueOf(asset.getValueChange()));
  			BigDecimal baseCurrencyInvestedValue = assetCurrencyToBaseCurrencyRate.multiply(BigDecimal.valueOf(asset.getValue()));
  
  			globalBaseCurrencyValueChange += baseCurrencyValueChange.doubleValue();
  			globalBaseCurrencyInvestedValue += baseCurrencyInvestedValue.doubleValue();
  
  			assets.add(asset);
  		}
  
  		double globalPercentChange = 0;
  
  		if (globalBaseCurrencyInvestedValue != 0) {
  			globalPercentChange = globalBaseCurrencyValueChange / globalBaseCurrencyInvestedValue * 100d;
  		}
  
  		double globalBaseCurrencyValue = globalBaseCurrencyInvestedValue + globalBaseCurrencyValueChange;
  
  		return new Portofolio(baseCurrencyAsset, assets, globalBaseCurrencyValue, globalPercentChange, globalBaseCurrencyValueChange);
  	}
focal_method.class_method_signature: PortofolioService.getPortofolio(String login)
focal_method.full_signature: public Portofolio getPortofolio(String login)
focal_method.identifier: getPortofolio
focal_method.invocations: findByUserUsername getBaseCurrency doubleValue getAmount getAssets getAsset getCode getCurrency getValue getLatest getCode getBaseCurrency multiply valueOf getValueChange multiply valueOf getValue doubleValue doubleValue add
focal_method.modifiers: public
focal_method.parameters: (String login)
focal_method.return: Portofolio
focal_method.signature: Portofolio getPortofolio(String login)