using Newtonsoft.Json; using System.Reflection; using YLErp.Configuration; using YLErp.Configuration.Enums; using static YLErp.DBModels.Consts.ConsReport; namespace YLErp { public static class PS { static ErpConfig _erpConfig; public static ProjectConfig Config { get; private set; } public static void ResetConfig(string jsonConfig) { if (string.IsNullOrWhiteSpace(jsonConfig)) { throw new ArgumentNullException(nameof(jsonConfig)); } _erpConfig = JsonHelper.Deserialize(jsonConfig); Config = new ProjectConfig(_erpConfig); } public static IErpConfig GetErpConfig() { return _erpConfig; } public static bool SetConfig(string name, string value) { if (name is null) { throw new ArgumentNullException(nameof(name)); } var index = name.LastIndexOf('.'); if (index >= 0) { name = name.Substring(index + 1); } var p = typeof(ErpConfig).GetProperty(name, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public); if (p == null) { return false; } var ptype = p.PropertyType; object objValue; if (ptype.IsEnum) { objValue = Enum.Parse(ptype, value); } else if (ptype == typeof(bool)) { objValue = value == "true"; } else if (ptype == typeof(int)) { objValue = int.TryParse(value, out var n) ? n : default; } else if (ptype == typeof(double)) { objValue = double.TryParse(value, out var n) ? n : default; } else if (ptype == typeof(decimal)) { objValue = decimal.TryParse(value, out var n) ? n : default; } else { objValue = Convert.ChangeType(value, ptype); } p.SetValue(_erpConfig, objValue); return true; } class ErpConfig : IErpConfig { /// /// /// public CompanyEnum Company { get; set; } /// /// 公司名称缩写 /// public string CompanyAbbreviation { get; set; } = "Default"; /// /// 公司名称 /// public string CompanyName { get; set; } = "公司"; /// /// 公司英文名称 /// public string CompanyEnName { get; set; } = "Company"; /// /// 公司简称,如:国泰君安 /// public string CompanyShortName { get; set; } = "公司"; /// /// 公司全名 /// public string CompanyFullName { get; set; } = "公司"; /// /// 波动率模式 /// public VolModeEnum VolMode { get; set; } = VolModeEnum.TradeVol; /// /// 是否检查密码符合监管要求 /// public bool CheckPassword { get; set; } /// /// 是否在风险对冲页面采用自动对冲策略 /// [JsonProperty("UseHedgingRule")] public bool IsUseHedgingRule { get; set; } /// /// 自动生成交易确认书、结算单、提前终止确认书等 /// [JsonProperty("AutoGenerateContracts")] public bool IsAutoGenerateContracts { get; set; } /// /// 是否支持简洁版的出入金导入 /// public bool SupportEntryExitSimpleVersion { get; set; } = true; /// /// RealTime相关信息通知的角色 /// public string RealTimeServiceNotifyRoles { get; set; } = ""; /// /// 是否显示RealTime相关信息通知 /// public bool ShowRealTimeServiceNotify { get; set; } /// /// 资金记录页面是否显示和客户的其他资金往来记录 /// [JsonProperty("ShowOtherClientCash")] public bool IsShowOtherClientCash { get; set; } = false; /// /// 部署组件版本 /// public ComponentVersion ComponentVersion { get; set; } = ComponentVersion.MarketMaker; public bool CanSelectCreditVariety { get; set; } = true; /// /// 银行账户只能在下拉中选择 /// [JsonProperty("BankOnlyDropDown")] public bool IsBankOnlyDropDown { get; set; } /// /// 授信控制 /// [JsonProperty("IsCreditLimit")] public bool IsCreditLimit { get; set; } /// /// /// [JsonProperty("EodSendMaturityEmail")] public bool IsEodSendMaturityEmail { get; set; } = true; /// /// /// public bool UseOldGenerateBook { get; set; } = true; /// /// /// public bool ShowAccruedTotalPnL { get; set; } /// /// /// public bool IsExportEntryexit { get; set; } /// /// /// public bool UseSingleLogin { get; set; } public bool UseDisplayNotional { get; set; } /// /// /// public bool IsShowCompanyCash { get; set; } /// /// 是否在盯市报告资金状态里面显示总盈亏 /// public bool TradeMarketShowTotalNetSettlement { get; set; } /// /// /// [JsonProperty("AmendableAfterConfirm")] public bool IsAmendableAfterConfirm { get; set; } /// /// 是否是在确认书生成后才能执行 /// public bool ExecuteAfterGeneratedConfirmDoc { get; set; } = true; /// /// 美式提前行权是否和到期行权用相同的结算单模板),默认值为True /// [JsonProperty("SingleExecutionTemplate")] public bool IsSingleExecutionTemplate { get; set; } = true; /// /// GenerateAmendDoc如果为true,在保存修改信息时,生成一个交易变更确认书文档并下载 /// [JsonProperty("GenerateAmendDoc")] public bool IsGenerateAmendDoc { get; set; } = true; /// /// 持仓市值是否进行四舍五入处理 /// public bool IsPVRounded { get; set; } /// /// 自定义交易收盘时是否跳过验证自定义风险指标 /// public bool IsMustRiskManual { get; set; } /// /// 模板或者其他相关文件的路径 /// public string DocPath { get; set; } /// /// 追保通知里是否加上额外追保 /// public bool NeedAdditionalMargin { get; set; } /// /// 在收盘时使用老的EodPnLExplainer方法 /// public bool UseOldEodPnLExplainer { get; set; } = true; /// /// 平值期权报价,当到期日是非交易日时,是否向前移;如果false,则向后移 /// public bool AtmQuotePreviousBizDayAdjust { get; set; } = true; /// /// 是否采用SkewMap的方法构造波动率,目前只有光大光子采用此模式 /// public bool SkewMapVolConstruction { get; set; } = false; /// /// 在报价中,TTM是否精确到分钟级别 /// public bool PrecisionOfMinuteInQuote { get; set; } = false; /// /// 波动率曲面上的日期节点的shift规则 /// public VolSurfaceKeyDateShiftEnum VolSurfaceKeyDateShift { get; set; } = VolSurfaceKeyDateShiftEnum.None; /// /// 波动率曲面的期限,是否不包含截止日期 /// 例如,估值日为2019-04-09,1M期限: /// 当VolSurfaceTermExcludeEndDate为true,则到期日为2019-05-08 /// 当VolSurfaceTermExcludeEndDate为false,则到期日为2019-05-09 /// public bool VolSurfaceTermExcludeEndDate { get; set; } = false; /// /// 双向预付金 /// public bool TwoSideMargin { get; set; } = false; /// /// 是否展示计算维持预付金的Spv /// public bool NeedShowSpv { get; set; } = false; /// /// 是否是权益类预付金算法 /// public bool IsStockMargin { get; set; } = false; /// /// 结算报告是否显示持仓预付金 /// public bool PositionDetialShowMargin { get; set; } = false; /// /// TapConsoleWebServer /// public string TapConsoleWebServer { get; set; } /// /// Web Base Url /// public string YLErpWebUrl { get; set; } /// /// 是否使用更加精确的波动率 /// public bool VolMoreAccurate { get; set; } = false; /// /// 是否包含客户端 /// public bool HasClientSide { get; set; } = false; /// /// 客户端是否可以注册 /// public bool HasClientSign { get; set; } = false; /// /// 公司ID(由镒链分配) /// public string CompanyID { get; set; } /// /// 客户上传文件审核是否启用 /// public bool ClientFileAudit { get; set; } = false; /// /// 客户上传文件审核记录 /// public string ClientFileAuditItems { get; set; } /// /// Qdp计算的并行度,小于等于1时代表不并行;该数字不要超过机器的CPU核数 /// public int QdpParallelDegree { get; set; } = 4; /// /// 外部定价引擎服务的Url地址 /// public string ExternalPricingServiceUrl { get; set; } /// /// 确认书用印记录 /// public bool ConfirmBookStampStatus { get; set; } = false; /// /// 板块性质别名配置 /// public string UnderlyingBlockConfig { get; set; } /// /// 交易编号必须大写 /// public bool UpperTradeNumber { get; set; } /// /// 交易编号是否允许修改 /// public bool CanEditTradeNumber { get; set; } /// /// 能否设置和导出成交溢价和了结溢价 /// public bool CanSetTradePremium { get; set; } /// /// 场内期权是否使用行情价收盘 /// public bool ExchangeOptionSettleByPrice { get; set; } /// /// 是否在实时风险中计算凤凰和雪球的所有greeks /// public bool CalcAutocallGreeksInRisk { get; set; } /// /// 多标的组合交易时使用单标的最大名义本金 /// public bool UseStockEqvNotionalMax { get; set; } /// /// 券商环境 /// public bool SecuritiesEnvironment { get; set; } /// /// 证券业报送定期报告最大可报告月 /// public int ReportMaxMonth { get; set; } /// /// 只是用结算确认书页面 /// public bool SettlementPageV2 { get; set; } /// /// FTP连接方式是否为被动模式 /// public bool SAC_FtpUsePassive { get; set; } /// /// 远程地址 /// public string SAC_RemotePath { get; set; } private string _sac_RemotePath_Outbox; /// /// 发件箱远程地址 /// public string SAC_RemotePath_Outbox { get { if (string.IsNullOrWhiteSpace(_sac_RemotePath_Outbox)) { return SAC_RemotePath; } return _sac_RemotePath_Outbox; } set { _sac_RemotePath_Outbox = value; } } /// /// FTP是否启用SSL /// public bool SAC_EnableSsl { get; set; } /// /// 登录远程地址的用户名 /// public string SAC_RemoteUser { get; set; } /// /// 登录远程地址的密码 /// public string SAC_RemotePassword { get; set; } /// /// 金仕达视图附件FTP远程地址 /// public string KingstarView_RemotePath { get; set; } /// /// 金仕达视图附件FTP是否启用SSL /// public bool KingstarView_EnableSsl { get; } /// /// 金仕达视图附件FTP登录远程地址的用户名 /// public string KingstarView_RemoteUser { get; set; } /// /// 金仕达视图附件FTP登录远程地址的密码 /// public string KingstarView_RemotePassword { get; set; } /// /// 金仕达视图附件FTPFTP连接方式是否为被动模式 /// public bool KingstarView_FtpUsePassive { get; set; } /// /// 金仕达视图附件本地存放目录 /// public string KingstarView_LocalViewAttDir { get; set; } /// /// 金仕达视图附件FTP远程文件服务器存放根路径 /// public string KingstarView_RemoteFileRootPath { get; set; } /// /// FDEP收件箱目录 /// public string SAC_FDEPInboxPath { get; set; } /// /// FDEP发件箱目录 /// public string SAC_FDEPOutboxPath { get; set; } /// /// 子系统发件箱目录,只支持本地系统 /// public string SAC_SubSystemOutboxPath { get; set; } /// /// 子系统收件箱目录,只支持本地系统 /// public string SAC_SubSystemInboxPath { get; set; } /// /// 金仕达视图链接字符串 /// public string KingstarViewConnectionString { get; set; } /// /// 金仕达视图链接名 /// public string KingstarViewTableSchema { get; set; } /// /// 证券业报送中定期报告取值模式 /// 1=Db; /// 2=Excel模板; /// 3=Db+Excel模板(该方式中涉及百分比汇总计算时仍使用模板中数据) /// 4=金仕达视图(该方式只涉及互换确认书及存续期的数据) /// 5=Db+金仕达视图 /// 6=Excel+金仕达视图 /// 7=Db+Excel+金仕达视图 /// public SAC_ReportDataSourceEnum SAC_ReportDataSource { get; set; } /// /// 是否隔离报备信息 /// public bool NeedIsolateSACInfo { get; set; } /// /// 严格的权限验证 /// public bool StrictAuthorize { get; set; } public bool DisablePasswordLogin { get; set; } /// /// 风险对冲累积总盈亏是否统计已过期的场内交易 /// public bool RiskAccPnl_SumExpiredExchangeTrades { get; set; } /// /// 收盘配置 /// public string SettlementConfig { get; set; } /// /// 用友科目编码 /// public string YongYouKeMuCode { get; set; } /// /// 成交首日结算波动率扣除比例 /// public string TradeOpenVolOff { get; set; } /// /// 接口审批 /// 0:不开启接口审批 /// 1:仅使用接口审批 /// 2:使用接口审批和系统审批(目前仅控制客户开户管理页面是否显示审批按钮) /// public int InterfaceApprovalMode { get; set; } /// /// 收盘时是否执行数据采集相关逻辑 /// public bool UseSettleDataAcquisition { get; set; } private double _eodVarPvPercent; /// /// EodVar中百分比的默认值; /// public double EodVarPvPercent { get { return _eodVarPvPercent.OtcFormatValue(2); } set { if (value > 1) { value = 0.99; } else if (value <= 0) { value = 0.01; } _eodVarPvPercent = value; } } /// /// 文件上传允许的文件类型(多个类型用'|'分隔),样例:.xlsx|.docx /// public string UploadFileAccepts { get; set; } /// /// 交易定价要素配置(querystring格式) /// public string TradePricingCfg { get; set; } /// /// 是否启用客户名义本金规模 /// public bool UseClientStockEqvNotional { get; set; } /// /// 平滑过渡日历处理模式 /// public SmoothingDaycountMode SmoothingDaycountMode { get; set; } /// /// 销售 模式(销售人员 ,客户经理) /// public SaleMode SaleMode { get; set; } = SaleMode.SaleMen; /// /// 累计转远期:远期多空和买卖方向赋值配置 /// public OptionTypeAndBuySell OptionTypeAndBuySell { get; set; } = OptionTypeAndBuySell.默认; /// /// 远期开仓是否补偿远期价值 /// public ForwardValueIsSupplyOrPay ForwardValueIsSupplyOrPay { get; set; } = ForwardValueIsSupplyOrPay.Type1; /// /// 标的资产信息缓存配置 /// public string UnderlyingCacheCfg { get; set; } /// /// 是否禁止匿名访问文件(比如App_Docs文件夹中的文件) /// public bool DisableAnonymousAccessFiles { get; set; } /// /// 远期交易价格模式 /// public ForwardTradePriceModel ForwardTradePriceModel { get; set; } /// /// 确认成交,是否进行“资金状况”提示 /// public bool IsAvailableForClient { get; set; } /// /// 收盘时交易是否自动延期结算 /// public bool IsAutoDelaySettlement { get; set; } /// /// (累计期权)使用'杠杆倍数 /// public bool AccumulatorShowMultiplier1 { get; set; } public bool IsTradeCheckInfo { get; set; } public bool IsPVIncludePrincipal { get; set; } public bool IsTradeSinglePriceCalcu { get; set; } /// /// 实时风险-跳过特定交易类型的计算 /// public string RealtimeRisk_SkipTradeTypes { get; set; } /// /// 持仓使用固定预付金比例计算是否使用期初价格 /// public bool EodFixedMarginUseSpotPrice { get; set; } public string SalesCommissionCalculation { get; set; } /// /// 启用外部API /// public bool ExternalAPIForCustomCalcEnable { get; set; } /// /// 计算自定义交易的api地址 /// 目前仅有自定义结构变更和自定义交易计算时会用到 /// 接口文档参考<广期自定义交易结算API对接>文件应该在腾讯文档上 /// public string ExternalAPIForCustomCalc { get; set; } /// /// 调用外部Api计算自定义交易时的超时时间(秒) /// 目前仅有自定义结构变更和自定义交易计算时会用到 /// 接口文档参考<广期自定义交易结算API对接>文件应该在腾讯文档上 /// public int ExternalAPIForCustomCalcTimeOut { get; set; } public bool IsForwardTradeToBuy { get; set; } /// /// 是否需要实时预警 /// public bool IsCalcRealtimeWarning { get; set; } = false; /// /// 自定义报送结构类型 /// public string CustomStructureTypeSm { get; set; } /// /// 亚式期权观察日是否包含起算日 /// public bool AsianOptionObDatesIncludeStartDate { get; set; } /// /// 客户资金表是否要统计其他资金 /// public bool IsSumOthersOnClientCash { get; set; } /// /// 是否允许远程访问admin /// public bool AdminEnableRemote { get; set; } private int _uploadFileSizeLimit = 102400; /// /// 文件上传大小限制(单位KB) /// public int UploadFileSizeLimit { get => _uploadFileSizeLimit; set => _uploadFileSizeLimit = value > 0 ? value : 102400; } /// /// 对冲交易接口网址 /// public string HedgingTradeUrl { get; set; } /// /// 限制用户每分钟可以发送的最大邮件数量,如每分钟内发送的量超过限制, /// 邮件将停留在发件箱,邮件被延迟到下一分钟,并最终被发送成功 /// public int MailMessageRateLimit { get; set; } /// /// 是否支持多币种結算 /// public bool SupportMultiCurrency { get; set; } /// /// 是否支持多日历 /// public bool SupportMultiCalendar { get; set; } /// /// 监管报告-场外业务持仓表-配置 /// public string Supervise_Position { get; set; } /// /// 日终结算时,到期的场内期权持仓自动执行平仓操作 /// public bool AutoCloseExpiriedExchangeOptionPosition { get; set; } /// /// 支持专业版雪球 /// public bool SuppotSnowballSpecialist { get; set; } /// /// 结算报告累计期权每观察日的了结数量是否包含乘数 /// public bool IsSettlementReportAccOptionContainMultiplier { get; set; } /// /// 结算报告配置(querystring格式) /// public string TradeMarketReportCfg { get; set; } /// /// 场内期权波动率类型(Normal:跟随系统波动率模式,ImpliedVol:隐含波动率) /// public ExchangeOptionVolType ExchangeOptionVolType { get; set; } /// /// 是否使用电子章系统对确认书进行自动用印并上传用印文件 /// public bool IsAutoSealAndUploadFiles { get; set; } = false; /// /// 电子用印接口地址 /// public string SealApi { get; set; } = ""; /// /// 电子章用印关键字 /// public string SealKeyWord { get; set; } = ""; /// /// 确认书生成时是否自动用印 /// public bool IsAutoSealAfterGeneratedBook { get; set; } = false; /// /// 收益互换浮动收益端默认为我方收取,并隐藏收支方向 /// public bool SwapFloatingIncomeReceiveOnlyMode { get; set; } = false; /// /// 衡泰内证账号 /// public string HTAccount { get; set; } = ""; public int ReportFileBeginNumber { get; set; } = 0; /// /// 登录Token过期时间(秒) /// 注意:此默认值应与appconfig.xml中的配置保持一致 /// public int LoginTokenExpireSeconds { get; set; } = 3600 * 10; // 默认10小时 /// /// 密码错误次数限制 /// 注意:此默认值应与appconfig.xml中的配置保持一致 /// public int PasswordErrorLimit { get; set; } = 5; // 默认5次 /// /// 密码错误锁定时间(分钟) /// 注意:此默认值应与appconfig.xml中的配置保持一致 /// public int PasswordErrorLockMinutes { get; set; } = 120; // 默认120分钟 /// /// 收盘回调地址 /// public string EodExecCallbackUrl { get; set; } = string.Empty; } } }