Ejemplo n.º 1
0
        internal void setupInstrumentAndfillStrikeInDecimal(ADMPositionImportWeb aDMSummaryImport,
                                                            Instrument[] instruments, BrokerImportFiles brokerImportFiles)
        {
            if (aDMSummaryImport.PFC.CompareTo("05") == 0)
            {
                aDMSummaryImport.PFC = "S-";
            }
            else if (aDMSummaryImport.PFC.CompareTo("02") == 0)
            {
                aDMSummaryImport.PFC = "C-";
            }

            int instrumentCounter = 0;

            while (instrumentCounter < instruments.Length)
            {
                if (aDMSummaryImport.PFC.CompareTo(instruments[instrumentCounter].admCode) == 0)
                {
                    break;
                }

                instrumentCounter++;
            }

            if (instrumentCounter >= instruments.Length)
            {
                instrumentCounter = 0;
            }

            aDMSummaryImport.instrumentArrayIdx = instrumentCounter;

            aDMSummaryImport.instrument = instruments[instrumentCounter];



            subContractType((ADM_Input_Data)aDMSummaryImport,
                            aDMSummaryImport.PSUBTY);


            if (brokerImportFiles == BrokerImportFiles.GMI_IMPORT_CSV_FILES)
            {
                aDMSummaryImport.strikeInDecimal = Convert.ToDouble(aDMSummaryImport.aDMStrike)
                                                   * instruments[instrumentCounter].admFuturePriceFactor;
            }
            else if (brokerImportFiles == BrokerImportFiles.ADM_WEB_IMPORT_FILES)
            {
                aDMSummaryImport.strikeInDecimal =
                    ConversionAndFormatting.convertToTickMovesDouble(aDMSummaryImport.aDMStrike,
                                                                     instruments[instrumentCounter].optionStrikeIncrement,
                                                                     instruments[instrumentCounter].optionADMStrikeDisplay);
            }
            else if (brokerImportFiles == BrokerImportFiles.BACKUP_SAVED_FILE)
            {
                aDMSummaryImport.strikeInDecimal = Convert.ToDouble(aDMSummaryImport.aDMStrike);
            }


            aDMSummaryImport.strike =
                ConversionAndFormatting.convertToTickMovesString(aDMSummaryImport.strikeInDecimal,
                                                                 instruments[aDMSummaryImport.instrumentArrayIdx].optionStrikeIncrement,
                                                                 instruments[aDMSummaryImport.instrumentArrayIdx].optionStrikeDisplay);
        }
Ejemplo n.º 2
0
        public void copyADMPositionImportWeb(ADMPositionImportWeb copyInto, ADMPositionImportWeb copyFrom)
        {
            copyInto.MODEL_OFFICE_ACCT = copyFrom.MODEL_OFFICE_ACCT;
            copyInto.acctGroup         = copyFrom.acctGroup;

            copyInto.dateTime = copyFrom.dateTime;

            copyInto.instrumentArrayIdx = copyFrom.instrumentArrayIdx;

            copyInto.instrument = copyFrom.instrument;

            copyInto.cqgSymbol = copyFrom.cqgSymbol;

            copyInto.isFuture = copyFrom.isFuture;

            copyInto.callPutOrFuture = copyFrom.callPutOrFuture;

            copyInto.strikeInDecimal = copyFrom.strikeInDecimal;

            copyInto.strike = copyFrom.strike;

            copyInto.contractInfo = copyFrom.contractInfo;
            copyInto.contractData = copyFrom.contractData;



            copyInto.modelLots            = copyFrom.modelLots;
            copyInto.orderLots            = copyFrom.orderLots;
            copyInto.rollIntoLots         = copyFrom.rollIntoLots;
            copyInto.rebalanceLots        = copyFrom.rebalanceLots;
            copyInto.liveADMRowIdx        = copyFrom.liveADMRowIdx;
            copyInto.netContractsEditable = copyFrom.netContractsEditable;


            copyInto.transAvgLongPrice  = copyFrom.transAvgLongPrice;
            copyInto.transAvgShortPrice = copyFrom.transAvgShortPrice;

            copyInto.transNetLong  = copyFrom.transNetLong;
            copyInto.transNetShort = copyFrom.transNetShort;
            copyInto.Net           = copyFrom.Net;



            copyInto.RecordType = copyFrom.RecordType;

            copyInto.POFFIC = copyFrom.POFFIC;
            copyInto.PACCT  = copyFrom.PACCT;

            copyInto.PCUSIP        = copyFrom.PCUSIP;
            copyInto.PCUSIP2       = copyFrom.PCUSIP2;
            copyInto.Description   = copyFrom.Description;
            copyInto.LongQuantity  = copyFrom.LongQuantity;
            copyInto.ShortQuantity = copyFrom.ShortQuantity;



            //copyInto.netContractsEditable = copyFrom.netContractsEditable;

            copyInto.WeightedPrice = copyFrom.WeightedPrice;

            //copyInto.AveragePrice = copyFrom.AveragePrice;

            copyInto.RealTimePrice = copyFrom.RealTimePrice;
            copyInto.SettledPrice  = copyFrom.SettledPrice;
            copyInto.PrelimPrice   = copyFrom.PrelimPrice;
            copyInto.Value         = copyFrom.Value;
            copyInto.ClosedValue   = copyFrom.ClosedValue;
            copyInto.SettledValue  = copyFrom.SettledValue;
            copyInto.Currency      = copyFrom.Currency;
            copyInto.PSUBTY        = copyFrom.PSUBTY;
            copyInto.PEXCH         = copyFrom.PEXCH;
            copyInto.PFC           = copyFrom.PFC;

            copyInto.aDMStrike = copyFrom.aDMStrike;

            copyInto.PCTYM          = copyFrom.PCTYM;
            copyInto.PCTYM_dateTime = copyFrom.PCTYM_dateTime;

            copyInto.PCARD = copyFrom.PCARD;
        }
Ejemplo n.º 3
0
        internal void readADMDetailedPositionImportWeb(String[] fileNames,
                                                       List <ADMPositionImportWeb> admSummaryFieldsList, ImportFileCheck importFileCheck,
                                                       Instrument[] instruments)//, bool[] doNotImportFile)
        {
            BrokerImportFiles brokerImportFiles = BrokerImportFiles.BACKUP_SAVED_FILE;
            FTPInputFileTypes cSVImportFileType = FTPInputFileTypes.ADM_WEB_INTERFACE_FILES;

            importFileCheck.importfile = true;

            //bool importFile = true;

#if DEBUG
            try
#endif
            {
                Type  admSummaryFieldTypes     = typeof(ADM_DETAIL_FIELDS);
                Array admSummaryFieldTypeArray = Enum.GetNames(admSummaryFieldTypes);

                for (int fileCounter = 0; fileCounter < fileNames.Length; fileCounter++)
                {
                    bool firstLine = true;

                    if (File.Exists(fileNames[fileCounter]))
                    {
                        DateTime lastWriteTime = File.GetLastWriteTime(fileNames[fileCounter]);

                        {
                            FileStream fileStream = new FileStream(fileNames[fileCounter],
                                                                   FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            StreamReader streamReader = new StreamReader(fileStream);


                            if (fileNames[fileCounter].ToLower().EndsWith(".csv"))
                            {
                                string[] parsedFileName = fileNames[fileCounter].Split('\\');

                                if (parsedFileName.Last().Substring(0, 3).ToLower().CompareTo("pos") == 0)
                                {
                                    cSVImportFileType = FTPInputFileTypes.POSITION_FILE_WEDBUSH_OR_RCG;

                                    brokerImportFiles = BrokerImportFiles.GMI_IMPORT_CSV_FILES;
                                }
                                else if (parsedFileName.Last().Substring(0, 3).ToLower().CompareTo("prl") == 0)
                                {
                                    cSVImportFileType = FTPInputFileTypes.TRANSACTION_FILE_WEDBUSH;

                                    brokerImportFiles = BrokerImportFiles.GMI_IMPORT_CSV_FILES;
                                }
                                else if (parsedFileName.Last().Substring(0, 4).ToLower().CompareTo("trnd") == 0)
                                {
                                    cSVImportFileType = FTPInputFileTypes.TRANSACTION_FILE_RCG;

                                    brokerImportFiles = BrokerImportFiles.GMI_IMPORT_CSV_FILES;
                                }
                                else if (parsedFileName.Last().ToLower().EndsWith("adatpos.csv"))
                                {
                                    cSVImportFileType = FTPInputFileTypes.POSITION_FILE_ADM;

                                    brokerImportFiles = BrokerImportFiles.GMI_IMPORT_CSV_FILES;
                                }
                                else if (parsedFileName.Last().ToLower().EndsWith("aaprlmcsv.csv"))
                                {
                                    cSVImportFileType = FTPInputFileTypes.TRANSACTION_FILE_ADM;

                                    brokerImportFiles = BrokerImportFiles.ADM_WEB_IMPORT_FILES;
                                }
                                else
                                {
                                    importFileCheck.importfile = false;

                                    String            caption = "An imported file is not a 'pos' or 'prl' file";
                                    String            message = fileNames[fileCounter] + "\nis not a 'pos' or 'prl'";
                                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                                    System.Windows.Forms.DialogResult result;

                                    // Displays the MessageBox.
                                    result = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                cSVImportFileType = FTPInputFileTypes.ADM_WEB_INTERFACE_FILES;
                                brokerImportFiles = BrokerImportFiles.ADM_WEB_IMPORT_FILES;
                            }

                            bool setFileReader = false;
                            Fill_GMI_ImportDelegate Import_GMI = null;

                            while (!(streamReader.EndOfStream) && importFileCheck.importfile)
                            {
                                String line = streamReader.ReadLine();
                                if (line.Length > 0)
                                {
                                    List <String> stringList;  // = readSeparatedLine(line, '\t');


                                    if (cSVImportFileType == FTPInputFileTypes.ADM_WEB_INTERFACE_FILES ||
                                        importFileCheck.importingBackedUpSavedFile)
                                    {
                                        stringList = readSeparatedLine(line, '\t');
                                    }
                                    else
                                    {
                                        stringList = readSeparatedLine(line, ',');
                                    }

                                    if (cSVImportFileType == FTPInputFileTypes.POSITION_FILE_ADM ||
                                        cSVImportFileType == FTPInputFileTypes.TRANSACTION_FILE_ADM)
                                    {
                                        //there isn't a header line in these 2 file types from ADM ftp
                                        firstLine = false;
                                    }



                                    if (firstLine)
                                    {
                                        //firstLine = false;

                                        if (cSVImportFileType == FTPInputFileTypes.POSITION_FILE_WEDBUSH_OR_RCG)
                                        {
                                            if (stringList.Count > 0)
                                            {
                                                //brokerImportFiles = BrokerImportFiles.BACKUP_SAVED_FILE;

                                                if (stringList[0].CompareTo("R I D") == 0)
                                                {
                                                    cSVImportFileType = FTPInputFileTypes.POSITION_FILE_RCG;
                                                }
                                                else
                                                {
                                                    cSVImportFileType = FTPInputFileTypes.POSITION_FILE_WEDBUSH;
                                                }
                                            }
                                        }

                                        else if (importFileCheck.importingBackedUpSavedFile)
                                        {
                                            brokerImportFiles = BrokerImportFiles.BACKUP_SAVED_FILE;
                                        }
                                        //else if (brokerImportFiles == BrokerImportFiles.ADM_FILES)
                                        else if (cSVImportFileType == FTPInputFileTypes.ADM_WEB_INTERFACE_FILES)
                                        {
                                            int stringListCounter = 0;

                                            while (stringListCounter < stringList.Count)
                                            {
                                                if (stringListCounter >= admSummaryFieldTypeArray.Length
                                                    ||
                                                    (stringListCounter < admSummaryFieldTypeArray.Length &&
                                                     stringList[stringListCounter].CompareTo(
                                                         admSummaryFieldTypeArray.GetValue(stringListCounter)) != 0))
                                                {
                                                    String            caption = "ADM FIELDS HAVE CHANGED, FIELDS DO NOT MATCH PREVIOUS INPUTS";
                                                    String            message = fileNames[fileCounter] + "\nADM FIELDS HAVE CHANGED, THERE IS A PROBLEM \nFILE WILL NOT BE IMPORTED";
                                                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                                                    System.Windows.Forms.DialogResult result;

                                                    // Displays the MessageBox.
                                                    result = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Error);

                                                    importFileCheck.importfile = false;

                                                    break;
                                                }

                                                stringListCounter++;
                                            }
                                        }
                                    }

                                    if (!setFileReader)
                                    {
                                        if ((importFileCheck.importingBackedUpSavedFile ||
                                             cSVImportFileType == FTPInputFileTypes.ADM_WEB_INTERFACE_FILES) &&
                                            importFileCheck.importfile)
                                        {
                                            Import_GMI    = new Fill_GMI_ImportDelegate(GMI_FileRead.FillGMI_ImportFromBackup_Or_ADMWeb);
                                            setFileReader = true;
                                        }
                                        else if (cSVImportFileType == FTPInputFileTypes.POSITION_FILE_WEDBUSH)
                                        {
                                            Import_GMI    = new Fill_GMI_ImportDelegate(GMI_FileRead.FillGMI_Position_Wedbush);
                                            setFileReader = true;
                                        }
                                        else if (cSVImportFileType == FTPInputFileTypes.TRANSACTION_FILE_WEDBUSH)
                                        {
                                            Import_GMI    = new Fill_GMI_ImportDelegate(GMI_FileRead.FillGMI_Transaction_Wedbush);
                                            setFileReader = true;
                                        }
                                        else if (cSVImportFileType == FTPInputFileTypes.POSITION_FILE_RCG)
                                        {
                                            Import_GMI    = new Fill_GMI_ImportDelegate(GMI_FileRead.FillGMI_Position_RCG);
                                            setFileReader = true;
                                        }
                                        else if (cSVImportFileType == FTPInputFileTypes.TRANSACTION_FILE_RCG)
                                        {
                                            Import_GMI    = new Fill_GMI_ImportDelegate(GMI_FileRead.FillGMI_Transaction_RCG);
                                            setFileReader = true;
                                        }
                                        else if (cSVImportFileType == FTPInputFileTypes.POSITION_FILE_ADM)
                                        {
                                            Import_GMI    = new Fill_GMI_ImportDelegate(GMI_FileRead.FillGMI_Position_ADM);
                                            setFileReader = true;
                                        }
                                        else if (cSVImportFileType == FTPInputFileTypes.TRANSACTION_FILE_ADM)
                                        {
                                            Import_GMI    = new Fill_GMI_ImportDelegate(GMI_FileRead.FillGMI_Transaction_ADM);
                                            setFileReader = true;
                                        }
                                    }


                                    if (!firstLine && setFileReader)
                                    {
                                        ADMPositionImportWeb aDMSummaryImport = Import_GMI(stringList);

                                        if (aDMSummaryImport != null)
                                        {
                                            admSummaryFieldsList.Add(aDMSummaryImport);

                                            setupInstrumentAndfillStrikeInDecimal(aDMSummaryImport,
                                                                                  instruments, brokerImportFiles);
                                        }
                                    }

                                    if (firstLine)
                                    {
                                        firstLine = false;
                                    }
                                    //if (stringList.Count > 0
                                    //&& stringList[(int)ADM_DETAIL_FIELDS.PEXCH].Trim().Length > 0
                                    //&& stringList[(int)ADM_DETAIL_FIELDS.PFC].Trim().Length > 0
                                    //&& stringList[(int)ADM_DETAIL_FIELDS.PCTYM].Trim().Length > 0)
                                    //{
                                    //    ADMPositionImportWeb aDMSummaryImport = new ADMPositionImportWeb();

                                    //    admSummaryFieldsList.Add(aDMSummaryImport);

                                    //    //aDMSummaryImport.rowInSummaryFieldList = admSummaryFieldsList.Count - 1;

                                    //    aDMSummaryImport.RecordType = stringList[(int)ADM_DETAIL_FIELDS.RecordType];
                                    //    aDMSummaryImport.POFFIC = stringList[(int)ADM_DETAIL_FIELDS.POFFIC];
                                    //    aDMSummaryImport.PACCT = stringList[(int)ADM_DETAIL_FIELDS.PACCT];
                                    //    aDMSummaryImport.PCUSIP = stringList[(int)ADM_DETAIL_FIELDS.PCUSIP];
                                    //    aDMSummaryImport.PCUSIP2 = stringList[(int)ADM_DETAIL_FIELDS.PCUSIP2];
                                    //    aDMSummaryImport.Description = stringList[(int)ADM_DETAIL_FIELDS.Description];

                                    //    aDMSummaryImport.LongQuantity = getDoubleOutOfStringList(stringList, ADM_DETAIL_FIELDS.LongQuantity);
                                    //    aDMSummaryImport.ShortQuantity = getDoubleOutOfStringList(stringList, ADM_DETAIL_FIELDS.ShortQuantity);
                                    //    //aDMSummaryImport.Net = getDoubleOutOfStringList(stringList, ADM_DETAIL_FIELDS.TradeDate);

                                    //    //aDMSummaryImport.netContractsEditable = aDMSummaryImport.Net;

                                    //    aDMSummaryImport.TradeDate = stringList[(int)ADM_DETAIL_FIELDS.TradeDate];
                                    //    aDMSummaryImport.TradePrice = getDoubleOutOfStringList(stringList, ADM_DETAIL_FIELDS.TradePrice);

                                    //    aDMSummaryImport.WeightedPrice = getDoubleOutOfStringList(stringList, ADM_DETAIL_FIELDS.WeightedPrice);

                                    //    //aDMSummaryImport.AveragePrice = getDoubleOutOfStringList(stringList, ADM_DETAIL_FIELDS.AveragePrice);

                                    //    aDMSummaryImport.RealTimePrice = getDoubleOutOfStringList(stringList, ADM_DETAIL_FIELDS.RealTimePrice);
                                    //    aDMSummaryImport.SettledPrice = getDoubleOutOfStringList(stringList, ADM_DETAIL_FIELDS.SettledPrice);
                                    //    aDMSummaryImport.PrelimPrice = getDoubleOutOfStringList(stringList, ADM_DETAIL_FIELDS.PrelimPrice);
                                    //    aDMSummaryImport.Value = getDoubleOutOfStringList(stringList, ADM_DETAIL_FIELDS.Value);
                                    //    aDMSummaryImport.ClosedValue = getDoubleOutOfStringList(stringList, ADM_DETAIL_FIELDS.ClosedValue);
                                    //    aDMSummaryImport.SettledValue = getDoubleOutOfStringList(stringList, ADM_DETAIL_FIELDS.SettledValue);

                                    //    aDMSummaryImport.Currency = stringList[(int)ADM_DETAIL_FIELDS.Currency];
                                    //    aDMSummaryImport.PSUBTY = stringList[(int)ADM_DETAIL_FIELDS.PSUBTY];
                                    //    aDMSummaryImport.PEXCH = getIntOutOfStringList(stringList, ADM_DETAIL_FIELDS.PEXCH);
                                    //    aDMSummaryImport.PFC = stringList[(int)ADM_DETAIL_FIELDS.PFC];
                                    //    aDMSummaryImport.aDMStrike = stringList[(int)ADM_DETAIL_FIELDS.Strike];

                                    //    aDMSummaryImport.PCTYM = stringList[(int)ADM_DETAIL_FIELDS.PCTYM];

                                    //    aDMSummaryImport.PCARD = stringList[(int)ADM_DETAIL_FIELDS.PCARD];


                                    //    setupInstrumentAndfillStrikeInDecimal(aDMSummaryImport,
                                    //        instruments, brokerImportFiles);
                                    //}
                                }
                            }

                            streamReader.Close();
                            fileStream.Close();
                        }
                    }
                }
                //                 else
                //                 {
                //                     String caption = "ADM FIELDS HAVE CHANGED, FIELDS DO NOT MATCH PREVIOUS INPUTS";
                //                     String message = fileName + "\nTHERE IS A PROBLEM \nFILE WILL NOT BE IMPORTED";
                //                     MessageBoxButtons buttons = MessageBoxButtons.OK;
                //                     System.Windows.Forms.DialogResult result;
                //
                //                     // Displays the MessageBox.
                //                     result = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Error);
                //                 }
            }
#if DEBUG
            catch (Exception ex)
            {
                TSErrorCatch.errorCatchOut(Convert.ToString(this), ex);
            }
#endif

            if (!importFileCheck.importfile)
            {
                admSummaryFieldsList.Clear();
            }

            //return importFile;
        }