Ejemplo n.º 1
0
 public void OnValueUpdate(Settings.Setting setting, object value)
 {
     if (setting == Settings.Setting.Shadows)
     {
         OnLoad();
     }
 }
Ejemplo n.º 2
0
        public SpinBox(string name, Settings.Setting<int> selectedValue, int _min, int _max, bool selectable = true)
            : base(name, selectable)
        {
            SelectedChoice = selectedValue;
            min = _min;
            max = _max;

            OnSelect += () =>
            {
                if (!Active)
                {
                    ActiveChanged = true;
                    Active = true;
                }
                else
                    ActiveChanged = false;
            };
            OnUnSelect += () =>
            {
                if (Active)
                {
                    ActiveChanged = true;
                    Active = false;
                }
                else
                    ActiveChanged = false;
            };

            OnSelect += SelectionChanged;
            OnUnSelect += SelectionChanged;
        }
Ejemplo n.º 3
0
 public CheckBox(string name, Settings.Setting<bool> value = null, bool selectable = true )
     : base(name, selectable)
 {
     this.value = value;
     if (this.value != null)
         OnSelect += () => this.value.Value = !this.value.Value;
 }
        private void CalculateInstrumentMarginData(Settings.Setting setting, Settings.Account account, Settings.Instrument instrument, DateTime tradeDay, MarginData marginData)
        {
            var tradePolicyDetail = setting.GetTradePolicyDetail(instrument.Id, account.TradePolicyId, tradeDay);

            marginData.Margin            += account.RateMarginO * tradePolicyDetail.MarginO;
            marginData.MarginLocked      += account.RateMarginLockO * tradePolicyDetail.MarginLockedO;
            marginData.MarginNight       += account.RateMarginO * tradePolicyDetail.MarginO;
            marginData.MarginNightLocked += account.RateMarginLockO * tradePolicyDetail.MarginLockedO;
        }
Ejemplo n.º 5
0
 public void OnValueUpdate(Settings.Setting setting, object value)
 {
     if (setting == Settings.Setting.MasterVolume || setting == Settings.Setting.SFXVolume ||
         setting == Settings.Setting.UIVolume || setting == Settings.Setting.Antialiasing
         )
     {
         OnLoad();
     }
 }
Ejemplo n.º 6
0
 internal HistoryOrderRecover(Account account, Guid instrumentId, List <Guid> affectedOrders, List <Guid> deletedOrders, Settings.Setting setting)
 {
     _account        = account;
     _instrumentId   = instrumentId;
     _affectedOrders = affectedOrders;
     _deletedOrders  = deletedOrders;
     _setting        = setting;
     _InstrumentDayClosePriceFactory = new InstrumentDayClosePriceFactory(_account);
 }
Ejemplo n.º 7
0
 internal HistoryOrderDeleter(Order order, Settings.Setting setting, bool isPayForInstalmentDebitInterest)
 {
     this.Account = order.Owner.Owner;
     _order       = order;
     _isPayForInstalmentDebitInterest = isPayForInstalmentDebitInterest;
     _physicalOrder       = _order as PhysicalOrder;
     _currencyId          = DBResetRepository.GetCurrencyId(this.Account.Id, order.Instrument().Id, _order.Owner.ExecuteTime.Value);
     _historyOrderRecover = new HistoryOrderRecover(this.Account, _order.Instrument().Id, OrderHelper.GetAffectedOrders(_order), new List <Guid> {
         order.Id
     }, setting);
 }
        private decimal CalculateOrderMargin(Order order, Settings.Setting setting, Settings.Instrument instrument, Settings.Account account, DateTime tradeDay, UsableMarginPrice usableMarginPrice)
        {
            Guid    currencyId   = this.GetCurrencyId(account, instrument);
            var     currencyRate = setting.GetCurrencyRate(instrument.CurrencyId, currencyId);
            decimal?rateIn       = currencyRate == null ? (decimal?)null : currencyRate.RateIn;
            decimal?rateOut      = currencyRate == null ? (decimal?)null : currencyRate.RateOut;
            var     currency     = setting.GetCurrency(currencyId, tradeDay);
            int     decimals     = currency.Decimals;
            Price   refPrice     = this.GetRefPrice(usableMarginPrice, order.IsBuy, instrument.IsNormal);

            return(Calculator.MarginCalculator.CalculateRptMargin((int)instrument.MarginFormula, order.LotBalance, order.Owner.ContractSize(tradeDay), order.ExecutePrice, rateIn, rateOut, decimals, refPrice));
        }
        private MarginData CreateMarginData(Settings.Setting setting, Settings.Account account, Settings.Instrument instrument, DateTime tradeDay)
        {
            var        tradePolicyDetail = setting.GetTradePolicyDetail(instrument.Id, account.TradePolicyId, tradeDay);
            MarginData marginData        = new MarginData();

            marginData.AccountId     = account.Id;
            marginData.InstrumentId  = instrument.Id;
            marginData.CurrencyId    = account.IsMultiCurrency ? instrument.CurrencyId : account.CurrencyId;
            marginData.MarginFormula = (int)instrument.MarginFormula;
            marginData.TradePolicyId = tradePolicyDetail.TradePolicy.ID;
            return(marginData);
        }
Ejemplo n.º 10
0
        internal static decimal CalculateNecessaryMargin(Settings.Setting setting, Guid volumeNecessaryId, decimal netLot, decimal tradePolicyMargin, bool isNight)
        {
            var     volumeNecessary = setting.GetVolumeNecessary(volumeNecessaryId, null);
            decimal necessary       = 0m;

            if (volumeNecessary.Option == Settings.VolumeNecessaryOption.Progessive)
            {
                necessary = volumeNecessary.CalclateNecessaryWhenExistsVolumeNecessaryDetails(netLot, tradePolicyMargin, isNight);
                if (volumeNecessary.VolumeNecessaryDetails.Count == 0)
                {
                    necessary = netLot * tradePolicyMargin;
                }
            }
            else
            {
                necessary = volumeNecessary.CalculateNecessaryForFlat(netLot, tradePolicyMargin, isNight);
            }
            return(necessary);
        }
Ejemplo n.º 11
0
        internal static void Process(Transaction tran, Settings.Setting setting, DateTime tradeDay)
        {
            var      account             = tran.Owner;
            var      historyOrderRecover = new HistoryOrderRecover(account, tran.InstrumentId, GetAffectedOrders(tran), new List <Guid>(), setting);
            DateTime beginResetTradeDay  = tradeDay;
            DateTime?lastResetTradeDay   = account.LastResetDay;

            if (lastResetTradeDay == null || beginResetTradeDay > lastResetTradeDay)
            {
                RecoverBalance(new Dictionary <DateTime, decimal>(), tran, CalculateNotRecoverOrderCost(tran));
            }
            else
            {
                var     deltaAmountPerTradeDayDict = historyOrderRecover.RecoverDay(beginResetTradeDay, lastResetTradeDay.Value);
                decimal orderExecuteFee            = CalculateCost(tran);
                RecoverAccountBalanceDayHistory(deltaAmountPerTradeDayDict, orderExecuteFee, tran);
                RecoverBalance(deltaAmountPerTradeDayDict, tran, orderExecuteFee);
                UpdateInstalmentOrderDebitInterest(tran, setting, beginResetTradeDay);
                OrderUpdater.Default.UpdateOrderInterestPerLotAndStoragePerLot(tran, lastResetTradeDay.Value);
            }
            RemoveCompletedOrdersFromCache(tran);
        }
Ejemplo n.º 12
0
        private static void UpdateInstalmentOrderDebitInterest(Transaction tran, Settings.Setting setting, DateTime?tradeDay)
        {
            if (!tran.IsPhysical)
            {
                return;
            }
            DateTime lastTradeDay = DateTime.Now.Date;
            int      currencyDecimals;

            if (tran.Owner.IsMultiCurrency)
            {
                var currency = setting.GetCurrency(tran.CurrencyId);
                currencyDecimals = currency.Decimals;
            }
            else
            {
                currencyDecimals = tran.Owner.Setting(tradeDay).Currency(tradeDay).Decimals;
            }
            foreach (var eachOrder in tran.Orders)
            {
                Physical.PhysicalOrder physicalOrder = (Physical.PhysicalOrder)eachOrder;
                if (physicalOrder.Instalment == null)
                {
                    return;
                }
                var instalmentPolicyDetail = physicalOrder.Instalment.InstalmentPolicyDetail(null);
                foreach (var eachInstalmentDetail in physicalOrder.Instalment.InstalmentDetails)
                {
                    if (eachInstalmentDetail.PaymentDateTimeOnPlan >= lastTradeDay)
                    {
                        continue;
                    }
                    eachInstalmentDetail.DebitInterest = InstalmentManager.CalculateDebitInterest(eachInstalmentDetail.Principal,
                                                                                                  eachInstalmentDetail.Interest, (lastTradeDay - eachInstalmentDetail.PaymentDateTimeOnPlan.Value).Days,
                                                                                                  instalmentPolicyDetail.InterestRate, instalmentPolicyDetail.DebitInterestType,
                                                                                                  instalmentPolicyDetail.DebitInterestRatio, instalmentPolicyDetail.DebitFreeDays, tran.SettingInstrument().InterestYearDays, currencyDecimals);
                }
            }
        }
Ejemplo n.º 13
0
        public static void EditorPersistentDataPathFileInspector(ref Settings.Setting _setting, int _configIndex)
        {
            GUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            bool b_binary = EditorGUILayout.Toggle("Binary", _setting.EditorConfigs[_configIndex].SaveSystemConfig.persistentDataPathFileBinary);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(_setting, b_binary ? "Enable" : "Disable" + " binary on save system");
                _setting.EditorConfigs[_configIndex].SaveSystemConfig.persistentDataPathFileBinary = b_binary;
                EditorUtility.SetDirty(_setting);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            bool b_checksum = EditorGUILayout.Toggle("Checksum", _setting.EditorConfigs[_configIndex].SaveSystemConfig.persistentDataPathFileChecksum);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(_setting, b_binary ? "Enable" : "Disable" + " checksum on save system");
                _setting.EditorConfigs[_configIndex].SaveSystemConfig.persistentDataPathFileChecksum = b_checksum;
                EditorUtility.SetDirty(_setting);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            PersistentDataPathFileShuffleTypes b_shuffleType = (PersistentDataPathFileShuffleTypes)(EditorGUILayout.EnumPopup("Shuffle", _setting.EditorConfigs[_configIndex].SaveSystemConfig.persistentDataPathFileShuffle));

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(_setting, "Change shuffle type on save system");
                _setting.EditorConfigs[_configIndex].SaveSystemConfig.persistentDataPathFileShuffle = b_shuffleType;
                EditorUtility.SetDirty(_setting);
            }
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 14
0
 public UIValueEditor(int x, int y, int width, Settings.Setting targetSetting)
     : base(x, y, width, 40)
 {
     setting = targetSetting;
     var box = new TextBox
     {
         Location = new Point(0, 20),
         BackColor = UITheme.buttonBottom,
         ForeColor = Color.White,
         BorderStyle = BorderStyle.FixedSingle
     };
     textBox = box;
     textBox.TextChanged += textBox_TextChanged;
     textBox.Text = targetSetting.value.ToString();
     base.Controls.Add(textBox);
 }
Ejemplo n.º 15
0
 public UICheckBox(int x, int y, string buttonText, Settings.Setting targetSetting)
     : base(x, y, 70, 20)
 {
     _buttonText = buttonText;
     box = new Rectangle(3, 3, 13, 13);
     setting = targetSetting;
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Loads the Master Config XML file into an ConfigMasterParsed Object
        /// </summary>
        /// <param name="ConfigMasterFilename"></param>
        /// <returns></returns>
        public static ConfigMasterParsed LoadConfigMasterFile(string ConfigMasterFilename)
        {
            var CMO = new ConfigMasterParsed();

            var XMasterFile = XDocument.Load(ConfigMasterFilename);

            //// Load registered Environments
            //foreach (var env in XMasterFile.Root.Element("Environments").Elements("Environment"))
            //{
            //    CMO.ListOfEnvironments.Add(new Models.Environment()
            //    {
            //        Title = env.Attribute("Title").Value,
            //        Description = env.Attribute("Description").Value
            //    });
            //}

            //// Load registered Servers
            //foreach (var env in XMasterFile.Root.Element("Servers").Elements("Server"))
            //{
            //    CMO.ListOfServers.Add(new Models.Computer()
            //    {
            //        ComputerName = env.Attribute("ComputerName").Value,
            //        Description = env.Attribute("Description").Value
            //    });
            //}


            //// Load registered Components
            //foreach (var env in XMasterFile.Root.Element("Components").Elements("Component"))
            //{
            //    CMO.ListOfComponents.Add(new Models.Component()
            //    {
            //        Title = env.Attribute("Title").Value,
            //        Description = env.Attribute("Description").Value
            //    });
            //}

            // Load Recipe
            CMO.GlobalRecipe = new ConfigFileInstances();

            foreach (var env in XMasterFile.Root.Element("Recipes").Elements("Environment"))
            {
                foreach (var comp in env.Elements("Component"))
                {
                    foreach (var svr in comp.Elements("Server"))
                    {
                        var newSvr = new ConfigFileInstances.ConfigFileInstance()
                        {
                            Environment    = env.Attribute("Title").Value,
                            Component      = comp.Attribute("Title").Value,
                            ComputerName   = svr.Attribute("ComputerName").Value,
                            ConfigFilePath = svr.Attribute("ConfigFilePath").Value
                        };

                        CMO.GlobalRecipe.ListOfRecipeConfigFiles.Add(newSvr);
                    }
                }
            }

            // Load Settings
            CMO.GlobalSettings = new Settings();
            foreach (var sett in XMasterFile.Root.Element("Settings").Elements("Setting"))
            {
                var newSetting = new Settings.Setting();
                newSetting.Name = sett.Attribute("Name").Value;
                newSetting.Key  = sett.Attribute("Key").Value;
                newSetting.GlobalDefaultValue = sett.Attribute("GlobalDefaultValue").Value;

                foreach (var applicComp in sett.Element("ApplicableComponents").Elements("Component"))
                {
                    newSetting.ListOfApplicableComponents.Add(applicComp.Attribute("Title").Value);
                }

                foreach (var overrideSetting in sett.Elements("Override"))
                {
                    var overridSet = new Settings.Setting.Overrides()
                    {
                        OverrideValue = overrideSetting.Attribute("OverrideValue").Value,
                        Component     = overrideSetting?.Element("Component")?.Attribute("Title")?.Value,
                        Environment   = overrideSetting?.Element("Environment")?.Attribute("Title")?.Value,
                        Server        = overrideSetting?.Element("Server")?.Attribute("ComputerName")?.Value,
                    };

                    newSetting.ListOfOverrides.Add(overridSet);
                }

                CMO.GlobalSettings.ListOfSettings.Add(newSetting);
            }


            return(CMO);
        }
Ejemplo n.º 17
0
        public static Tuple <Price, Price> ParseBuyAndSellPrice(DataRow dr, Guid instrumentId, DateTime?tradeDay, Settings.Setting setting)
        {
            var   instrument = setting.GetInstrument(instrumentId, tradeDay);
            Price buyPrice   = dr.GetColumn <string>("BuyPrice").CreatePrice(instrument);
            Price sellPrice  = dr.GetColumn <string>("SellPrice").CreatePrice(instrument);

            return(Tuple.Create(buyPrice, sellPrice));
        }
Ejemplo n.º 18
0
 internal InstrumentTradeDaySetting(IDBRow dr, Guid instrumentId, DateTime tradeDate, Settings.Setting setting)
 {
     this.InterestMultiple                = dr.GetColumn <int>("InterestMultiple");
     this.BeginTime                       = dr.GetColumn <DateTime>("BeginTime");
     this.ResetTime                       = dr.GetColumn <DateTime>("ResetTime");
     this.ValueDate                       = dr.GetColumn <DateTime?>("ValueDate");
     this.ShouldValueCurrentDayPL         = dr.GetColumn <bool>("ShouldValueCurrentDayPL");
     this.IsUseSettlementPriceForInterest = dr.GetColumn <bool>("IsUseSettlementPriceForInterest");
     this.StoragePerLotInterestRateBuy    = dr.GetColumn <decimal>("StoragePerLotInterestRateBuy");
     this.StoragePerLotInterestRateSell   = dr.GetColumn <decimal>("StoragePerLotInterestRateSell");
     this.InterestRateBuy                 = dr.GetColumn <decimal>("InterestRateBuy");
     this.InterestRateSell                = dr.GetColumn <decimal>("InterestRateSell");
     this.InstalmentInterestRateBuy       = dr.GetColumn <decimal>("InstalmentInterestRateBuy");
     this.InstalmentInterestRateSell      = dr.GetColumn <decimal>("InstalmentInterestRateSell");
     this.IsMonthLastDay                  = dr.GetColumn <bool>("IsMonthLastDay");
     this.WeekDay = dr.GetColumn <int>("WeekDay");
     this.IsInterestUseAccountCurrency = dr.GetColumn <bool>("IsInterestUseAccountCurrency");
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Loads the Master Config XML file into an ConfigMasterParsed Object
        /// </summary>
        /// <param name="ConfigMasterFilename"></param>
        /// <returns></returns>
        public static ConfigMasterParsed LoadConfigMasterFile(string ConfigMasterFilename)
        {
            var CMO = new ConfigMasterParsed();

            var XMasterFile = XDocument.Load(ConfigMasterFilename);

            //// Load registered Environments
            //foreach (var env in XMasterFile.Root.Element("Environments").Elements("Environment"))
            //{
            //    CMO.ListOfEnvironments.Add(new Models.Environment()
            //    {
            //        Title = env.Attribute("Title").Value,
            //        Description = env.Attribute("Description").Value
            //    });
            //}

            //// Load registered Servers
            //foreach (var env in XMasterFile.Root.Element("Servers").Elements("Server"))
            //{
            //    CMO.ListOfServers.Add(new Models.Computer()
            //    {
            //        ComputerName = env.Attribute("ComputerName").Value,
            //        Description = env.Attribute("Description").Value
            //    });
            //}


            //// Load registered Components
            //foreach (var env in XMasterFile.Root.Element("Components").Elements("Component"))
            //{
            //    CMO.ListOfComponents.Add(new Models.Component()
            //    {
            //        Title = env.Attribute("Title").Value,
            //        Description = env.Attribute("Description").Value
            //    });
            //}

            // Load Recipe
            CMO.GlobalRecipe = new ConfigFileInstances();

            foreach (var env in XMasterFile.Root.Element("Recipes").Elements("Environment"))
            {

                foreach (var comp in env.Elements("Component"))
                {
                    
                    foreach (var svr in comp.Elements("Server"))
                    {

                        var newSvr = new ConfigFileInstances.ConfigFileInstance()
                        {
                            Environment = env.Attribute("Title").Value,
                            Component = comp.Attribute("Title").Value,
                            ComputerName = svr.Attribute("ComputerName").Value,
                            ConfigFilePath = svr.Attribute("ConfigFilePath").Value
                        };

                        CMO.GlobalRecipe.ListOfRecipeConfigFiles.Add(newSvr);
                        
                    }
                     
                }
 
            }

            // Load Settings
            CMO.GlobalSettings = new Settings();
            foreach (var sett in XMasterFile.Root.Element("Settings").Elements("Setting"))
            {
                var newSetting = new Settings.Setting();
                newSetting.Name = sett.Attribute("Name").Value;
                newSetting.Key = sett.Attribute("Key").Value;
                newSetting.GlobalDefaultValue = sett.Attribute("GlobalDefaultValue").Value;

                foreach (var applicComp in sett.Element("ApplicableComponents").Elements("Component"))
                {
                    newSetting.ListOfApplicableComponents.Add(applicComp.Attribute("Title").Value);
                }

                foreach (var overrideSetting in sett.Elements("Override"))
                {
                    var overridSet = new Settings.Setting.Overrides()
                    {
                        OverrideValue = overrideSetting.Attribute("OverrideValue").Value,
                        Component = overrideSetting?.Element("Component")?.Attribute("Title")?.Value,
                        Environment = overrideSetting?.Element("Environment")?.Attribute("Title")?.Value,
                        Server = overrideSetting?.Element("Server")?.Attribute("ComputerName")?.Value,
                    };

                    newSetting.ListOfOverrides.Add(overridSet);
                }

                CMO.GlobalSettings.ListOfSettings.Add(newSetting);
            }


            return CMO;
        }