Пример #1
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);
        }
Пример #2
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);
        }