//public string[] parsedExpression //{ // get { return saParsed; } //} public ReversePolishNotation(OptionStrategy optionStrategy, OptionSpreadManager optionSpreadManager) { sOriginalExpression = string.Empty; sTransitionExpression = string.Empty; sPostfixExpression = string.Empty; this.optionStrategy = optionStrategy; this.optionSpreadManager = optionSpreadManager; }
public List <OptionStrategy> readSupplementContracts(string fullFile, OptionArrayTypes optionArrayTypes, int portfolioId, QueryFutureIdContractDelegate queryFutureIdContractDelegate, object queryObject) { List <OptionStrategy> optionStrategies = new List <OptionStrategy>(); try { if (File.Exists(fullFile)) { FileStream fileStream = new FileStream(fullFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); StreamReader streamReader = new StreamReader(fileStream); int optionStrategyCount = 1; while (!streamReader.EndOfStream) { String line = streamReader.ReadLine(); if (line.Length > 0) { string[] supplementContractStrategy = line.Split(','); if (supplementContractStrategy.Length >= 3) { string idcontract = queryFutureIdContractDelegate(queryObject, Convert.ToInt32(supplementContractStrategy[0].Trim()), Convert.ToInt32(supplementContractStrategy[1].Trim()), Convert.ToInt32(supplementContractStrategy[2].Trim())); OptionStrategy optionStrategy = new OptionStrategy(); optionStrategy.optionStrategyParameters = new OptionStrategyParameter[ optionArrayTypes.tblStrategyStateFieldTypesArray.GetLength(0)]; for (int i = 0; i < optionArrayTypes.tblStrategyStateFieldTypesArray.GetLength(0); i++) { optionStrategy.optionStrategyParameters[i] = new OptionStrategyParameter(); } optionStrategies.Add(optionStrategy); optionStrategy.supplementContract = true; optionStrategy.idPortfoliogroup = portfolioId; optionStrategy.idInstrument = Convert.ToInt32(supplementContractStrategy[0]); optionStrategy.idStrategy = optionStrategyCount; optionStrategyCount++; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.numberOfLegs].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.numberOfLegs; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.numberOfLegs].parseParameter = TBL_DB_PARSE_PARAMETER.DONOT_PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.numberOfLegs].stateValue = 1; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.spreadStructure].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.spreadStructure; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.spreadStructure].parseParameter = TBL_DB_PARSE_PARAMETER.PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.spreadStructure].stateValueStringNotParsed = "2"; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.activeContractIndexes].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.activeContractIndexes; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.activeContractIndexes].parseParameter = TBL_DB_PARSE_PARAMETER.PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.activeContractIndexes].stateValueStringNotParsed = idcontract; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rollIntoContractIndexes].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.rollIntoContractIndexes; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rollIntoContractIndexes].parseParameter = TBL_DB_PARSE_PARAMETER.PARSE_ROLL_PARAMETER_SCRIPT; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rollIntoContractIndexes].stateValueStringNotParsed = ""; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.cfgContracts].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.cfgContracts; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.cfgContracts].parseParameter = TBL_DB_PARSE_PARAMETER.PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.cfgContracts].stateValueStringNotParsed = ""; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.currentPosition].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.currentPosition; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.currentPosition].parseParameter = TBL_DB_PARSE_PARAMETER.PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.currentPosition].stateValueStringNotParsed = ""; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.entryRule].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.entryRule; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.entryRule].parseParameter = TBL_DB_PARSE_PARAMETER.PARSE_ENTRY_SCRIPT; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.entryRule].stateValueStringNotParsed = ""; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.entryLots].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.entryLots; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.entryLots].parseParameter = TBL_DB_PARSE_PARAMETER.PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.entryLots].stateValueStringNotParsed = ""; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.exitRule].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.exitRule; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.exitRule].parseParameter = TBL_DB_PARSE_PARAMETER.PARSE_EXIT_SCRIPT; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.exitRule].stateValueStringNotParsed = ""; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.exitLots].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.exitLots; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.exitLots].parseParameter = TBL_DB_PARSE_PARAMETER.PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.exitLots].stateValueStringNotParsed = ""; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.marginRequirement].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.marginRequirement; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.marginRequirement].parseParameter = TBL_DB_PARSE_PARAMETER.DONOT_PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.marginRequirement].stateValue = 0; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rRisk].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.rRisk; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rRisk].parseParameter = TBL_DB_PARSE_PARAMETER.DONOT_PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rRisk].stateValue = 0; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rRisk_R].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.rRisk_R; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rRisk_R].parseParameter = TBL_DB_PARSE_PARAMETER.DONOT_PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rRisk_R].stateValue = 0; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.oneR].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.oneR; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.oneR].parseParameter = TBL_DB_PARSE_PARAMETER.DONOT_PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.oneR].stateValue = 0; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rStatus].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.rStatus; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rStatus].parseParameter = TBL_DB_PARSE_PARAMETER.DONOT_PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rStatus].stateValue = 0; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rStatus_R].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.rStatus_R; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rStatus_R].parseParameter = TBL_DB_PARSE_PARAMETER.DONOT_PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.rStatus_R].stateValue = 0; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.idRiskType].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.idRiskType; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.idRiskType].parseParameter = TBL_DB_PARSE_PARAMETER.DONOT_PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.idRiskType].stateValue = 0; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.idSignalType].strategyStateFieldType = TBL_STRATEGY_STATE_FIELDS.idSignalType; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.idSignalType].parseParameter = TBL_DB_PARSE_PARAMETER.DONOT_PARSE_PARAMETER; optionStrategy.optionStrategyParameters[(int)TBL_STRATEGY_STATE_FIELDS.idSignalType].stateValue = 0; optionStrategy.lockedIn_R = 0; } } } fileStream.Close(); streamReader.Close(); } } catch (Exception ex) { TSErrorCatch.errorCatchOut(Convert.ToString(this), ex); } return(optionStrategies); }