예제 #1
0
 public WalletManager4Pamm(ProtectedOperationContext secCtx,
                           string login, int accountId)
 {
     this.secCtx = secCtx;
     this.login = login;
     this.accountId = accountId;
 }
 public AuthenticationResponse ChangePassword(ProtectedOperationContext ctx, string login, string newPassword)
 {
     try
     {
         if (UserOperationRightsStorage.IsProtectedOperation(UserOperation.ChangeAccountSettings))
             if (!UserSessionStorage.Instance.PermitUserOperation(ctx,
                 UserOperationRightsStorage.IsTradeOperation(UserOperation.ChangeAccountSettings), false))
                 return AuthenticationResponse.NotAuthorized;
     }
     catch (Exception ex)
     {
         Logger.ErrorFormat("Ошибка в AuthenticationResponse({0}): {1}", login, ex);
         return AuthenticationResponse.ServerError;
     }
     using (var dbContext = DatabaseContext.Instance.Make())
     {
         try
         {
             var user = dbContext.PLATFORM_USER.FirstOrDefault(u => u.Login == login);
             if (user == null) return AuthenticationResponse.InvalidAccount;
             user.Password = newPassword;
             dbContext.SaveChanges();
         }
         catch (Exception ex)
         {
             Logger.ErrorFormat("Ошибка в ChangePassword({0}) : {1}", login, ex);
             return AuthenticationResponse.ServerError;
         }
     }
     return AuthenticationResponse.OK;
 }
        public RequestStatus UnsubscribePortfolio(ProtectedOperationContext secCtx,
                                                  string subscriberLogin, bool deletePortfolio, bool deleteSubscriptions)
        {
            if (UserOperationRightsStorage.IsProtectedOperation(UserOperation.GetAccountDetail))
                if (
                    !UserSessionStorage.Instance.PermitUserOperation(secCtx,
                                                                     UserOperationRightsStorage.IsTradeOperation(
                                                                         UserOperation.BindToSignal), false))
                    return RequestStatus.Unauthorized;

            using (var ctx = DatabaseContext.Instance.Make())
                return walletRepository.UnsubscribeUserFromPortfolio(ctx, subscriberLogin, deletePortfolio, deleteSubscriptions);
        }
예제 #4
0
 public bool DisableService(ProtectedOperationContext ctx, int serviceId, out WalletError error)
 {
     error = WalletError.OK;
     if (Channel == null)
         throw new Exception("WalletManagerProxy: связь не установлена");
     try
     {
         return Channel.DisableService(ctx, serviceId, out error);
     }
     catch
     {
         RenewFactory();
         try
         {
             return Channel.DisableService(ctx, serviceId, out error);
         }
         catch (Exception ex2)
         {
             Logger.Error("DisableService() error: ", ex2);
             return false;
         }
     }
 }
 public RequestStatus ApplyPortfolioTradeSettings(ProtectedOperationContext secCtx, string login,
                                                  AutoTradeSettings sets)
 {
     if (UserOperationRightsStorage.IsProtectedOperation(UserOperation.BindToSignal))
         if (!UserSessionStorage.Instance.PermitUserOperation(secCtx,
             UserOperationRightsStorage.IsTradeOperation(UserOperation.BindToSignal), false))
             return RequestStatus.Unauthorized;
     try
     {
         using (var ctx = DatabaseContext.Instance.Make())
         {
             var user = ctx.PLATFORM_USER.FirstOrDefault(u => u.Login == login);
             if (user == null)
                 return RequestStatus.Unauthorized;
             var subsription = ctx.USER_TOP_PORTFOLIO.FirstOrDefault(u => u.User == user.ID);
             if (subsription == null)
                 return RequestStatus.CommonError;
             subsription.AutoTrade = sets.TradeAuto;
             subsription.MaxLeverage = sets.MaxLeverage;
             subsription.PercentLeverage = sets.PercentLeverage;
             subsription.HedgingOrdersEnabled = sets.HedgingOrdersEnabled;
             subsription.FixedVolume = sets.FixedVolume;
             subsription.MinVolume = sets.MinVolume;
             subsription.MaxVolume = sets.MaxVolume;
             subsription.VolumeRound = (int?) sets.VolumeRound;
             subsription.StepVolume = sets.StepVolume;
             subsription.TargetAccount = sets.TargetAccount;
             ctx.SaveChanges();
             return RequestStatus.OK;
         }
     }
     catch (Exception ex)
     {
         Logger.Error("Ошибка в ApplyPortfolioTradeSettings()", ex);
         return RequestStatus.ServerError;
     }
 }
        /// <summary>
        /// подписать на портфель
        /// отключить остальные подписки
        /// если портфель пользовательский - сохранить его
        /// </summary>
        public RequestStatus SubscribeOnPortfolio(
            ProtectedOperationContext secCtx,
            string subscriberLogin,
            TopPortfolio portfolio,
            decimal? maxFee,
            AutoTradeSettings tradeAutoSettings)
        {
            //Logger.InfoFormat("SubscribeOnPortfolio({0})", subscriberLogin);
            if (UserOperationRightsStorage.IsProtectedOperation(UserOperation.BindToSignal))
                if (!UserSessionStorage.Instance.PermitUserOperation(secCtx,
                    UserOperationRightsStorage.IsTradeOperation(UserOperation.BindToSignal), false))
                        return RequestStatus.Unauthorized;

            try
            {
                using (var ctx = DatabaseContext.Instance.Make())
                    return walletRepository.SubscribeUserOnPortfolio(ctx, subscriberLogin, portfolio, maxFee, tradeAutoSettings);
            }
            catch (Exception ex)
            {
                Logger.Error("Ошибка в SubscribeOnPortfolio()", ex);
                return RequestStatus.ServerError;
            }
        }
예제 #7
0
 public WalletError ChangePaymentSystemWallets(ProtectedOperationContext ctx, UserPaymentSystem paySys,
                                               bool remove,
                                               string userLogin, string walletPwrd)
 {
     if (Channel == null)
         throw new Exception("WalletManagerProxy: связь не установлена");
     try
     {
         return Channel.ChangePaymentSystemWallets(ctx, paySys, remove, userLogin, walletPwrd);
     }
     catch
     {
         RenewFactory();
         try
         {
             return Channel.ChangePaymentSystemWallets(ctx, paySys, remove, userLogin, walletPwrd);
         }
         catch (Exception ex2)
         {
             Logger.Error("ChangePaymentSystemWallets() error: ", ex2);
             return WalletError.CommonError;
         }
     }
 }
예제 #8
0
 public override RequestStatus SendCloseRequest(ProtectedOperationContext ctx, int accountId, int orderId, PositionExitReason reason)
 {
     return proxyTrade.proxy.SendCloseRequest(ctx, accountId, orderId, reason);
 }
예제 #9
0
 public override RequestStatus SendEditMarketRequest(ProtectedOperationContext secCtx, MarketOrder pos)
 {
     if (IsDayOff()) return RequestStatus.WrongTime;
     return base.SendEditMarketRequest(secCtx, pos);
 }
예제 #10
0
 public override RequestStatus SendNewOrderRequest(ProtectedOperationContext secCtx, int requestUniqueId, MarketOrder order,
     OrderType orderType, decimal requestedPrice, decimal slippagePoints)
 {
     if (IsDayOff()) return RequestStatus.WrongTime;
     return base.SendNewOrderRequest(secCtx, requestUniqueId, order, orderType, requestedPrice, slippagePoints);
 }
예제 #11
0
 public override RequestStatus SendCloseByTickerRequest(ProtectedOperationContext ctx, int accountId,
                                                        string ticker, PositionExitReason reason)
 {
     return proxyTrade.proxy.SendCloseByTickerRequest(ctx, accountId, ticker, reason);
 }
예제 #12
0
 public abstract RequestStatus SendEditPendingRequest(ProtectedOperationContext secCtx, PendingOrder ord);
예제 #13
0
 public override RequestStatus SendEditPendingRequest(ProtectedOperationContext secCtx, PendingOrder ord)
 {
     return proxyTrade.proxy.SendEditPendingRequest(secCtx, ord);
 }
예제 #14
0
 public override RequestStatus SendNewPendingOrderRequest(
     ProtectedOperationContext ctx,
     int requestUniqueId,
     PendingOrder order)
 {
     return proxyTrade.proxy.SendNewPendingOrderRequest(ctx, requestUniqueId, order);
 }
예제 #15
0
 public List<Transfer> GetAccountTransfersPartByPart(ProtectedOperationContext secCtx,
     string login, int startId, int countMax)
 {
     throw new NotImplementedException();
 }
예제 #16
0
 public abstract RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext ctx,
     PendingOrder order, PendingOrderStatus status, int? positionId, string closeReason);
예제 #17
0
 public RequestStatus ApplyPortfolioTradeSettings(ProtectedOperationContext secCtx, string login, AutoTradeSettings sets)
 {
     throw new NotImplementedException();
 }
예제 #18
0
 public List<AccountShare> GetAccountShares(ProtectedOperationContext secCtx, int accountId, bool needMoneyShares)
 {
     throw new NotImplementedException();
 }
예제 #19
0
 public virtual void SendTradeSignalEvent(ProtectedOperationContext ctx, int accountId, int tradeSignalCategory,
     UserEvent acEvent)
 {
     Logger.InfoFormat("Текстовое сообщение робота: [{0:dd.MM.yyyy HH:mm}] {1} {2} {3}",
         acEvent.Time, acEvent.Code, acEvent.Title, acEvent.Text);
 }
예제 #20
0
 public abstract RequestStatus SendNewPendingOrderRequest(ProtectedOperationContext ctx,
                                                          int requestUniqueId, PendingOrder order);
예제 #21
0
 public abstract RequestStatus SendNewOrderRequest(ProtectedOperationContext secCtx,
     int requestUniqueId,
     MarketOrder order,
     OrderType orderType,
     decimal requestedPrice,
     decimal slippagePoints);
예제 #22
0
 public override RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext ctx,
     PendingOrder order, PendingOrderStatus status, int? positionId, string closeReason)
 {
     return proxyTrade.proxy.SendDeletePendingOrderRequest(ctx, order, status, positionId, closeReason);
 }
 public void ReviveChannel(ProtectedOperationContext ctx, string login, int accountId, string terminalVersion)
 {
     string address;
     var clientCallback = GetContextParams(out address);
     UserSessionStorage.Instance.ReviveChannel(ctx, clientCallback, address, login, accountId, terminalVersion);
 }
예제 #24
0
 public override RequestStatus SendEditMarketRequest(ProtectedOperationContext secCtx, MarketOrder pos)
 {
     return proxyTrade.proxy.SendEditMarketRequest(secCtx, pos);
 }
예제 #25
0
 public static bool IsServerContext(ProtectedOperationContext ctx)
 {
     return(ctx.userMachineName == "server#" && ctx.terminalId == long.MaxValue);
 }
예제 #26
0
 public override RequestStatus SendNewOrderRequest(
     ProtectedOperationContext secCtx,
     int requestUniqueId,
     MarketOrder order,
     OrderType orderType,
     decimal requestedPrice,
     decimal slippagePoints)
 {
     return proxyTrade.proxy.SendNewOrderRequest(
         secCtx,
         requestUniqueId, order, orderType, requestedPrice, slippagePoints);
 }
예제 #27
0
 public override RequestStatus SendCloseByTickerRequest(ProtectedOperationContext ctx, int accountId, string ticker, PositionExitReason reason)
 {
     if (IsDayOff()) return RequestStatus.WrongTime;
     return base.SendCloseByTickerRequest(ctx, accountId, ticker, reason);
 }
예제 #28
0
 public override void SendTradeSignalEvent(ProtectedOperationContext ctx, int accountId,
     int tradeSignalCategory, UserEvent acEvent)
 {
     try
     {
         proxyTrade.proxy.SendTradeSignalEvent(ctx, accountId, tradeSignalCategory, acEvent);
     }
     catch (Exception ex)
     {
         Logger.ErrorFormat("Ошибка в SendTradeSignalEvent(acc: {0}, cat: {1}): {2}",
             accountId, tradeSignalCategory, ex);
     }
 }
예제 #29
0
 public override RequestStatus SendCloseRequest(ProtectedOperationContext ctx, int accountId, int orderId, PositionExitReason reason)
 {
     if (IsDayOff()) return RequestStatus.WrongTime;
     return base.SendCloseRequest(ctx, accountId, orderId, reason);
 }
 public void Logout(ProtectedOperationContext ctx)
 {
     UserSessionStorage.Instance.Logout(ctx);
 }
예제 #31
0
 public abstract RequestStatus SendEditMarketRequest(ProtectedOperationContext secCtx, MarketOrder pos);