public EntityResponse SetAutomaticOptionExercisingParameters(CustomerAutomaticOptionExercisingInformation information)
        {
            if (string.IsNullOrWhiteSpace(information.CustomerAccountCode))
            {
                return(EntityResponse <List <CustomerAutomaticOptionExercisingInformation> > .Error(
                           ErrorCode.SZKingdomLibraryError,
                           ErrorMessages.SZKingdom_CustomerCodeEmpty));
            }

            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.CustomerCode(information.CustomerCode));
            arguments.Add(SZKingdomArgument.CustomerAccountCode(information.CustomerAccountCode));
            arguments.Add(SZKingdomArgument.StockBoard(information.TradeSector));
            arguments.Add(SZKingdomArgument.TradeAccount(information.TradingAccount));

            arguments.Add(SZKingdomArgument.ExercisingQuantity(information.ExercisingQuantity));
            arguments.Add(SZKingdomArgument.AutomaticExerciseControl(information.AutomaticExcerciseControl));
            arguments.Add(SZKingdomArgument.ExercisingStrategyType(information.ExercisingStrategyType));
            arguments.Add(SZKingdomArgument.ExercisingStrategyValue(information.ExercisingStrategyValue));
            arguments.Add(SZKingdomArgument.OptionNumber(information.ContractNumber));
            arguments.Add(SZKingdomArgument.Remark(information.Remark));

            EntityResponse result =
                _marketDataLibrary.ExecuteCommand(SZKingdomRequest.SetAutomaticOptionExercisingParameters, arguments);

            return(result);
        }
Example #2
0
        public EntityResponse <List <IntradayOptionOrderBasicInformation> > GetCancellableOrders(IntradayOptionOrderArguments intradayOrderArguments)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            if (intradayOrderArguments.CustomerCode == null && intradayOrderArguments.CustomerAccountCode == null)
            {
                EntityResponse <List <IntradayOptionOrderBasicInformation> > entityRespose = EntityResponse <List <IntradayOptionOrderBasicInformation> >
                                                                                             .Error(ErrorCode.SZKingdomLibraryError, SameCodesErrorMessage);

                return(entityRespose);
            }

            arguments.Add(SZKingdomArgument.CustomerCode(intradayOrderArguments.CustomerCode));
            arguments.Add(SZKingdomArgument.CustomerAccountCode(intradayOrderArguments.CustomerAccountCode));
            arguments.Add(SZKingdomArgument.StockBoard(intradayOrderArguments.StockBoard));
            arguments.Add(SZKingdomArgument.TradeAccount(intradayOrderArguments.TradeAccount));
            arguments.Add(SZKingdomArgument.OptionNumber(intradayOrderArguments.OptionNumber));
            arguments.Add(SZKingdomArgument.OptionUnderlyingCode(intradayOrderArguments.OptionUnderlyingCode));
            arguments.Add(SZKingdomArgument.OrderId(intradayOrderArguments.OrderId));
            arguments.Add(SZKingdomArgument.QueryPosition(intradayOrderArguments.QueryPosition));

            EntityResponse <List <IntradayOptionOrderBasicInformation> > result = _marketDataLibrary
                                                                                  .ExecuteCommandList <IntradayOptionOrderBasicInformation>(SZKingdomRequest.CancelableOptionOrders, arguments);

            return(result);
        }
        public EntityResponse <List <CustomerAutomaticOptionExercisingInformation> > GetAutomaticOptionExercisingParameters(string customerCode, string customerAccountCode, string tradeSector, string tradeAccount, List <string> optionNumbers)
        {
            if (string.IsNullOrWhiteSpace(customerAccountCode))
            {
                return(EntityResponse <List <CustomerAutomaticOptionExercisingInformation> > .Error(
                           ErrorCode.SZKingdomLibraryError,
                           ErrorMessages.SZKingdom_CustomerCodeEmpty));
            }
            List <CustomerAutomaticOptionExercisingInformation> result = new List <CustomerAutomaticOptionExercisingInformation>();

            foreach (string optionNumber in optionNumbers)
            {
                var arguments = new List <SZKingdomArgument>();
                arguments.Add(SZKingdomArgument.CustomerAccountCode(customerAccountCode));

                arguments.Add(SZKingdomArgument.OptionNumber(optionNumber));

                EntityResponse <CustomerAutomaticOptionExercisingInformation> item =
                    _marketDataLibrary.ExecuteCommandSingleEntity <CustomerAutomaticOptionExercisingInformation>(SZKingdomRequest.AutomaticOptionExercisingParameters, arguments);
                if (item.Entity == null)
                {
                    item = EntityResponse <CustomerAutomaticOptionExercisingInformation> .Success(
                        new CustomerAutomaticOptionExercisingInformation()
                    {
                        ContractNumber     = optionNumber,
                        ExercisingQuantity = 0
                    });
                }

                result.Add(item);
            }

            return(result);
        }
Example #4
0
        public EntityResponse <List <HistoricalOptionTradeInformation> > GetHistoricalOptionTrades(HistoricalOptionOrdersArguments historicalOrderArguments)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            if (historicalOrderArguments.CustomerCode == null && historicalOrderArguments.CustomerAccountCode == null)
            {
                EntityResponse <List <HistoricalOptionTradeInformation> > entityResponse = EntityResponse <List <HistoricalOptionTradeInformation> >
                                                                                           .Error(ErrorCode.SZKingdomLibraryError, SameCodesErrorMessage);

                return(entityResponse);
            }

            arguments.Add(SZKingdomArgument.CustomerCode(historicalOrderArguments.CustomerCode));
            arguments.Add(SZKingdomArgument.CustomerAccountCode(historicalOrderArguments.CustomerAccountCode));
            arguments.Add(SZKingdomArgument.StockBoard(historicalOrderArguments.StockBoard));
            arguments.Add(SZKingdomArgument.TradeAccount(historicalOrderArguments.TradeAccount));
            arguments.Add(SZKingdomArgument.OptionNumber(historicalOrderArguments.OptionNumber));
            arguments.Add(SZKingdomArgument.OptionUnderlyingCode(historicalOrderArguments.OptionUnderlyingCode));
            arguments.Add(SZKingdomArgument.OrderId(historicalOrderArguments.OrderId));
            arguments.Add(SZKingdomArgument.OrderBatchSerialNo(historicalOrderArguments.OrderBatchSerialNo));
            arguments.Add(SZKingdomArgument.BeginDate(historicalOrderArguments.BeginDate.ToString(SZKingdomMappingHelper.SZKingdomDateFormat)));
            arguments.Add(SZKingdomArgument.EndDate(historicalOrderArguments.EndDate.ToString(SZKingdomMappingHelper.SZKingdomDateFormat)));
            arguments.Add(SZKingdomArgument.PageNumber(historicalOrderArguments.PageNumber));
            arguments.Add(SZKingdomArgument.PageRecordCount(historicalOrderArguments.PageRecordCount));

            EntityResponse <List <HistoricalOptionTradeInformation> > result = _marketDataLibrary
                                                                               .ExecuteCommandList <HistoricalOptionTradeInformation>(SZKingdomRequest.HistoricalOptionTrades, arguments);

            return(result);
        }
        public EntityResponse <List <OptionPositionInformation> > GetOptionPositions(OptionPositionsArguments optionPositionsArguments)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            if (optionPositionsArguments.CustomerCode == null && optionPositionsArguments.CustomerAccountCode == null)
            {
                return(EntityResponse <List <OptionPositionInformation> > .Error(
                           ErrorCode.SZKingdomLibraryError,
                           ErrorMessages.SZKingdom_CustAndAccCodeNull));
            }

            arguments.Add(SZKingdomArgument.CustomerCode(optionPositionsArguments.CustomerCode));
            arguments.Add(SZKingdomArgument.CustomerAccountCode(optionPositionsArguments.CustomerAccountCode));
            arguments.Add(SZKingdomArgument.TradeAccount(optionPositionsArguments.TradeAccount));
            arguments.Add(SZKingdomArgument.OptionNumber(optionPositionsArguments.OptionNumber));
            arguments.Add(SZKingdomArgument.TradeUnit(optionPositionsArguments.TradeUnit));
            arguments.Add(SZKingdomArgument.OptionSide(optionPositionsArguments.OptionSide));
            arguments.Add(SZKingdomArgument.OptionCoveredFlag(optionPositionsArguments.OptionCoveredFlag));
            arguments.Add(SZKingdomArgument.QueryPosition(optionPositionsArguments.QueryPosition));

            EntityResponse <List <OptionPositionInformation> > result =
                _marketDataLibrary.ExecuteCommandList <OptionPositionInformation>(SZKingdomRequest.OptionPositions, arguments);

            return(result);
        }
 public EntityResponse <List <SecurityInformation> > GetSecuritiesInformation(StockBoard stockBoard = null, string securityCode = null)
 {
     try
     {
         List <SZKingdomArgument> arguments = new List <SZKingdomArgument>
         {
             SZKingdomArgument.StockBoard(stockBoard),
             SZKingdomArgument.SecurityCode(securityCode)
         };
         var retFromKingdom = _marketDataLibrary.ExecuteCommandList <SecurityInformation>(SZKingdomRequest.SecuritiesInformation, arguments);
         EntityResponse <List <SecurityInformation> > result = CheckForEmptyResult(retFromKingdom);
         //EntityResponse<List<SecurityInformation>> result =
         //    CheckForEmptyResult(_marketDataLibrary.ExecuteCommandList<SecurityInformation>(SZKingdomRequest.SecuritiesInformation, arguments));
         if (securityCode != null && result.IsSuccess && result.Entity.Count != 1)
         {
             Logging.Logger.Debug("thread ID:" + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + ", GetSecuritiesInformation return SZKingdomLibraryNoRecords," + ", class is MarketDataProvider");
             return(ErrorCode.SZKingdomLibraryNoRecords);
         }
         return(result);
     }
     catch (Exception ex)
     {
         Logging.Logger.Debug("thread ID:" + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + "Exception is" + ex.StackTrace.ToString() + ", class is MarketDataProvider");
         return(null);
     }
 }
        public EntityResponse <UserLoginInformation> UserLogin(LoginAccountType accountType, string accountId, string password, PasswordUseScope useScope)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.LoginAccountType(accountType));
            arguments.Add(SZKingdomArgument.LoginAccountId(accountId));
            arguments.Add(SZKingdomArgument.PasswordUseScpose(useScope));
            arguments.Add(SZKingdomArgument.AuthenticationData(_marketDataLibrary.EncryptPassword(accountId, password)));
            arguments.Add(SZKingdomArgument.EncryptionKey(accountId));
            arguments.Add(SZKingdomArgument.EncryptionType(EncryptionType.WinEncryption));
            arguments.Add(SZKingdomArgument.AuthenticationType(AuthenticationType.Password));             // password(0) is the only AUTH_TYPE

            EntityResponse <List <UserLoginInformation> > results =
                _marketDataLibrary.ExecuteCommandList <UserLoginInformation>(SZKingdomRequest.UserLogin, arguments);

            if (results.IsSuccess)
            {
                if (results.Entity.Count >= 1)
                {
                    UserLoginInformation result = results.Entity.First();                     //.Single(u => u.StockBoard == StockBoard.SHStockOptions);
                    return(result);
                }
                return(EntityResponse <UserLoginInformation> .Error(ErrorCode.AuthenticationIncorrectIdentity, string.Format(ErrorMessages.SZKingdom_Invalid_Account, accountId)));
            }
            return(EntityResponse <UserLoginInformation> .Error(results));
        }
        public EntityResponse <List <HistoricalFundTransfer> > GetHistoricalTransferFund(string customerAccountCode, string BeginDate, string EndDate, int qryPos, int qryNum)
        {
            var arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.CustomerAccountCode(customerAccountCode));
            arguments.Add(SZKingdomArgument.BeginDate(BeginDate));
            arguments.Add(SZKingdomArgument.EndDate(EndDate));
            arguments.Add(SZKingdomArgument.QueryNumer(qryNum));
            arguments.Add(SZKingdomArgument.QueryPosition(qryPos));


            EntityResponse <List <HistoricalFundTransfer> > results = _marketDataLibrary.ExecuteCommandList <HistoricalFundTransfer>(SZKingdomRequest.HistoricalFundTransfer, arguments);

            if (results.IsSuccess)
            {
                if (results.Entity.Count >= 1)
                {
                    List <HistoricalFundTransfer> resultList = (List <HistoricalFundTransfer>)results.Entity.OrderBy(u => u.OccurTime); // order by OccurTime to show

                    return(resultList);
                }
                return(EntityResponse <List <HistoricalFundTransfer> > .Error(ErrorCode.AuthenticationIncorrectIdentity, string.Format(ErrorMessages.InvalidDateRange, BeginDate, EndDate)));
            }
            return(EntityResponse <List <HistoricalFundTransfer> > .Error(results));
        }
        public EntityResponse <List <BankCodeInformation> > GetBankCodeInformation(string customerAccountCode, Currency currency)
        {
            var arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.CustomerAccountCode(customerAccountCode));
            arguments.Add(SZKingdomArgument.Currency(currency));

            return(_marketDataLibrary.ExecuteCommandList <BankCodeInformation>(SZKingdomRequest.GetBankCode, arguments));
        }
        public EntityResponse <QuotationInformation> GetQuotationInformation(string securityCode)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>
            {
                SZKingdomArgument.StockBoard(StockBoard.SHAShares),
                SZKingdomArgument.SecurityCode(securityCode)
            };

            EntityResponse <QuotationInformation> result =
                _marketDataLibrary.ExecuteCommandSingleEntity <QuotationInformation>(SZKingdomRequest.QuotationInformation, arguments);

            return(result);
        }
        public EntityResponse <List <OptionBasicInformation> > GetOptionBasicInformation(string underlyingCode = null, string optionNumber = null)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>
            {
                SZKingdomArgument.StockBoard(StockBoard.SHStockOptions),
                SZKingdomArgument.OptionNumber(optionNumber),
                SZKingdomArgument.OptionUnderlyingCode(underlyingCode)
            };
            EntityResponse <List <OptionBasicInformation> > result =
                CheckForEmptyResult(_marketDataLibrary.ExecuteCommandList <OptionBasicInformation>(SZKingdomRequest.OptionBasicInformation, arguments));

            return(result);
        }
        public EntityResponse <AccountInformation> GetAccountInformation(string customerCode, string customerAccountCode)
        {
            if (string.IsNullOrWhiteSpace(customerCode) && string.IsNullOrWhiteSpace(customerAccountCode))
            {
                return(EntityResponse <AccountInformation> .Error(
                           ErrorCode.SZKingdomLibraryError,
                           "Customer code and account code cannot be empty at the same time."));
            }

            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.CustomerCode(customerCode));
            arguments.Add(SZKingdomArgument.CustomerAccountCode(customerAccountCode));

            return(_marketDataLibrary.ExecuteCommandSingleEntity <AccountInformation>(SZKingdomRequest.GetAccountInformation, arguments));
        }
Example #13
0
        public EntityResponse <OrderMarginInformation> GetOptionOrderMargin(OrderMarginArguments orderArguments)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.CustomerAccountCode(orderArguments.CustomerAccountCode));
            arguments.Add(SZKingdomArgument.StockBoard(orderArguments.StockBoard));
            arguments.Add(SZKingdomArgument.Currency(orderArguments.Currency));
            arguments.Add(SZKingdomArgument.TradeAccount(orderArguments.TradeAccount));
            arguments.Add(SZKingdomArgument.OptionNumber(orderArguments.OptionNumber));
            arguments.Add(SZKingdomArgument.OrderQuantity(orderArguments.OrderQuantity));

            EntityResponse <OrderMarginInformation> result =
                _marketDataLibrary.ExecuteCommandSingleEntity <OrderMarginInformation>(SZKingdomRequest.OptionOrderMargin, arguments);

            return(result);
        }
        public EntityResponse <FundTransferSerialNo> TransferFund(TransferFundArguments transferArguments)
        {
            var arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.CustomerAccountCode(transferArguments.CustomerAccountCode));
            arguments.Add(SZKingdomArgument.Currency(transferArguments.Currency));
            arguments.Add(SZKingdomArgument.FundPassword(_marketDataLibrary.EncryptPassword(transferArguments.CustomerAccountCode, transferArguments.FundPassword)));
            arguments.Add(SZKingdomArgument.BankCode(transferArguments.BankCode));
            arguments.Add(SZKingdomArgument.BankPassword(_marketDataLibrary.EncryptPassword(transferArguments.CustomerAccountCode, transferArguments.BankPassword)));
            arguments.Add(SZKingdomArgument.TransferType(transferArguments.TransferType));
            arguments.Add(SZKingdomArgument.TransferAmount(transferArguments.TransferAmount));
            arguments.Add(SZKingdomArgument.EncryptionKey(transferArguments.CustomerAccountCode));
            arguments.Add(SZKingdomArgument.EncryptionType(EncryptionType.WinEncryption));
            arguments.Add(SZKingdomArgument.OperationRemark(transferArguments.OperationRemark));

            return(_marketDataLibrary.ExecuteCommandSingleEntity <FundTransferSerialNo>(SZKingdomRequest.FundTransfer, arguments));
        }
Example #15
0
        public EntityResponse <OptionOrderMaxQuantityInformation> GetOptionOrderMaxQuantity(OptionOrderMaxQuantityArguments maxQuantityArguments)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.CustomerCode(maxQuantityArguments.CustomerCode));
            arguments.Add(SZKingdomArgument.CustomerAccountCode(maxQuantityArguments.CustomerAccountCode));
            arguments.Add(SZKingdomArgument.TradeAccount(maxQuantityArguments.TradeAccount));
            arguments.Add(SZKingdomArgument.StockBoard(maxQuantityArguments.StockBoard));
            arguments.Add(SZKingdomArgument.StockBusiness(maxQuantityArguments.StockBusiness));
            arguments.Add(SZKingdomArgument.StockBusinessAction(maxQuantityArguments.StockBusinessAction));

            if (maxQuantityArguments.StockBusiness.In(OptionOrderBusinesses) && string.IsNullOrWhiteSpace(maxQuantityArguments.OptionNumber))
            {
                EntityResponse <OptionOrderMaxQuantityInformation> entityResponse = EntityResponse <OptionOrderMaxQuantityInformation> .Error(
                    ErrorCode.SZKingdomLibraryError,
                    ErrorMessages.SZKingdom_OptionNumberCanNotBeEmpty);

                return(entityResponse);
            }
            if (maxQuantityArguments.StockBusiness.In(StockOrderBusinesses) && string.IsNullOrWhiteSpace(maxQuantityArguments.SecurityCode))
            {
                EntityResponse <OptionOrderMaxQuantityInformation> entityResponse = EntityResponse <OptionOrderMaxQuantityInformation> .Error(
                    ErrorCode.SZKingdomLibraryError,
                    ErrorMessages.SZKingdom_StockCanNotBeEmpty);

                return(entityResponse);
            }
            arguments.Add(SZKingdomArgument.OptionNumber(maxQuantityArguments.OptionNumber));
            arguments.Add(SZKingdomArgument.SecurityCode(maxQuantityArguments.SecurityCode));


            if (maxQuantityArguments.StockBusiness.In(PriceNecessaryBusinesses) && maxQuantityArguments.OrderPrice == null)
            {
                EntityResponse <OptionOrderMaxQuantityInformation> entityResponse = EntityResponse <OptionOrderMaxQuantityInformation>
                                                                                    .Error(ErrorCode.SZKingdomLibraryError, ErrorMessages.SZKingdom_OrderPriceCanNotBeEmpty);

                return(entityResponse);
            }
            arguments.Add(SZKingdomArgument.OrderPrice(maxQuantityArguments.OrderPrice));


            EntityResponse <OptionOrderMaxQuantityInformation> result =
                _marketDataLibrary.ExecuteCommandSingleEntity <OptionOrderMaxQuantityInformation>(SZKingdomRequest.OptionOrderMaxQuantity, arguments);

            return(result);
        }
Example #16
0
        public EntityResponse <OptionOrderInformation> SubmitOptionOrder(OptionOrderArguments orderArguments)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.CustomerAccountCode(orderArguments.CustomerAccountCode));
            arguments.Add(SZKingdomArgument.StockBoard(orderArguments.StockBoard));
            arguments.Add(SZKingdomArgument.TradeAccount(orderArguments.TradeAccount));
            arguments.Add(SZKingdomArgument.OptionNumber(orderArguments.OptionNumber));
            arguments.Add(SZKingdomArgument.SecurityCode(orderArguments.SecurityCode));
            arguments.Add(SZKingdomArgument.OrderQuantity(orderArguments.OrderQuantity));
            arguments.Add(SZKingdomArgument.StockBusiness(orderArguments.StockBusiness));
            arguments.Add(SZKingdomArgument.StockBusinessAction(orderArguments.StockBusinessAction));
            arguments.Add(SZKingdomArgument.SecurityLevel(orderArguments.SecurityLevel));
            arguments.Add(SZKingdomArgument.OrderPrice(orderArguments.OrderPrice));
            arguments.Add(SZKingdomArgument.CustomerCode(orderArguments.CustomerCode));
            arguments.Add(SZKingdomArgument.TradeUnit(orderArguments.TradeUnit));
            arguments.Add(SZKingdomArgument.OrderBatchSerialNo(orderArguments.OrderBatchSerialNo));
            arguments.Add(SZKingdomArgument.ClientInfo(orderArguments.ClientInfo));
            arguments.Add(SZKingdomArgument.InternalOrganization(orderArguments.InternalOrganization));

            if (orderArguments.SecurityLevel != SecurityLevel.NoSecurity)
            {
                if (!string.IsNullOrWhiteSpace(orderArguments.SecurityInfo))
                {
                    arguments.Add(SZKingdomArgument.SecurityInfo(orderArguments.SecurityInfo));
                }
                else if (!string.IsNullOrWhiteSpace(orderArguments.Password))
                {
                    orderArguments.SecurityInfo = _marketDataLibrary.EncryptPassword(orderArguments.CustomerAccountCode, orderArguments.Password);
                }
                else
                {
                    EntityResponse <OptionOrderInformation> entityResponse = EntityResponse <OptionOrderInformation>
                                                                             .Error(ErrorCode.SZKingdomLibraryError, "No security info");

                    return(entityResponse);
                }
            }

            EntityResponse <OptionOrderInformation> result =
                _marketDataLibrary.ExecuteCommandSingleEntity <OptionOrderInformation>(SZKingdomRequest.OptionOrder, arguments);

            return(result);
        }
        public EntityResponse <RiskLevelInformation> GetAccountRiskLevelInformation(string customerAccountCode, Currency currency)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            if (string.IsNullOrWhiteSpace(customerAccountCode))
            {
                return(EntityResponse <RiskLevelInformation> .Error(
                           ErrorCode.SZKingdomLibraryError,
                           ErrorMessages.SZKingdom_CustomerCodeEmpty));
            }

            arguments.Add(SZKingdomArgument.CustomerAccountCode(customerAccountCode));
            arguments.Add(SZKingdomArgument.Currency(currency));

            EntityResponse <RiskLevelInformation> result =
                _marketDataLibrary.ExecuteCommandSingleEntity <RiskLevelInformation>(SZKingdomRequest.AccountRiskLevel, arguments);

            return(result);
        }
Example #18
0
        public EntityResponse <List <AssignableExerciseDetail> > AssignableExerciseDetail(AssignableExerciseDetailArguments assignableExerciseDetailArguments)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.CustomerCode(assignableExerciseDetailArguments.CustomerCode));
            arguments.Add(SZKingdomArgument.CustomerAccountCode(assignableExerciseDetailArguments.CustomerAccountCode));
            arguments.Add(SZKingdomArgument.Currency(assignableExerciseDetailArguments.Currency));
            arguments.Add(SZKingdomArgument.StockBoard(assignableExerciseDetailArguments.StockBoard));

            arguments.Add(SZKingdomArgument.TradeAccount(assignableExerciseDetailArguments.TradeAccount));
            arguments.Add(SZKingdomArgument.OptionNumber(assignableExerciseDetailArguments.OptionNumber));
            arguments.Add(SZKingdomArgument.OptionUnderlyingCode(assignableExerciseDetailArguments.OptionUnderlyingCode));
            arguments.Add(SZKingdomArgument.OptionType(assignableExerciseDetailArguments.OptionType));
            arguments.Add(SZKingdomArgument.OptionCoveredFlag(assignableExerciseDetailArguments.OptionCoveredFlag));
            arguments.Add(SZKingdomArgument.ExerciseSide(assignableExerciseDetailArguments.ExerciseSide));
            arguments.Add(SZKingdomArgument.QueryPosition(assignableExerciseDetailArguments.QueryPosition));
            arguments.Add(SZKingdomArgument.QueryNumer(assignableExerciseDetailArguments.QueryNumer));



            //if (orderArguments.SecurityLevel != SecurityLevel.NoSecurity)
            //{
            //    if (!string.IsNullOrWhiteSpace(orderArguments.SecurityInfo))
            //    {
            //        arguments.Add(SZKingdomArgument.SecurityInfo(orderArguments.SecurityInfo));
            //    }
            //    else if (!string.IsNullOrWhiteSpace(orderArguments.Password))
            //    {
            //        orderArguments.SecurityInfo = _marketDataLibrary.EncryptPassword(orderArguments.CustomerAccountCode, orderArguments.Password);
            //    }
            //    else
            //    {
            //        EntityResponse<OptionOrderInformation> entityResponse = EntityResponse<OptionOrderInformation>
            //            .Error(ErrorCode.SZKingdomLibraryError, "No security info");
            //        return entityResponse;
            //    }
            //}

            EntityResponse <List <AssignableExerciseDetail> > result =
                _marketDataLibrary.ExecuteCommandList <AssignableExerciseDetail>(SZKingdomRequest.AssignableExerciseDetail, arguments);

            return(result);
        }
Example #19
0
        public EntityResponse <UnderlyingSecurityLockUnlockInformation> LockUnlockUnderlyingSecurity(
            UnderlyingSecurityLockUnlockArguments lockUnlockArguments)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.CustomerAccountCode(lockUnlockArguments.CustomerAccountCode));
            arguments.Add(SZKingdomArgument.TradeAccount(lockUnlockArguments.TradeAccount));
            arguments.Add(SZKingdomArgument.StockBoard(lockUnlockArguments.StockBoard));
            arguments.Add(SZKingdomArgument.SecurityCode(lockUnlockArguments.SecurityCode));
            arguments.Add(SZKingdomArgument.OrderQuantity(lockUnlockArguments.OrderQuantity));
            arguments.Add(SZKingdomArgument.StockBusiness(lockUnlockArguments.StockBusiness));
            arguments.Add(SZKingdomArgument.StockBusinessAction(StockBusinessAction.OrderDeclaration));
            arguments.Add(SZKingdomArgument.SecurityLevel(lockUnlockArguments.SecurityLevel));
            arguments.Add(SZKingdomArgument.InternalOrganization(lockUnlockArguments.InternalOrganization));

            if (lockUnlockArguments.SecurityLevel != SecurityLevel.NoSecurity)
            {
                lockUnlockArguments.SecurityInfo = _marketDataLibrary.EncryptPassword(lockUnlockArguments.CustomerAccountCode, lockUnlockArguments.Password);

                if (!string.IsNullOrWhiteSpace(lockUnlockArguments.SecurityInfo))
                {
                    arguments.Add(SZKingdomArgument.SecurityInfo(lockUnlockArguments.SecurityInfo));
                }
                else
                {
                    EntityResponse <UnderlyingSecurityLockUnlockInformation> entityResponse = EntityResponse <UnderlyingSecurityLockUnlockInformation>
                                                                                              .Error(ErrorCode.SZKingdomLibraryError, "No security info");

                    return(entityResponse);
                }
            }

            arguments.Add(SZKingdomArgument.CustomerCode(lockUnlockArguments.CustomerCode));
            arguments.Add(SZKingdomArgument.TradeUnit(lockUnlockArguments.TradeUnit));
            arguments.Add(SZKingdomArgument.OrderBatchSerialNo(lockUnlockArguments.OrderBatchSerialNo));
            arguments.Add(SZKingdomArgument.ClientInfo(lockUnlockArguments.ClientInfo));

            EntityResponse <UnderlyingSecurityLockUnlockInformation> result = _marketDataLibrary
                                                                              .ExecuteCommandSingleEntity <UnderlyingSecurityLockUnlockInformation>(SZKingdomRequest.UnderlyingSecurityLockUnlock, arguments);

            return(result);
        }
        public EntityResponse <List <FundInformation> > GetFundInformation(string customertCode = null, string customerAccountCode = null, Currency currency = null)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            if (string.IsNullOrWhiteSpace(customertCode) && string.IsNullOrWhiteSpace(customerAccountCode))
            {
                return(EntityResponse <List <FundInformation> > .Error(ErrorCode.SZKingdomLibraryError,
                                                                       string.Format(ErrorMessages.SZKingdom_EmptyAccountIds)));
            }

            arguments.Add(SZKingdomArgument.CustomerCode(customertCode));
            arguments.Add(SZKingdomArgument.CustomerAccountCode(customerAccountCode));
            arguments.Add(SZKingdomArgument.Currency(currency));
            arguments.Add(SZKingdomArgument.ValueFlag("15"));

            EntityResponse <List <FundInformation> > result =
                _marketDataLibrary.ExecuteCommandList <FundInformation>(SZKingdomRequest.FundInformation, arguments);

            return(result);
        }
        public BaseResponse ChangePassword(string customerCode, PasswordUseScope useScope, string oldPassword, string newPassword)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.UserCode(customerCode));
            arguments.Add(SZKingdomArgument.PasswordUseScpose(useScope));
            arguments.Add(SZKingdomArgument.OldAuthenticationData(_marketDataLibrary.EncryptPassword(customerCode, oldPassword)));
            arguments.Add(SZKingdomArgument.NewAuthenticationData(_marketDataLibrary.EncryptPassword(customerCode, newPassword)));
            arguments.Add(SZKingdomArgument.EncryptionKey(customerCode));
            arguments.Add(SZKingdomArgument.EncryptionType(EncryptionType.WinEncryption));
            arguments.Add(SZKingdomArgument.AuthenticationType(AuthenticationType.Password));

            EntityResponse <DataTable> result = _marketDataLibrary.ExecuteCommand(SZKingdomRequest.ChangePassword, arguments);

            if (result.IsSuccess)
            {
                return(BaseResponse.Success());
            }

            return(BaseResponse.Error(result.ErrorCode, result.FormattedMessage));
        }
Example #22
0
        private static void SetFixedParameters(SZKingdomRequest function, List <SZKingdomArgument> inputParameters)
        {
            //todo: add more required fixed parameters here.
            string operatorCode = Configuration.OperatorCode;
            string operatorRole = Configuration.OperatorRole;

            foreach (SZKingdomArgument argument in inputParameters)
            {
                if (argument.Name.Equals(NullCustomerCodeArgument.Name) && !string.IsNullOrWhiteSpace(argument.Value))
                {
                    operatorCode = argument.Value;
                    operatorRole = UserRole.Customer.InternalValue;
                }
            }
            inputParameters.Add(SZKingdomArgument.OperatorCode(operatorCode));
            inputParameters.Add(SZKingdomArgument.OperatorRole(operatorRole));
            inputParameters.Add(SZKingdomArgument.OperateChannel(Configuration.Channel));
            inputParameters.Add(SZKingdomArgument.OperatorSite(Configuration.OperatorSite));
            inputParameters.Add(SZKingdomArgument.OperateOrganization(Configuration.OperateOrganization));
            inputParameters.Add(SZKingdomArgument.FunctionNo(function.InternalValue));
            inputParameters.Add(SZKingdomArgument.RunTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")));
        }
        public EntityResponse <List <OptionableStockPositionInformation> > GetOptionalStockPositions(string customerCode, string customerAccountCode,
                                                                                                     string tradeAccount, string tradeUnit = null,
                                                                                                     string queryPosition = null)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            if (string.IsNullOrWhiteSpace(customerCode) && string.IsNullOrWhiteSpace(customerAccountCode))
            {
                return(EntityResponse <List <OptionableStockPositionInformation> > .Error(ErrorCode.SZKingdomLibraryError, "Customer code and Account code cannot be empty at the same time."));
            }

            arguments.Add(SZKingdomArgument.CustomerCode(customerCode));
            arguments.Add(SZKingdomArgument.CustomerAccountCode(customerAccountCode));
            arguments.Add(SZKingdomArgument.TradeAccount(tradeAccount));
            arguments.Add(SZKingdomArgument.TradeUnit(tradeUnit));
            arguments.Add(SZKingdomArgument.QueryPosition(queryPosition));

            EntityResponse <List <OptionableStockPositionInformation> > result =
                _marketDataLibrary.ExecuteCommandList <OptionableStockPositionInformation>(SZKingdomRequest.OptionableStockPositions, arguments);

            return(result);
        }
Example #24
0
        public BaseResponse CancelOptionOrder(OptionOrderCancellationArguments cancellationArguments)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            arguments.Add(SZKingdomArgument.CustomerAccountCode(cancellationArguments.CustomerAccountCode));
            arguments.Add(SZKingdomArgument.StockBoard(cancellationArguments.StockBoard.ToString()));
            arguments.Add(SZKingdomArgument.InternalOrganization(cancellationArguments.InternalOrganization));
            arguments.Add(SZKingdomArgument.OrderId(cancellationArguments.OrderId));
            arguments.Add(SZKingdomArgument.OrderBatchSerialNo(cancellationArguments.OrderBatchSerialNo));

            if (string.IsNullOrWhiteSpace(cancellationArguments.OrderId) && cancellationArguments.OrderBatchSerialNo == null)
            {
                EntityResponse <OptionOrderCancellationInformation> entityResponse = EntityResponse <OptionOrderCancellationInformation>
                                                                                     .Error(ErrorCode.SZKingdomLibraryError, "Order Id and Order BSN cannot be empty at the same time");

                return(entityResponse);
            }

            BaseResponse result = _marketDataLibrary.ExecuteCommand(SZKingdomRequest.CancelOptionOrder, arguments);

            return(result);
        }
Example #25
0
        public EntityResponse <List <LockableUnderlyingInformation> > GetLockableUnderlyings(StockBoard stockBoard, string tradeAccount,
                                                                                             string customerCode = null, string accountCode = null)
        {
            List <SZKingdomArgument> arguments = new List <SZKingdomArgument>();

            if (customerCode == null && accountCode == null)
            {
                EntityResponse <List <LockableUnderlyingInformation> > entityReponse = EntityResponse <List <LockableUnderlyingInformation> >
                                                                                       .Error(ErrorCode.SZKingdomLibraryError, SameCodesErrorMessage);

                return(entityReponse);
            }

            arguments.Add(SZKingdomArgument.CustomerCode(customerCode));
            arguments.Add(SZKingdomArgument.CustomerAccountCode(accountCode));
            arguments.Add(SZKingdomArgument.StockBoard(stockBoard));
            arguments.Add(SZKingdomArgument.TradeAccount(tradeAccount));

            EntityResponse <List <LockableUnderlyingInformation> > result = _marketDataLibrary
                                                                            .ExecuteCommandList <LockableUnderlyingInformation>(SZKingdomRequest.LockableUnderlyings, arguments);

            return(result);
        }