| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
-
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace MuchInfo.Chart.Data.Models
- {
- /// <summary>
- /// 公式模型与编辑器中FormulaBase对应,保存一些图表参数。
- /// </summary>
- public class FormulaModel
- {
- /// <summary>
- /// 获取或设置编辑器中转换的用于生图表数据
- /// </summary>
- public List<IndicatorModel> IndicatorList { get; set; }
- /// <summary>
- /// 公式名称
- /// </summary>
- public string FormulaName { get; set; }
- public FormulaModel()
- {
- }
- public FormulaModel(string formulaName)
- {
- this.FormulaName = formulaName;
- }
- /// <summary>
- /// 是否是主图
- /// </summary>
- public bool IsMain
- {
- get
- {
- if (string.IsNullOrWhiteSpace(FormulaName)) return false;
- else
- {
- return FormulaName.ToLower() == "main";
- }
- }
- }
- /// <summary>
- /// 是否是成交量
- /// </summary>
- public bool IsVolume
- {
- get
- {
- if (string.IsNullOrWhiteSpace(FormulaName)) return false;
- else
- {
- return FormulaName.ToLower() == "vol";
- }
- }
- }
- /// <summary>
- /// 是否为主图指标
- /// </summary>
- public bool IsMainIndicator { get; set; }
- /// <summary>
- /// 编辑副图指标
- /// </summary>
- public ProgramModel EditProgram { get; set; }
- /// <summary>
- /// 设置计算公式的参数
- /// </summary>
- public void SetParamValue()
- {
- //formulaModel.FormulaName = this.Name;
- if (EditProgram == null || EditProgram.CustomParams==null || !EditProgram.CustomParams.Any()) return;
- string paramsStr = "(";
- foreach (var paramsName in EditProgram.CustomParams.Keys)
- {
- if (!EditProgram.DefaultParams.ContainsKey(paramsName)) throw new Exception("公式默认参数获取异常!");
- paramsStr += (string.IsNullOrEmpty(EditProgram.CustomParams[paramsName].Value)
- ? EditProgram.DefaultParams[paramsName]
- : EditProgram.CustomParams[paramsName].Value) + ",";
- }
- paramsStr = paramsStr.TrimEnd(',') + ")";
- this.FormulaName = EditProgram.Name + (paramsStr.Equals("()") ? string.Empty : paramsStr);
- }
- }
- }
|