Class AccountService
java.lang.Object
com.bluebell.greenhouse.radicle.services.AbstractGenericEntityService<Account, AccountRepository>
com.bluebell.greenhouse.radicle.services.account.AccountService
@Service
@Transactional(readOnly=true)
public class AccountService
extends AbstractGenericEntityService<Account, AccountRepository>
Service-layer for
Account entities.- Version:
- 3.0.6
- Author:
- Stephen Prizio
-
Constructor Summary
ConstructorsConstructorDescriptionAccountService(AccountRepository accountRepository, AccountLedgerService accountLedgerService, AccountDetailsService accountDetailsService, LocaleService localeService, PositionService positionService, PerformanceReportService performanceReportService, StrategyService strategyService, TransactionService transactionService, PositionImportService positionImportService, AccountServiceCollaborators collaborators) Creates the service. -
Method Summary
Modifier and TypeMethodDescriptioncreateNewAccount(CreateUpdateAccountDTO data, Portfolio portfolio) Creates a newAccountwith the given data.booleanDeletes the account a reference identifies.booleandeleteAccount(Account account) Deletes the givenAccount.findAccountByAccountNumber(String accountNumber, Broker broker, String username) Obtains anAccountfor the given account number, broker, and owner username.findOwnedAccount(String accountNumber, Long userId) Finds the account with the given number owned by the given user.generateAccountBalanceHistory(Account account, RecordTimeInterval timeInterval) Retrieves details for the account a reference identifies.getAccountDetails(Account account) Returns anAccountDetailsfor the givenAccount.intMarks staleAccounts as inactive.voidreassignAccounts(long portfolioNumber) Reassigns default accounts.refreshAccount(OwnedAccountRef ref, boolean ignoreStart) Refreshes the account a reference identifies.refreshAccount(Account account, boolean ignoreStart) Refreshes the givenAccount.Resolves the account a reference identifies.syncAccountsForStrategy(Strategy strategy, List<Account> accounts, User user) updateAccount(OwnedAccountRef ref, CreateUpdateAccountDTO data, Portfolio portfolio) Updates the account a reference identifies.updateAccount(Account account, CreateUpdateAccountDTO data, Portfolio portfolio) Updates an existingAccount.booleanUpdates the account imported position data with the given payload specifically for MT4 data.booleanupdateAccountPositionDataFromMT4(MT4AccountPositionDataDTO data, String strategyReferenceCode) Updates the account imported position data with the given payload specifically for MT4 data.updateAccountStrategy(OwnedAccountRef ref, String strategyUid) Assigns or removes a strategy on the account a reference identifies.updateAccountStrategy(Account account, String strategyUid) Assigns or removes a strategy on the givenAccount.intMoves accounts between portfolios owned by the authenticated user.Methods inherited from class AbstractGenericEntityService
refreshEntity, resolveEntity, resolveEntity, resolveEntity
-
Constructor Details
-
AccountService
public AccountService(AccountRepository accountRepository, AccountLedgerService accountLedgerService, AccountDetailsService accountDetailsService, LocaleService localeService, PositionService positionService, PerformanceReportService performanceReportService, StrategyService strategyService, TransactionService transactionService, PositionImportService positionImportService, AccountServiceCollaborators collaborators) Creates the service.- Parameters:
accountRepository-AccountRepositoryaccountLedgerService-AccountLedgerServiceaccountDetailsService-AccountDetailsServicelocaleService-LocaleServicepositionService-PositionServiceperformanceReportService-PerformanceReportServicestrategyService-StrategyServicetransactionService-TransactionServicepositionImportService-PositionImportServicecollaborators-AccountServiceCollaborators
-
-
Method Details
-
refreshAccount
-
getAccountDetails
Returns anAccountDetailsfor the givenAccount.- Parameters:
account-Account- Returns:
AccountDetails
-
findAccountByAccountNumber
-
resolveOwned
Resolves the account a reference identifies.- Parameters:
ref-OwnedAccountRef- Returns:
Account
-
getAccountDetails
Retrieves details for the account a reference identifies.- Parameters:
ref-OwnedAccountRef- Returns:
AccountDetails
-
refreshAccount
Refreshes the account a reference identifies.- Parameters:
ref-OwnedAccountRefignoreStart- whether to ignore the account start date- Returns:
- refreshed
Account
-
updateAccount
@Transactional public Account updateAccount(OwnedAccountRef ref, CreateUpdateAccountDTO data, Portfolio portfolio) Updates the account a reference identifies.- Parameters:
ref-OwnedAccountRefdata-CreateUpdateAccountDTOportfolio- owningPortfolio- Returns:
- updated
Account
-
updateAccountStrategy
Assigns or removes a strategy on the account a reference identifies.- Parameters:
ref-OwnedAccountRefstrategyUid- strategy uid, blank to remove- Returns:
- updated
Account
-
deleteAccount
Deletes the account a reference identifies.- Parameters:
ref-OwnedAccountRef- Returns:
- true when the account was deleted
-
findOwnedAccount
-
updateAccountStrategy
-
syncAccountsForStrategy
-
createNewAccount
Creates a newAccountwith the given data.- Parameters:
data-CreateUpdateAccountDTOportfolio-Portfolio- Returns:
- new
Account
-
updateAccount
@Transactional public Account updateAccount(Account account, CreateUpdateAccountDTO data, Portfolio portfolio) Updates an existingAccount.- Parameters:
account-Accountto updatedata-CreateUpdateAccountDTOportfolio-Portfolio- Returns:
- updated
Account
-
deleteAccount
-
reassignAccounts
@Transactional public void reassignAccounts(long portfolioNumber) Reassigns default accounts.- Parameters:
portfolioNumber- portfolio id of accounts to reassign
-
updatePortfolioAssignments
@Transactional public int updatePortfolioAssignments(UpdateAccountPortfolioAssignmentsDTO data, User user) Moves accounts between portfolios owned by the authenticated user. All account and destination portfolio references are resolved before any changes are applied so that the request is atomic.- Parameters:
data- requested account portfolio assignmentsuser- authenticated owner- Returns:
- number of accounts moved
-
updateAccountPositionDataFromMT4
Updates the account imported position data with the given payload specifically for MT4 data.- Parameters:
data-MT4AccountPositionDataDTO- Returns:
- true if successful update
-
updateAccountPositionDataFromMT4
@Transactional public boolean updateAccountPositionDataFromMT4(MT4AccountPositionDataDTO data, String strategyReferenceCode) Updates the account imported position data with the given payload specifically for MT4 data.- Parameters:
data-MT4AccountPositionDataDTOstrategyReferenceCode- optional default strategy reference code- Returns:
- true if successful update
-
invalidateStaleAccounts
@Transactional public int invalidateStaleAccounts()Marks staleAccounts as inactive. A stale account is one that has not been traded on within the lookback period. The default period is 1 year.- Returns:
- count of accounts changed
-
generateAccountBalanceHistory
public List<AccountBalanceHistory> generateAccountBalanceHistory(Account account, RecordTimeInterval timeInterval) - Parameters:
account-AccounttimeInterval-RecordTimeInterval- Returns:
ListofAccountBalanceHistory
-