Пример #1
0
        public LinearSpectrum(float[] data, int bands, float minFrequency = -1, float maxFrequency = -1)
        {
            int dataReferenceCount = (data.Length - 1) * 2;

            int fromIndex = minFrequency < 0 ? 0 : FrequencyHelper.GetIndexOfFrequency(minFrequency, dataReferenceCount).Clamp(0, data.Length - 1 - bands); // -bands since we need at least enough data to get our bands
            int toIndex   = maxFrequency < 0 ? data.Length - 1 : FrequencyHelper.GetIndexOfFrequency(maxFrequency, dataReferenceCount).Clamp(fromIndex, data.Length - 1);

            int usableSourceData = Math.Max(bands, (toIndex - fromIndex) + 1);

            Bands = new Band[bands];

            double frequenciesPerBand = (double)usableSourceData / bands;
            double frequencyCounter   = 0;

            int index = fromIndex;

            for (int i = 0; i < Bands.Length; i++)
            {
                frequencyCounter += frequenciesPerBand;
                int count = (int)frequencyCounter;

                float[] bandData = new float[count];
                Array.Copy(data, index, bandData, 0, count);
                Bands[i] = new Band(FrequencyHelper.GetFrequencyOfIndex(index, dataReferenceCount),
                                    FrequencyHelper.GetFrequencyOfIndex(index + count, dataReferenceCount),
                                    bandData);

                index            += count;
                frequencyCounter -= count;
            }
        }
Пример #2
0
        public void CreateJiraTasks()
        {
            var queries = JiraRepository.GetAllQueries();

            if (queries != null)
            {
                foreach (var query in queries)
                {
                    if (TaskRepository.IsPlanned(query.Id))
                    {
                        continue;
                    }

                    var latestRun = TaskRepository.GetLatestRunByReference(query.Id)?.ProcessedTime.Value ?? DateTime.Now;

                    if (FrequencyHelper.IsTimeToPlan(query.Frequency, latestRun, out DateTime plannedRunTime))
                    {
                        TaskRepository.CreateTask(new Task
                        {
                            Type        = TaskType.JIRA,
                            Status      = TaskStatus.PLANNED,
                            PlannedTime = plannedRunTime,
                            Reference   = query.Id
                        });
                    }
                }
            }
        }
Пример #3
0
        public GammaSpectrum(float[] data, int bands, float gamma = 2, float minFrequency = -1, float maxFrequency = -1)
        {
            int dataReferenceCount = (data.Length - 1) * 2;

            int fromIndex = minFrequency < 0 ? 0 : FrequencyHelper.GetIndexOfFrequency(minFrequency, dataReferenceCount).Clamp(0, data.Length - 1 - bands); // -bands since we need at least enough data to get our bands
            int toIndex   = maxFrequency < 0 ? data.Length - 1 : FrequencyHelper.GetIndexOfFrequency(maxFrequency, dataReferenceCount).Clamp(fromIndex, data.Length - 1);

            int usableSourceData = Math.Max(bands, (toIndex - fromIndex) + 1);

            Bands = new Band[bands];

            int index = fromIndex;

            for (int i = 0; i < Bands.Length; i++)
            {
                int count = Math.Max(1, (((int)(Math.Pow((i + 1f) / Bands.Length, gamma) * usableSourceData))) - index);

                float[] bandData = new float[count];
                Array.Copy(data, index, bandData, 0, count);
                Bands[i] = new Band(FrequencyHelper.GetFrequencyOfIndex(index, dataReferenceCount),
                                    FrequencyHelper.GetFrequencyOfIndex(index + count, dataReferenceCount),
                                    bandData);

                index += count;
            }
        }
Пример #4
0
        public LogarithmicSpectrum(float[] data, int bands, float minFrequency = -1, float maxFrequency = -1)
        {
            int dataReferenceCount = (data.Length - 1) * 2;

            int fromIndex = minFrequency < 0 ? 0 : FrequencyHelper.GetIndexOfFrequency(minFrequency, dataReferenceCount).Clamp(0, data.Length - 1 - bands); // -bands since we need at least enough data to get our bands
            int toIndex   = maxFrequency < 0 ? data.Length - 1 : FrequencyHelper.GetIndexOfFrequency(maxFrequency, dataReferenceCount).Clamp(fromIndex, data.Length - 1);

            int usableSourceData = Math.Max(bands, (toIndex - fromIndex) + 1);

            Bands = new Band[bands];

            double ratio       = Math.Pow(usableSourceData, 1.0 / bands);
            double calculation = 1;

            int index = fromIndex;

            for (int i = 0; i < Bands.Length; i++)
            {
                calculation *= ratio;
                int count = Math.Max(1, ((int)calculation) - index);

                float[] bandData = new float[count];
                Array.Copy(data, index, bandData, 0, count);
                Bands[i] = new Band(FrequencyHelper.GetFrequencyOfIndex(index, dataReferenceCount),
                                    FrequencyHelper.GetFrequencyOfIndex(index + count, dataReferenceCount),
                                    bandData);

                index += count;
            }
        }
Пример #5
0
        public RawSpectrumProvider(float[][] data, int audioChannel)
        {
            int dataReferenceCount = (data[audioChannel - 1].Length - 1) * 2;

            Bands = new Band[data[audioChannel - 1].Length];

            for (int i = 0; i < Bands.Length; i++)
            {
                Bands[i] = new Band(FrequencyHelper.GetFrequencyOfIndex(i, dataReferenceCount), FrequencyHelper.GetFrequencyOfIndex(i, dataReferenceCount), new[] { data[audioChannel - 1][i] });
            }
        }
Пример #6
0
        /// <summary>
        /// Initialize components.
        /// </summary>
        public override void _initializeComponents()
        {
            Frame f = new Frame()
            {
                Label   = Director.Properties.Resources.ScenarioLabel,
                Padding = 10
            };
            VBox ScenarioSettings = new VBox();

            // Create scenario name
            ScenarioName          = new TextEntry();
            ScenarioName.Changed += ScenarioName_Changed;
            ScenarioSettings.PackStart(new Label(Director.Properties.Resources.ScenarioName));
            ScenarioSettings.PackStart(ScenarioName);
            ScenarioSettings.PackStart(InvalidScenarioName);
            f.Content = ScenarioSettings;
            PackStart(f);

            Frame h = new Frame()
            {
                Label   = Director.Properties.Resources.RunningOptionsLabel,
                Padding = 10
            };
            VBox RunningOptionsSettings = new VBox();

            // Select scenario run
            PeriodicityRunning       = new RadioButton(Director.Properties.Resources.FrequencyLabel);
            TimeDelayRunning         = new RadioButton(Director.Properties.Resources.TimeDelayLabel);
            PeriodicityRunning.Group = TimeDelayRunning.Group;
            RunningOptionsSettings.PackStart(PeriodicityRunning);
            RunningOptionsSettings.PackStart(TimeDelayRunning);
            PeriodicityRunning.Group.ActiveRadioButtonChanged += ChangeFrequencyOption;

            // Frequency settings
            RunningOptionsSettings.PackStart(new Label()
            {
                Text = Director.Properties.Resources.RunningPeriodicity
            });
            FrequencyRunning = new ComboBox();
            FrequencyHelper.FillComboBox(FrequencyRunning);
            RunningOptionsSettings.PackStart(FrequencyRunning);
            FrequencyRunning.SelectedIndex     = 0;
            FrequencyRunning.SelectionChanged += FrequencyRunning_SelectionChanged;

            // Time delay settings
            RunningOptionsSettings.PackStart(new Label()
            {
                Text = Director.Properties.Resources.TimeDelayInSeconds
            });
            TimeDelay = new TextEntry()
            {
                Text = "0"
            };
            TimeDelay.Changed += delegate
            {
                try
                {
                    ActiveScenario.TimeAfterPrevious = int.Parse(TimeDelay.Text);

                    InvalidTimeDelay.Visible = false;
                }
                catch
                {
                    InvalidTimeDelay.Visible = true;
                }
            };
            RunningOptionsSettings.PackStart(TimeDelay);
            RunningOptionsSettings.PackStart(InvalidTimeDelay);

            // Add to form
            h.Content = RunningOptionsSettings;
            PackStart(h);


            // Scenario information
            ScenarioInformation = new VBox();
            ScrollView ScenarioInformationScrollView = new ScrollView()
            {
                VerticalScrollPolicy = ScrollPolicy.Automatic,
                Content = ScenarioInformation
            };

            Frame si = new Frame()
            {
                Label   = Director.Properties.Resources.ScenarioOverview,
                Padding = 10,
                Content = ScenarioInformationScrollView
            };

            PackStart(si, true, true);
        }
Пример #7
0
        /// <summary>
        /// Initialize window.
        /// </summary>
        public override void _initializeComponents()
        {
            // Server Name + URL + Periodicity window
            Frame f = new Frame();

            f.Label   = Director.Properties.Resources.ServerSettings;
            f.Padding = 10;

            // Create VBOX
            VBox ServerSettings = new VBox();

            // Prepare text box
            ServerSettings.PackStart(new Label()
            {
                Text = Director.Properties.Resources.ServerName
            });
            ServerName          = new TextEntry();
            ServerName.Changed += ServerName_Changed;
            ServerSettings.PackStart(ServerName);

            // Add invalid server name
            ServerSettings.PackStart(InvalidServerName);

            // Server URL
            ServerSettings.PackStart(new Label()
            {
                Text = Director.Properties.Resources.ServerURL
            });
            ServerURL          = new TextEntry();
            ServerURL.Changed += ServerURL_Changed;
            ServerSettings.PackStart(ServerURL);

            // Invalid URL
            ServerSettings.PackStart(InvalidServerURL);

            // Frequency settings
            ServerSettings.PackStart(new Label()
            {
                Text = Director.Properties.Resources.RunningPeriodicity
            });
            FrequencyRunning = new ComboBox();
            FrequencyHelper.FillComboBox(FrequencyRunning);
            ServerSettings.PackStart(FrequencyRunning);
            FrequencyRunning.SelectedIndex     = 0;
            FrequencyRunning.SelectionChanged += FrequencyRunning_SelectionChanged;

            // Add Frame to server settings
            f.Content = ServerSettings;
            PackStart(f);

            // Authorization
            AuthRequired            = new CheckBox(Director.Properties.Resources.Authorization);
            AuthRequired.MarginLeft = 10;
            PackStart(AuthRequired);

            // Create Authentication Frame
            Authentication = new Frame()
            {
                Label   = Director.Properties.Resources.AuthorizationSettings,
                Padding = 10
            };

            // Login and Password fields
            VBox AuthBox = new VBox();

            AuthBox.PackStart(new Label()
            {
                Text = Director.Properties.Resources.Username
            });
            AuthUserName          = new TextEntry();
            AuthUserName.Changed += AuthUserName_Changed;
            AuthBox.PackStart(AuthUserName);

            AuthBox.PackStart(new Label()
            {
                Text = Director.Properties.Resources.Password
            });
            AuthUserPassword          = new PasswordEntry();
            AuthUserPassword.Changed += AuthUserPassword_Changed;
            AuthBox.PackStart(AuthUserPassword);

            // Authentication content
            Authentication.Content = AuthBox;
            PackStart(Authentication);

            // Change value
            AuthRequired.Toggled += AuthRequired_Toggled;

            // Email settings
            Frame EmailFrame = new Frame()
            {
                Label     = Director.Properties.Resources.EmailNotifications,
                Padding   = 10,
                MinHeight = 180
            };

            // Create EmailList widget
            EmailWidget        = new EmailList();
            EmailFrame.Content = EmailWidget;
            PackStart(EmailFrame, expand: true, fill: true);
        }
Пример #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriceableSimpleBond"/> class.
        /// </summary>
        /// <param name="baseDate">The base date.</param>
        /// <param name="bond">The bond</param>
        /// <param name="settlementDate">The settlement date.</param>
        /// <param name="exDivDate">The ex dividend date.</param>
        /// <param name="businessDayAdjustments">The business day adjustments.</param>
        /// <param name="paymentCalendar">The payment Calendar.</param>
        /// <param name="marketQuote">The market quote.</param>
        /// <param name="quoteType">The quote type</param>
        public PriceableSimpleBond(DateTime baseDate, Bond bond, DateTime settlementDate, DateTime exDivDate,
                                   BusinessDayAdjustments businessDayAdjustments, IBusinessCalendar paymentCalendar, BasicQuotation marketQuote, BondPriceEnum quoteType)
            : base(baseDate, bond.faceAmount, bond.currency, null, null, businessDayAdjustments, marketQuote, quoteType)
        {
            Id = bond.id;
            var tempId = Id.Split('-');
            var bondId = tempId[0];

            if (tempId.Length > 2)
            {
                bondId = tempId[2];
            }
            Issuer      = (string)bond.Item;//Does not handle PartyReference type -> only string!
            Description = "Not Defined";
            if (bond.description != null)
            {
                Description = bond.description;
            }
            MaturityDate   = bond.maturity;
            CouponDayCount = new DayCountFraction {
                Value = bond.dayCountFraction.Value
            };
            if (bond.parValueSpecified)
            {
                ParValue = bond.parValue;
            }
            if (bond.couponRateSpecified)
            {
                CouponRate = bond.couponRate;
            }
            CouponFrequency = new Period
            {
                period           = bond.paymentFrequency.period,
                periodMultiplier = bond.paymentFrequency.periodMultiplier
            };
            CouponType = CouponTypeEnum.Fixed;
            if (bond.clearanceSystem != null)
            {
                ClearanceSystem = bond.clearanceSystem.Value;
            }
            if (bond.exchangeId != null)
            {
                Exchange = bond.exchangeId.Value;
            }
            if (bond.seniority != null)
            {
                Seniority = EnumHelper.Parse <CreditSeniorityEnum>(bond.seniority.Value);
            }
            if (bond.instrumentId != null)
            {
                InstrumentIds = new List <InstrumentId>();
                foreach (var identifier in bond.instrumentId.Select(id => InstrumentIdHelper.Parse(id.Value)))
                {
                    InstrumentIds.Add(identifier);
                }
            }
            //This handles the case of a bond forward used in curve building.
            if (MaturityDate > BaseDate)
            {
                var rollConvention =
                    RollConventionEnumHelper.Parse(MaturityDate.Day.ToString(CultureInfo.InvariantCulture));
                Frequency             = FrequencyHelper.ToFrequency(bond.paymentFrequency);
                SettlementDate        = settlementDate;
                UnAdjustedPeriodDates = DateScheduler.GetUnadjustedCouponDatesFromMaturityDate(SettlementDate,
                                                                                               MaturityDate,
                                                                                               CouponFrequency,
                                                                                               rollConvention,
                                                                                               out _,
                                                                                               out var nextCouponDate);
                LastCouponDate      = UnAdjustedPeriodDates[0];
                NextCouponDate      = nextCouponDate;
                AdjustedPeriodDates =
                    AdjustedDateScheduler.GetAdjustedDateSchedule(UnAdjustedPeriodDates,
                                                                  PaymentBusinessDayAdjustments.businessDayConvention,
                                                                  paymentCalendar).ToArray();
                AdjustedPeriodDates[0] = SettlementDate;
                NextExDivDate          = exDivDate;
                IsXD = IsExDiv();
            }
            BondCurveName         = CurveNameHelpers.GetBondCurveName(Currency.Value, bondId);
            SwapDiscountCurveName = CurveNameHelpers.GetDiscountCurveName(Currency.Value, true);
        }
Пример #9
0
 private Pitch(PitchClass pitchClass, int octave)
 {
     _pitchClass = pitchClass;
     _octave     = octave;
     _frequency  = FrequencyHelper.GetFrequency(pitchClass, octave);
 }
Пример #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriceableSimpleBond"/> class.
        /// </summary>
        /// <param name="baseDate">The base date.</param>
        /// <param name="nodeStruct">The bond nodeStruct</param>
        /// <param name="settlementCalendar">The settlement Calendar.</param>
        /// <param name="paymentCalendar">The payment Calendar.</param>
        /// <param name="marketQuote">The market quote.</param>
        /// <param name="quoteType">THe quote Type</param>
        public PriceableSimpleBond(DateTime baseDate, BondNodeStruct nodeStruct, IBusinessCalendar settlementCalendar, IBusinessCalendar paymentCalendar,
                                   BasicQuotation marketQuote, BondPriceEnum quoteType)
            : base(baseDate, nodeStruct.Bond.faceAmount, nodeStruct.Bond.currency, nodeStruct.SettlementDate, nodeStruct.ExDivDate, nodeStruct.BusinessDayAdjustments, marketQuote, quoteType)
        {
            Id = nodeStruct.Bond.id;
            var tempId = Id.Split('-');
            var bondId = tempId[0];

            if (tempId.Length > 2)
            {
                bondId = tempId[2];
            }
            SettlementDateCalendar = settlementCalendar;
            Issuer      = (string)nodeStruct.Bond.Item;//Does not handle PartyReference type -> only string!
            Description = "Not Defined";
            //IsYTMQuote = true;
            if (nodeStruct.Bond.description != null)
            {
                Description = nodeStruct.Bond.description;
            }
            MaturityDate   = nodeStruct.Bond.maturity;
            CouponDayCount = new DayCountFraction {
                Value = nodeStruct.Bond.dayCountFraction.Value
            };
            CouponFrequency = new Period
            {
                period           = nodeStruct.Bond.paymentFrequency.period,
                periodMultiplier = nodeStruct.Bond.paymentFrequency.periodMultiplier
            };
            if (nodeStruct.Bond.couponRateSpecified)
            {
                CouponRate = nodeStruct.Bond.couponRate;
            }
            if (nodeStruct.Bond.parValueSpecified)
            {
                ParValue = nodeStruct.Bond.parValue;
            }
            if (nodeStruct.Bond.clearanceSystem != null)
            {
                ClearanceSystem = nodeStruct.Bond.clearanceSystem.Value;
            }
            if (nodeStruct.Bond.exchangeId != null)
            {
                Exchange = nodeStruct.Bond.exchangeId.Value;
            }
            CouponType = CouponTypeEnum.Fixed;
            if (nodeStruct.Bond.seniority != null)
            {
                Seniority = EnumHelper.Parse <CreditSeniorityEnum>(nodeStruct.Bond.seniority.Value, true);
            }
            if (nodeStruct.Bond.instrumentId != null)
            {
                InstrumentIds = new List <InstrumentId>();
                foreach (var identifier in nodeStruct.Bond.instrumentId.Select(id => InstrumentIdHelper.Parse(id.Value)))
                {
                    InstrumentIds.Add(identifier);
                }
            }
            //This handles the case of a bondforward used in curve building.
            if (MaturityDate > BaseDate)
            {
                DateTime lastCouponDate;
                DateTime nextCouponDate;
                var      rollConvention =
                    RollConventionEnumHelper.Parse(MaturityDate.Day.ToString(CultureInfo.InvariantCulture));
                Frequency = FrequencyHelper.ToFrequency(nodeStruct.Bond.paymentFrequency);
                //Get the settlement date
                SettlementDate = GetSettlementDate(baseDate, settlementCalendar, nodeStruct.SettlementDate);
                //Generate the necessary dates.
                //TODO Should the settlement date and the underlying bond be calculated on the fly when calculation occurs?
                UnAdjustedPeriodDates = DateScheduler.GetUnadjustedCouponDatesFromMaturityDate(SettlementDate,
                                                                                               MaturityDate,
                                                                                               CouponFrequency,
                                                                                               rollConvention,
                                                                                               out lastCouponDate,
                                                                                               out nextCouponDate);
                LastCouponDate      = UnAdjustedPeriodDates[0];
                NextCouponDate      = nextCouponDate;
                AdjustedPeriodDates =
                    AdjustedDateScheduler.GetAdjustedDateSchedule(UnAdjustedPeriodDates,
                                                                  nodeStruct.BusinessDayAdjustments
                                                                  .businessDayConvention, paymentCalendar)
                    .ToArray();
                AdjustedPeriodDates[0] = SettlementDate; //TODO check this!
                NextExDivDate          = GetNextExDivDate();
                IsXD = IsExDiv();
            }
            BondCurveName         = CurveNameHelpers.GetBondCurveName(Currency.Value, bondId);
            SwapDiscountCurveName = CurveNameHelpers.GetDiscountCurveName(Currency.Value, true);
        }