Ejemplo n.º 1
0
        private T SendRequest <T>(IntervalPeriod periodInterval, DataType dataType = DataType.Bid) where T : HistoricalData
        {
            T data = null;

            var request = new TimeHistoricalRequest(InstrumentsManager.Current, dataType, periodInterval.Period, periodInterval.Value);

            data = HistoricalDataManager.Get(request, new Interval(GetFromPeriod(periodInterval), DateTime.UtcNow)) as T;

            var result = new AsyncResult(data);

            HistoricalDataManager.OnLoaded = (historianData) =>
            {
                result        = new AsyncResult(historianData, true);
                result.Status = "Done";
            };

            do
            {
                result.Status = "Loading";
            } while (!result.IsReady);

            asyncResults.Add(result);

            data = result.Data as T;

            return(data);
        }
Ejemplo n.º 2
0
        public double TimeFrameGetPrice(IntervalPeriod periodInterval, PriceType priceType, int index = 0)
        {
            bardata = TimeFrameRequest <BarData>(periodInterval);

            var price = 0D;

            if (bardata != null && bardata.Count > 0)
            {
                price = bardata.GetValue(priceType, index);
            }

            return(price);
        }
Ejemplo n.º 3
0
        public T TimeFrameRequest <T>(IntervalPeriod periodInterval, DataType dataType = DataType.Bid) where T : HistoricalData
        {
            if (bardata != null)
            {
                var searchName = bardata.HistoricalRequest.Instrument.Symbol + ((bardata.HistoricalRequest as TimeHistoricalRequest).Period).ToString() + (bardata.HistoricalRequest as TimeHistoricalRequest).Value.ToString();

                if (asyncResults.FindIndex(x => x.Name == searchName) == -1)
                {
                    return(SendRequest <T>(periodInterval, dataType));
                }

                return(bardata as T);
            }
            else
            {
                return(SendRequest <T>(periodInterval, dataType));
            }
        }
Ejemplo n.º 4
0
        private DateTime GetFromPeriod(IntervalPeriod periodInterval)
        {
            var currentFromInterval = HistoryDataSeries.GetTimeUtc(HistoryDataSeries.Count - 1);

            switch (periodInterval.Period)
            {
            case Period.Second: return(currentFromInterval > DateTime.UtcNow.AddSeconds(-periodInterval.Value) ? DateTime.UtcNow.AddSeconds(-periodInterval.Value) : currentFromInterval);

            case Period.Minute: return(currentFromInterval > DateTime.UtcNow.AddMinutes(-periodInterval.Value) ? DateTime.UtcNow.AddMinutes(-periodInterval.Value) : currentFromInterval);

            case Period.Hour: return(currentFromInterval > DateTime.UtcNow.AddHours(-periodInterval.Value) ? DateTime.UtcNow.AddHours(-periodInterval.Value) : currentFromInterval);

            case Period.Day: return(currentFromInterval > DateTime.UtcNow.AddDays(-periodInterval.Value) ? DateTime.UtcNow.AddDays(-periodInterval.Value) : currentFromInterval);

            case Period.Week: return(currentFromInterval > DateTime.UtcNow.AddDays(-periodInterval.Value * 7) ? DateTime.UtcNow.AddDays(-periodInterval.Value * 7) : currentFromInterval);

            case Period.Month: return(currentFromInterval > DateTime.UtcNow.AddMonths(-periodInterval.Value) ? DateTime.UtcNow.AddMonths(-periodInterval.Value) : currentFromInterval);

            case Period.Year: return(currentFromInterval > DateTime.UtcNow.AddYears(-periodInterval.Value) ? DateTime.UtcNow.AddYears(-periodInterval.Value) : currentFromInterval);

            default: return(currentFromInterval);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// ラジオボタンの選択が変更された場合発生するイベントのハンドラ
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            IntervalPeriod interval = IntervalPeriod.minutes;

            switch (this.RadioButtonList1.SelectedValue)
            {
            case "0":
                this.dateLogPeriodStart = DateTimeOffset.Parse(dateTimeNow.Date.ToString());
                this.dateLogPeriodEnd   = DateTimeOffset.Parse(dateTimeNow.ToString());
                interval = IntervalPeriod.minutes;
                break;

            case "1":
                this.dateLogPeriodStart = DateTimeOffset.Parse
                                              (dateTimeNow.Date.Subtract(new TimeSpan(7, 0, 0, 0)).ToString());
                this.dateLogPeriodEnd = DateTimeOffset.Parse(dateTimeNow.ToString());
                interval = IntervalPeriod.minutes;
                break;

            case "2":
                this.dateLogPeriodStart = DateTimeOffset.Parse
                                              (dateTimeNow.Date.Subtract(new TimeSpan(30, 0, 0, 0)).ToString());
                this.dateLogPeriodEnd = DateTimeOffset.Parse(dateTimeNow.ToString());
                interval = IntervalPeriod.day;
                break;

            default:
                /*
                 * this.dateLogPeriodStart = DateTimeOffset.Parse(dateTimeNow.Date.ToString());
                 * this.dateLogPeriodEnd = DateTimeOffset.Parse(dateTimeNow.ToString());
                 * interval = IntervalPeriod.minutes;
                 */
                break;
            }
            this.getIoTData(interval);
            this.drawGraph();
        }
Ejemplo n.º 6
0
        public override NameValueCollection GetParameters(string serviceId)
        {
            var parameters = base.GetParameters(serviceId);

            ParameterValidator.IsNotNull(Amount, "Amount");
            parameters.Add("amount", Amount.ToString());

            ParameterValidator.IsNotNull(BankaccountHolder, "BankaccountHolder");
            parameters.Add("bankaccountHolder", BankaccountHolder);

            ParameterValidator.IsNotNull(BankaccountNumber, "BankaccountNumber");
            parameters.Add("bankaccountNumber", BankaccountNumber);

            ParameterValidator.IsNotNull(IntervalValue, "IntervalValue");
            parameters.Add("intervalValue", IntervalValue.ToString());

            ParameterValidator.IsNotNull(IntervalPeriod, "IntervalPeriod");
            parameters.Add("intervalPeriod", IntervalPeriod.ToEnumString());

            if (!ParameterValidator.IsEmpty(BankaccountBic))
            {
                parameters.Add("bankaccountBic", BankaccountBic);
            }

            if (!ParameterValidator.IsNull(ProcessDate))
            {
                parameters.Add("processDate", ProcessDate.Value.ToString("dd-MM-yyyy"));
            }

            if (!ParameterValidator.IsEmpty(Description))
            {
                parameters.Add("description", Description);
            }

            if (!ParameterValidator.IsEmpty(Currency))
            {
                parameters.Add("currency", Currency);
            }

            if (!ParameterValidator.IsEmpty(ExchangeUrl))
            {
                parameters.Add("exchangeUrl", ExchangeUrl);
            }

            if (!ParameterValidator.IsEmpty(IpAddress))
            {
                parameters.Add("ipAddress", IpAddress);
            }

            if (!ParameterValidator.IsEmpty(Email))
            {
                parameters.Add("email", Email);
            }

            if (ParameterValidator.IsNonEmptyInt(PromotorId))
            {
                parameters.Add("promotorId", PromotorId.ToString());
            }

            if (!ParameterValidator.IsEmpty(Tool))
            {
                parameters.Add("tool", Tool);
            }

            if (!ParameterValidator.IsEmpty(Info))
            {
                parameters.Add("info", Info);
            }

            if (!ParameterValidator.IsEmpty(Object))
            {
                parameters.Add("object", Object);
            }

            if (!ParameterValidator.IsEmpty(Extra1))
            {
                parameters.Add("extra1", Extra1);
            }

            if (!ParameterValidator.IsEmpty(Extra2))
            {
                parameters.Add("extra2", Extra2);
            }

            if (!ParameterValidator.IsEmpty(Extra3))
            {
                parameters.Add("extra3", Extra3);
            }

            return(parameters);
        }
Ejemplo n.º 7
0
        private void getIoTData(IntervalPeriod interval)
        {
            int    intervalMinutes;
            string secondUnit = "";

            switch (interval)
            {
            case IntervalPeriod.minutes:
                intervalMinutes = 1;
                secondUnit      = "日";
                break;

            case IntervalPeriod.day:
                intervalMinutes = 60;
                secondUnit      = "日";
                break;

            case IntervalPeriod.week:
                intervalMinutes = 60 * 24;
                secondUnit      = "月";
                break;

            default:
                intervalMinutes = 0;
                break;
            }

            //IoTデータの取得を行います
            var dataSetAqua   = AzureStrageTable.DeserializeAqualiumDataSet(dateLogPeriodStart, dateLogPeriodEnd);
            var dataTableAqua = dataSetAqua.Tables["aqua"];

            this.graphData          = new List <string>();
            this.graphTemperature   = new List <double>();
            this.graphHumidity      = new List <double>();
            this.graphPressure      = new List <double>();
            this.graphExTemperature = new List <double>();
            for (int i = 0; i < dataTableAqua.Rows.Count; i++)
            {
                var tmpDateTime  = DateTime.Parse((string)dataTableAqua.Rows[i]["TimeStamp"]);
                int totalMinutes = tmpDateTime.Month * 30 + tmpDateTime.Day * 24 + tmpDateTime.Hour * 60 + tmpDateTime.Minute;
                if ((totalMinutes % intervalMinutes) == 0)
                {
                    var    tmp               = tmpDateTime.Day.ToString() + secondUnit + tmpDateTime.Hour.ToString() + ":" + tmpDateTime.Minute.ToString();
                    double tmpTemperature    = double.Parse((string)dataTableAqua.Rows[i]["Temperature"]);
                    double tmpHumidity       = double.Parse((string)dataTableAqua.Rows[i]["Humidity"]);
                    double tmpPressure       = double.Parse((string)dataTableAqua.Rows[i]["Pressure"]);
                    double tmpExtTemperature = double.Parse((string)dataTableAqua.Rows[i]["ExternalTemperature"]);

                    if (lowLimitTemperature <= tmpTemperature && tmpTemperature <= highLimitTemperature &&
                        lowLimitHumidity <= tmpHumidity && tmpHumidity <= highLimitHumidity &&
                        lowLimitPressure <= tmpPressure && tmpPressure <= highLimitPressure &&
                        lowLimitTemperature <= tmpExtTemperature && tmpExtTemperature <= highLimitTemperature)
                    {
                        graphData.Add(tmp);
                        graphTemperature.Add(tmpTemperature);
                        graphHumidity.Add(tmpHumidity);
                        graphPressure.Add(tmpPressure);
                        graphExTemperature.Add(tmpExtTemperature);
                    }
                }
            }
        }