using System; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Http; using Core.Main; using Core.Helper; using Core.Main.DataObjects.PTMagicData; using Core.MarketAnalyzer; namespace Monitor.Pages { public class SettingsSingleMarketSettingsModel : _Internal.BasePageModelSecure { public SingleMarketSetting SingleMarketSetting = null; public string SettingName = ""; public void OnGet() { // Initialize Config base.Init(); BindData(); } private void BindData() { SettingName = this.GetStringParameter("gs", ""); if (!SettingName.Equals("")) { SingleMarketSetting = PTMagicConfiguration.AnalyzerSettings.SingleMarketSettings.Find(sms => SystemHelper.StripBadCode(sms.SettingName, Constants.WhiteListNames).Equals(SettingName)); } else { SingleMarketSetting = new SingleMarketSetting(); SingleMarketSetting.SettingName = "New Setting"; } } public string GetMarketTrendSelection(Trigger t) { string result = ""; foreach (MarketTrend mt in PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.MarketTrends.FindAll(m => m.Platform.Equals("Exchange", StringComparison.InvariantCultureIgnoreCase))) { string selected = ""; if (t != null) { if (t.MarketTrendName.Equals(mt.Name, StringComparison.InvariantCultureIgnoreCase)) { selected = " selected=\"selected\""; } } result += "" + mt.Name + ""; } return result; } public string GetOffTriggerMarketTrendSelection(OffTrigger ot) { string result = ""; foreach (MarketTrend mt in PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.MarketTrends.FindAll(m => m.Platform.Equals("Exchange", StringComparison.InvariantCultureIgnoreCase))) { string selected = ""; if (ot != null) { if (ot.MarketTrendName.Equals(mt.Name, StringComparison.InvariantCultureIgnoreCase)) { selected = " selected=\"selected\""; } } result += "" + mt.Name + ""; } return result; } public string GetMarketTrendRelationSelection(Trigger t) { string result = ""; string selected = ""; if (t != null) { if (t.MarketTrendRelation.Equals("Relative", StringComparison.InvariantCultureIgnoreCase)) { selected = " selected=\"selected\""; } } result += "Relative"; if (t != null) { if (t.MarketTrendRelation.Equals("Absolute", StringComparison.InvariantCultureIgnoreCase)) { selected = " selected=\"selected\""; } else { selected = ""; } } result += "Absolute"; return result; } public string GetOffTriggerMarketTrendRelationSelection(OffTrigger ot) { string result = ""; string selected = ""; if (ot != null) { if (ot.MarketTrendRelation.Equals("Relative", StringComparison.InvariantCultureIgnoreCase)) { selected = " selected=\"selected\""; } } result += "Relative"; if (ot != null) { if (ot.MarketTrendRelation.Equals("RelativeTrigger", StringComparison.InvariantCultureIgnoreCase)) { selected = " selected=\"selected\""; } } result += "Relative to trigger price"; if (ot != null) { if (ot.MarketTrendRelation.Equals("Absolute", StringComparison.InvariantCultureIgnoreCase)) { selected = " selected=\"selected\""; } else { selected = ""; } } result += "Absolute"; return result; } public string GetValueModes(string propertyKey) { string result = ""; string selected = ""; if (propertyKey.IndexOf("_OFFSET", StringComparison.InvariantCultureIgnoreCase) == -1) { selected = " selected=\"selected\""; } result += "Flat value"; if (propertyKey.EndsWith("_OFFSET", StringComparison.InvariantCultureIgnoreCase)) { selected = " selected=\"selected\""; } else { selected = ""; } result += "Offset by flat value"; if (propertyKey.EndsWith("_OFFSETPERCENT", StringComparison.InvariantCultureIgnoreCase)) { selected = " selected=\"selected\""; } else { selected = ""; } result += "Offset by percent"; return result; } } }