class ProtonApi::PerformanceCalculatorRequest
Attributes
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/proton_api/models/performance_calculator_request.rb, line 102 def self.attribute_map { :'annualized_return_period' => :'annualized_return_period', :'risk_free_alpha' => :'risk_free_alpha', :'allocation_id' => :'allocation_id', :'mean_percentile_monte_carlo' => :'mean_percentile_monte_carlo', :'model_id' => :'model_id', :'mar_downside_deviation' => :'mar_downside_deviation', :'risk_free_sharpe' => :'risk_free_sharpe', :'benchmark_id' => :'benchmark_id', :'risk_free_sortino' => :'risk_free_sortino', :'household_id' => :'household_id', :'min_percentile_monte_carlo' => :'min_percentile_monte_carlo', :'moving_average_n_day' => :'moving_average_n_day', :'active_premium_period' => :'active_premium_period', :'stat_name' => :'stat_name', :'end_date' => :'end_date', :'start_date' => :'start_date', :'n_day_returns' => :'n_day_returns', :'var_conf_interval' => :'var_conf_interval', :'period_type' => :'period_type', :'risk_free_treynor' => :'risk_free_treynor', :'n_rolling_max_drawdown' => :'n_rolling_max_drawdown', :'portfolio_id' => :'portfolio_id', :'num_sim_monte_carlo' => :'num_sim_monte_carlo', :'goal_id' => :'goal_id', :'account_id' => :'account_id', :'security_id' => :'security_id', :'n_path_monte_carlo' => :'n_path_monte_carlo', :'client_id' => :'client_id', :'n_rolling_volatility' => :'n_rolling_volatility', :'hist_factor' => :'hist_factor', :'max_percentile_monte_carlo' => :'max_percentile_monte_carlo' } end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/proton_api/models/performance_calculator_request.rb, line 177 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'annualized_return_period') self.annualized_return_period = attributes[:'annualized_return_period'] else self.annualized_return_period = 'D' end if attributes.has_key?(:'risk_free_alpha') self.risk_free_alpha = attributes[:'risk_free_alpha'] else self.risk_free_alpha = 0.0 end if attributes.has_key?(:'allocation_id') self.allocation_id = attributes[:'allocation_id'] end if attributes.has_key?(:'mean_percentile_monte_carlo') self.mean_percentile_monte_carlo = attributes[:'mean_percentile_monte_carlo'] else self.mean_percentile_monte_carlo = 50.0 end if attributes.has_key?(:'model_id') self.model_id = attributes[:'model_id'] end if attributes.has_key?(:'mar_downside_deviation') self.mar_downside_deviation = attributes[:'mar_downside_deviation'] else self.mar_downside_deviation = 0.0 end if attributes.has_key?(:'risk_free_sharpe') self.risk_free_sharpe = attributes[:'risk_free_sharpe'] else self.risk_free_sharpe = 0.0 end if attributes.has_key?(:'benchmark_id') self.benchmark_id = attributes[:'benchmark_id'] end if attributes.has_key?(:'risk_free_sortino') self.risk_free_sortino = attributes[:'risk_free_sortino'] else self.risk_free_sortino = 0.0 end if attributes.has_key?(:'household_id') self.household_id = attributes[:'household_id'] end if attributes.has_key?(:'min_percentile_monte_carlo') self.min_percentile_monte_carlo = attributes[:'min_percentile_monte_carlo'] else self.min_percentile_monte_carlo = 20.0 end if attributes.has_key?(:'moving_average_n_day') self.moving_average_n_day = attributes[:'moving_average_n_day'] else self.moving_average_n_day = 7 end if attributes.has_key?(:'active_premium_period') self.active_premium_period = attributes[:'active_premium_period'] else self.active_premium_period = 'D' end if attributes.has_key?(:'stat_name') self.stat_name = attributes[:'stat_name'] end if attributes.has_key?(:'end_date') self.end_date = attributes[:'end_date'] end if attributes.has_key?(:'start_date') self.start_date = attributes[:'start_date'] end if attributes.has_key?(:'n_day_returns') self.n_day_returns = attributes[:'n_day_returns'] else self.n_day_returns = 7 end if attributes.has_key?(:'var_conf_interval') self.var_conf_interval = attributes[:'var_conf_interval'] else self.var_conf_interval = 95.0 end if attributes.has_key?(:'period_type') self.period_type = attributes[:'period_type'] else self.period_type = 'D' end if attributes.has_key?(:'risk_free_treynor') self.risk_free_treynor = attributes[:'risk_free_treynor'] else self.risk_free_treynor = 0.0 end if attributes.has_key?(:'n_rolling_max_drawdown') self.n_rolling_max_drawdown = attributes[:'n_rolling_max_drawdown'] else self.n_rolling_max_drawdown = 7 end if attributes.has_key?(:'portfolio_id') self.portfolio_id = attributes[:'portfolio_id'] end if attributes.has_key?(:'num_sim_monte_carlo') self.num_sim_monte_carlo = attributes[:'num_sim_monte_carlo'] else self.num_sim_monte_carlo = 1000 end if attributes.has_key?(:'goal_id') self.goal_id = attributes[:'goal_id'] end if attributes.has_key?(:'account_id') self.account_id = attributes[:'account_id'] end if attributes.has_key?(:'security_id') self.security_id = attributes[:'security_id'] end if attributes.has_key?(:'n_path_monte_carlo') self.n_path_monte_carlo = attributes[:'n_path_monte_carlo'] else self.n_path_monte_carlo = 100 end if attributes.has_key?(:'client_id') self.client_id = attributes[:'client_id'] end if attributes.has_key?(:'n_rolling_volatility') self.n_rolling_volatility = attributes[:'n_rolling_volatility'] else self.n_rolling_volatility = 7 end if attributes.has_key?(:'hist_factor') self.hist_factor = attributes[:'hist_factor'] else self.hist_factor = 5.0 end if attributes.has_key?(:'max_percentile_monte_carlo') self.max_percentile_monte_carlo = attributes[:'max_percentile_monte_carlo'] else self.max_percentile_monte_carlo = 80.0 end end
Attribute type mapping.
# File lib/proton_api/models/performance_calculator_request.rb, line 139 def self.swagger_types { :'annualized_return_period' => :'String', :'risk_free_alpha' => :'Float', :'allocation_id' => :'String', :'mean_percentile_monte_carlo' => :'Float', :'model_id' => :'String', :'mar_downside_deviation' => :'Float', :'risk_free_sharpe' => :'Float', :'benchmark_id' => :'String', :'risk_free_sortino' => :'Float', :'household_id' => :'String', :'min_percentile_monte_carlo' => :'Float', :'moving_average_n_day' => :'Integer', :'active_premium_period' => :'String', :'stat_name' => :'String', :'end_date' => :'Date', :'start_date' => :'Date', :'n_day_returns' => :'Integer', :'var_conf_interval' => :'Float', :'period_type' => :'String', :'risk_free_treynor' => :'Float', :'n_rolling_max_drawdown' => :'Integer', :'portfolio_id' => :'String', :'num_sim_monte_carlo' => :'Integer', :'goal_id' => :'String', :'account_id' => :'String', :'security_id' => :'String', :'n_path_monte_carlo' => :'Integer', :'client_id' => :'String', :'n_rolling_volatility' => :'Integer', :'hist_factor' => :'Float', :'max_percentile_monte_carlo' => :'Float' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/proton_api/models/performance_calculator_request.rb, line 537 def ==(o) return true if self.equal?(o) self.class == o.class && annualized_return_period == o.annualized_return_period && risk_free_alpha == o.risk_free_alpha && allocation_id == o.allocation_id && mean_percentile_monte_carlo == o.mean_percentile_monte_carlo && model_id == o.model_id && mar_downside_deviation == o.mar_downside_deviation && risk_free_sharpe == o.risk_free_sharpe && benchmark_id == o.benchmark_id && risk_free_sortino == o.risk_free_sortino && household_id == o.household_id && min_percentile_monte_carlo == o.min_percentile_monte_carlo && moving_average_n_day == o.moving_average_n_day && active_premium_period == o.active_premium_period && stat_name == o.stat_name && end_date == o.end_date && start_date == o.start_date && n_day_returns == o.n_day_returns && var_conf_interval == o.var_conf_interval && period_type == o.period_type && risk_free_treynor == o.risk_free_treynor && n_rolling_max_drawdown == o.n_rolling_max_drawdown && portfolio_id == o.portfolio_id && num_sim_monte_carlo == o.num_sim_monte_carlo && goal_id == o.goal_id && account_id == o.account_id && security_id == o.security_id && n_path_monte_carlo == o.n_path_monte_carlo && client_id == o.client_id && n_rolling_volatility == o.n_rolling_volatility && hist_factor == o.hist_factor && max_percentile_monte_carlo == o.max_percentile_monte_carlo end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/proton_api/models/performance_calculator_request.rb, line 608 def _deserialize(type, value) case type.to_sym when :DateTime value when :Date value when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = ProtonApi.const_get(type).new temp_model.build_from_hash(value) end end
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/proton_api/models/performance_calculator_request.rb, line 672 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end
Custom attribute writer method checking allowed values (enum). @param [Object] annualized_return_period
Object to be assigned
# File lib/proton_api/models/performance_calculator_request.rb, line 417 def annualized_return_period=(annualized_return_period) validator = EnumAttributeValidator.new('String', ['Y', 'Q', 'M', 'D']) unless validator.valid?(annualized_return_period) fail ArgumentError, 'invalid value for "annualized_return_period", must be one of #{validator.allowable_values}.' end @annualized_return_period = annualized_return_period end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/proton_api/models/performance_calculator_request.rb, line 588 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
@see the `==` method @param [Object] Object to be compared
# File lib/proton_api/models/performance_calculator_request.rb, line 575 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Fixnum] Hash code
# File lib/proton_api/models/performance_calculator_request.rb, line 581 def hash [annualized_return_period, risk_free_alpha, allocation_id, mean_percentile_monte_carlo, model_id, mar_downside_deviation, risk_free_sharpe, benchmark_id, risk_free_sortino, household_id, min_percentile_monte_carlo, moving_average_n_day, active_premium_period, stat_name, end_date, start_date, n_day_returns, var_conf_interval, period_type, risk_free_treynor, n_rolling_max_drawdown, portfolio_id, num_sim_monte_carlo, goal_id, account_id, security_id, n_path_monte_carlo, client_id, n_rolling_volatility, hist_factor, max_percentile_monte_carlo].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/proton_api/models/performance_calculator_request.rb, line 348 def list_invalid_properties invalid_properties = Array.new if !@mean_percentile_monte_carlo.nil? && @mean_percentile_monte_carlo < 0 invalid_properties.push('invalid value for "mean_percentile_monte_carlo", must be greater than or equal to 0.') end if !@min_percentile_monte_carlo.nil? && @min_percentile_monte_carlo < 0 invalid_properties.push('invalid value for "min_percentile_monte_carlo", must be greater than or equal to 0.') end if !@moving_average_n_day.nil? && @moving_average_n_day < 1 invalid_properties.push('invalid value for "moving_average_n_day", must be greater than or equal to 1.') end if @stat_name.nil? invalid_properties.push('invalid value for "stat_name", stat_name cannot be nil.') end if !@n_day_returns.nil? && @n_day_returns < 1 invalid_properties.push('invalid value for "n_day_returns", must be greater than or equal to 1.') end if !@n_rolling_max_drawdown.nil? && @n_rolling_max_drawdown < 1 invalid_properties.push('invalid value for "n_rolling_max_drawdown", must be greater than or equal to 1.') end if !@num_sim_monte_carlo.nil? && @num_sim_monte_carlo < 1 invalid_properties.push('invalid value for "num_sim_monte_carlo", must be greater than or equal to 1.') end if !@n_path_monte_carlo.nil? && @n_path_monte_carlo < 1 invalid_properties.push('invalid value for "n_path_monte_carlo", must be greater than or equal to 1.') end if !@n_rolling_volatility.nil? && @n_rolling_volatility < 1 invalid_properties.push('invalid value for "n_rolling_volatility", must be greater than or equal to 1.') end if !@max_percentile_monte_carlo.nil? && @max_percentile_monte_carlo < 0 invalid_properties.push('invalid value for "max_percentile_monte_carlo", must be greater than or equal to 0.') end invalid_properties end
Custom attribute writer method with validation @param [Object] max_percentile_monte_carlo
Value to be assigned
# File lib/proton_api/models/performance_calculator_request.rb, line 527 def max_percentile_monte_carlo=(max_percentile_monte_carlo) if !max_percentile_monte_carlo.nil? && max_percentile_monte_carlo < 0 fail ArgumentError, 'invalid value for "max_percentile_monte_carlo", must be greater than or equal to 0.' end @max_percentile_monte_carlo = max_percentile_monte_carlo end
Custom attribute writer method with validation @param [Object] mean_percentile_monte_carlo
Value to be assigned
# File lib/proton_api/models/performance_calculator_request.rb, line 427 def mean_percentile_monte_carlo=(mean_percentile_monte_carlo) if !mean_percentile_monte_carlo.nil? && mean_percentile_monte_carlo < 0 fail ArgumentError, 'invalid value for "mean_percentile_monte_carlo", must be greater than or equal to 0.' end @mean_percentile_monte_carlo = mean_percentile_monte_carlo end
Custom attribute writer method with validation @param [Object] min_percentile_monte_carlo
Value to be assigned
# File lib/proton_api/models/performance_calculator_request.rb, line 437 def min_percentile_monte_carlo=(min_percentile_monte_carlo) if !min_percentile_monte_carlo.nil? && min_percentile_monte_carlo < 0 fail ArgumentError, 'invalid value for "min_percentile_monte_carlo", must be greater than or equal to 0.' end @min_percentile_monte_carlo = min_percentile_monte_carlo end
Custom attribute writer method with validation @param [Object] moving_average_n_day
Value to be assigned
# File lib/proton_api/models/performance_calculator_request.rb, line 447 def moving_average_n_day=(moving_average_n_day) if !moving_average_n_day.nil? && moving_average_n_day < 1 fail ArgumentError, 'invalid value for "moving_average_n_day", must be greater than or equal to 1.' end @moving_average_n_day = moving_average_n_day end
Custom attribute writer method with validation @param [Object] n_day_returns
Value to be assigned
# File lib/proton_api/models/performance_calculator_request.rb, line 467 def n_day_returns=(n_day_returns) if !n_day_returns.nil? && n_day_returns < 1 fail ArgumentError, 'invalid value for "n_day_returns", must be greater than or equal to 1.' end @n_day_returns = n_day_returns end
Custom attribute writer method with validation @param [Object] n_path_monte_carlo
Value to be assigned
# File lib/proton_api/models/performance_calculator_request.rb, line 507 def n_path_monte_carlo=(n_path_monte_carlo) if !n_path_monte_carlo.nil? && n_path_monte_carlo < 1 fail ArgumentError, 'invalid value for "n_path_monte_carlo", must be greater than or equal to 1.' end @n_path_monte_carlo = n_path_monte_carlo end
Custom attribute writer method with validation @param [Object] n_rolling_max_drawdown
Value to be assigned
# File lib/proton_api/models/performance_calculator_request.rb, line 487 def n_rolling_max_drawdown=(n_rolling_max_drawdown) if !n_rolling_max_drawdown.nil? && n_rolling_max_drawdown < 1 fail ArgumentError, 'invalid value for "n_rolling_max_drawdown", must be greater than or equal to 1.' end @n_rolling_max_drawdown = n_rolling_max_drawdown end
Custom attribute writer method with validation @param [Object] n_rolling_volatility
Value to be assigned
# File lib/proton_api/models/performance_calculator_request.rb, line 517 def n_rolling_volatility=(n_rolling_volatility) if !n_rolling_volatility.nil? && n_rolling_volatility < 1 fail ArgumentError, 'invalid value for "n_rolling_volatility", must be greater than or equal to 1.' end @n_rolling_volatility = n_rolling_volatility end
Custom attribute writer method with validation @param [Object] num_sim_monte_carlo
Value to be assigned
# File lib/proton_api/models/performance_calculator_request.rb, line 497 def num_sim_monte_carlo=(num_sim_monte_carlo) if !num_sim_monte_carlo.nil? && num_sim_monte_carlo < 1 fail ArgumentError, 'invalid value for "num_sim_monte_carlo", must be greater than or equal to 1.' end @num_sim_monte_carlo = num_sim_monte_carlo end
Custom attribute writer method checking allowed values (enum). @param [Object] period_type
Object to be assigned
# File lib/proton_api/models/performance_calculator_request.rb, line 477 def period_type=(period_type) validator = EnumAttributeValidator.new('String', ['Y', 'Q', 'M', 'D']) unless validator.valid?(period_type) fail ArgumentError, 'invalid value for "period_type", must be one of #{validator.allowable_values}.' end @period_type = period_type end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/proton_api/models/performance_calculator_request.rb, line 659 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end
Returns the string representation of the object @return [String] String presentation of the object
# File lib/proton_api/models/performance_calculator_request.rb, line 647 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/proton_api/models/performance_calculator_request.rb, line 395 def valid? annualized_return_period_validator = EnumAttributeValidator.new('String', ['Y', 'Q', 'M', 'D']) return false unless annualized_return_period_validator.valid?(@annualized_return_period) return false if !@mean_percentile_monte_carlo.nil? && @mean_percentile_monte_carlo < 0 return false if !@min_percentile_monte_carlo.nil? && @min_percentile_monte_carlo < 0 return false if !@moving_average_n_day.nil? && @moving_average_n_day < 1 active_premium_period_validator = EnumAttributeValidator.new('String', ['Y', 'Q', 'M', 'D']) return false unless active_premium_period_validator.valid?(@active_premium_period) return false if @stat_name.nil? return false if !@n_day_returns.nil? && @n_day_returns < 1 period_type_validator = EnumAttributeValidator.new('String', ['Y', 'Q', 'M', 'D']) return false unless period_type_validator.valid?(@period_type) return false if !@n_rolling_max_drawdown.nil? && @n_rolling_max_drawdown < 1 return false if !@num_sim_monte_carlo.nil? && @num_sim_monte_carlo < 1 return false if !@n_path_monte_carlo.nil? && @n_path_monte_carlo < 1 return false if !@n_rolling_volatility.nil? && @n_rolling_volatility < 1 return false if !@max_percentile_monte_carlo.nil? && @max_percentile_monte_carlo < 0 true end