Esempio n. 1
0
        private PositionManager ParseUserArgsPositionForManager(PositionManager manager, List <string[]> userData)
        {
            UserPosTableTypes type;
            double            enterPrice;
            int    quantity;
            double strike;

            double       remainingDays;
            double       priceStep;
            double       priceVal;
            TradeBlotter futBlotter;
            TradeBlotter optBlotter;

            foreach (string[] data in userData)
            {
                if (!UserPosTableTypes.TryParse(data[0], out type))
                {
                    throw new NotImplementedException();
                }

                enterPrice = Convert.ToDouble(data[2]);
                quantity   = Convert.ToInt32(data[3]);

                if (!String.IsNullOrEmpty(data[1]))
                {
                    strike = Convert.ToDouble(data[1]);
                }
                else
                {
                    strike = 0.0;
                }


                if (type.Equals(UserPosTableTypes.C))
                {
                    try
                    {
                        futBlotter    = dataCollector.GetBasicFutures().GetTradeBlotter();
                        optBlotter    = dataCollector.GetOption(strike, OptionType.Call).GetTradeBlotter();
                        remainingDays = dataCollector.GetOption(strike, OptionType.Call).RemainingDays;
                        priceStep     = dataCollector.GetOption(strike, OptionType.Call).PriceStep;
                        priceVal      = dataCollector.GetOption(strike, OptionType.Call).PriceStepValue;

                        manager.AddOption(Option.GetFakeOption(OptionType.Call, strike, enterPrice,
                                                               remainingDays, quantity, futBlotter, optBlotter, priceStep, priceVal));
                    }
                    catch (QuikDdeException e1)
                    {
                        mainForm.UpdateMessageWindow(e1.Message);
                        LOGGER.Error("ParseUserArgs, exception in call section: {0}", e1.ToString());
                    }
                }

                else if (type.Equals(UserPosTableTypes.P))
                {
                    try
                    {
                        futBlotter    = dataCollector.GetBasicFutures().GetTradeBlotter();
                        optBlotter    = dataCollector.GetOption(strike, OptionType.Put).GetTradeBlotter();
                        remainingDays = dataCollector.GetOption(strike, OptionType.Put).RemainingDays;
                        priceStep     = dataCollector.GetOption(strike, OptionType.Call).PriceStep;
                        priceVal      = dataCollector.GetOption(strike, OptionType.Call).PriceStepValue;

                        manager.AddOption(Option.GetFakeOption(OptionType.Put, strike, enterPrice,
                                                               remainingDays, quantity, futBlotter, optBlotter, priceStep, priceVal));
                    }
                    catch (QuikDdeException e1)
                    {
                        mainForm.UpdateMessageWindow(e1.Message);
                        LOGGER.Error("ParseUserArgs, exception in put section: {0}", e1.ToString());
                    }
                }
                else if (type.Equals(UserPosTableTypes.F))
                {
                    futBlotter = dataCollector.GetBasicFutures().GetTradeBlotter();
                    priceStep  = dataCollector.GetBasicFutures().PriceStep;
                    priceVal   = dataCollector.GetBasicFutures().PriceStepValue;

                    manager.AddFutures(Futures.GetFakeFutures(enterPrice, quantity, futBlotter, priceStep,
                                                              priceVal));
                }
                else
                {
                    mainForm.UpdateMessageWindow("incorrect type of instrument: " + type);
                    LOGGER.Error("ParseUserArgs, incorrect type of instrument, futures section: {0}", type);
                }
            }

            return(manager);
        }