Exemplo n.º 1
0
        private string GetAccountAlertBody(AccountInfoDTO accountInfoDTO, AccountAlertDTO accountAlertDTO)
        {
            var body = $"Account : {accountInfoDTO.AccountName} alert triggered! \n";

            body = body + $"account equity is {accountInfoDTO.AccountEquity} and the alert limit was {accountAlertDTO.MinBalance}";

            return(body);
        }
Exemplo n.º 2
0
        private string GetAccountStrategyAlertBody(AccountInfoDTO accountInfoDTO, AccountAlertDTO accountAlertDTO)
        {
            var body = $"Account : {accountInfoDTO.AccountName} alert triggered! \n";

            body = body + $". Strategy {accountAlertDTO.StrategyId} min balance was : {accountAlertDTO.MinBalance} exceeded for {accountAlertDTO.StrategyDaysToCheck} days";

            return(body);
        }
Exemplo n.º 3
0
        public void SendAccountStrategyAlert(AccountInfoDTO accountInfoDTO, AccountAlertDTO accountAlertDTO)
        {
            var client           = new SendGridClient(GetApiKey());
            var from             = new EmailAddress(GetSender());
            var subject          = GetAccountAlertSubject();
            var to               = new EmailAddress(GetReceiver());
            var plainTextContent = GetAccountStrategyAlertBody(accountInfoDTO, accountAlertDTO);
            var htmlContent      = "<strong>" + GetAccountStrategyAlertBody(accountInfoDTO, accountAlertDTO) + "</strong>";
            var msg              = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
            var response         = client.SendEmailAsync(msg);

            response.Wait();
        }
Exemplo n.º 4
0
        public AccountInfoDTO MapJsonStringToAccountDTO(string accountStr)
        {
            Dictionary <string, string> jsonMap = JsonConvert.DeserializeObject <Dictionary <string, string> >(accountStr);

            var accountDto = new AccountInfoDTO();

            accountDto.ApiKey            = jsonMap.GetValueOrDefault("apiKey");
            accountDto.AccountBalance    = Convert.ToDouble(jsonMap.GetValueOrDefault("accountBalance"));
            accountDto.AccountEquity     = Convert.ToDouble(jsonMap.GetValueOrDefault("accountEquity"));
            accountDto.AccountFreeMargin = Convert.ToDouble(jsonMap.GetValueOrDefault("accountFreeMargin"));

            return(accountDto);
        }
Exemplo n.º 5
0
        public int UpdateAccountInfo(AccountInfoDTO accountInfoDTO)
        {
            try
            {
                var sql = "update account_info set account_balance = @AccountBalance, account_equity = @AccountEquity, account_free_margin = @AccountFreeMargin where id = @Id";

                using (var connection = new SqlConnection(GetConnectionString()))
                {
                    var affectedRows = connection.Execute(sql, new
                    {
                        AccountBalance    = accountInfoDTO.AccountBalance,
                        AccountEquity     = accountInfoDTO.AccountEquity,
                        AccountFreeMargin = accountInfoDTO.AccountFreeMargin,
                        Id = accountInfoDTO.AccountId
                    });
                    return(affectedRows);
                }
            } catch (Exception e)
            {
                return(0);
            }
        }