示例#1
0
 public JsonMtGOX()
 {
     high = new High();
     low = new Low();
     avg = new Avg();
     vwap = new Vwap();
     vol = new Vol();
     lastlocal = new LastLocal();
     lastorig = new LastOrig();
     lastall = new LastAll();
     last = new Last();
     buy = new Buy();
     sell = new Sell();
     rootobject = new RootObject();
     returnObject = new Return();
 }
示例#2
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         if (Type != null)
         {
             hashCode = hashCode * 59 + Type.GetHashCode();
         }
         if (Visible != null)
         {
             hashCode = hashCode * 59 + Visible.GetHashCode();
         }
         if (ShowLegend != null)
         {
             hashCode = hashCode * 59 + ShowLegend.GetHashCode();
         }
         if (LegendGroup != null)
         {
             hashCode = hashCode * 59 + LegendGroup.GetHashCode();
         }
         if (Opacity != null)
         {
             hashCode = hashCode * 59 + Opacity.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (UId != null)
         {
             hashCode = hashCode * 59 + UId.GetHashCode();
         }
         if (Ids != null)
         {
             hashCode = hashCode * 59 + Ids.GetHashCode();
         }
         if (CustomData != null)
         {
             hashCode = hashCode * 59 + CustomData.GetHashCode();
         }
         if (Meta != null)
         {
             hashCode = hashCode * 59 + Meta.GetHashCode();
         }
         if (MetaArray != null)
         {
             hashCode = hashCode * 59 + MetaArray.GetHashCode();
         }
         if (SelectedPoints != null)
         {
             hashCode = hashCode * 59 + SelectedPoints.GetHashCode();
         }
         if (HoverInfo != null)
         {
             hashCode = hashCode * 59 + HoverInfo.GetHashCode();
         }
         if (HoverInfoArray != null)
         {
             hashCode = hashCode * 59 + HoverInfoArray.GetHashCode();
         }
         if (Stream != null)
         {
             hashCode = hashCode * 59 + Stream.GetHashCode();
         }
         if (Transforms != null)
         {
             hashCode = hashCode * 59 + Transforms.GetHashCode();
         }
         if (UiRevision != null)
         {
             hashCode = hashCode * 59 + UiRevision.GetHashCode();
         }
         if (X != null)
         {
             hashCode = hashCode * 59 + X.GetHashCode();
         }
         if (Open != null)
         {
             hashCode = hashCode * 59 + Open.GetHashCode();
         }
         if (High != null)
         {
             hashCode = hashCode * 59 + High.GetHashCode();
         }
         if (Low != null)
         {
             hashCode = hashCode * 59 + Low.GetHashCode();
         }
         if (Close != null)
         {
             hashCode = hashCode * 59 + Close.GetHashCode();
         }
         if (Line != null)
         {
             hashCode = hashCode * 59 + Line.GetHashCode();
         }
         if (Increasing != null)
         {
             hashCode = hashCode * 59 + Increasing.GetHashCode();
         }
         if (Decreasing != null)
         {
             hashCode = hashCode * 59 + Decreasing.GetHashCode();
         }
         if (Text != null)
         {
             hashCode = hashCode * 59 + Text.GetHashCode();
         }
         if (TextArray != null)
         {
             hashCode = hashCode * 59 + TextArray.GetHashCode();
         }
         if (HoverText != null)
         {
             hashCode = hashCode * 59 + HoverText.GetHashCode();
         }
         if (HoverTextArray != null)
         {
             hashCode = hashCode * 59 + HoverTextArray.GetHashCode();
         }
         if (WhiskerWidth != null)
         {
             hashCode = hashCode * 59 + WhiskerWidth.GetHashCode();
         }
         if (HoverLabel != null)
         {
             hashCode = hashCode * 59 + HoverLabel.GetHashCode();
         }
         if (XCalendar != null)
         {
             hashCode = hashCode * 59 + XCalendar.GetHashCode();
         }
         if (XAxis != null)
         {
             hashCode = hashCode * 59 + XAxis.GetHashCode();
         }
         if (YAxis != null)
         {
             hashCode = hashCode * 59 + YAxis.GetHashCode();
         }
         if (IdsSrc != null)
         {
             hashCode = hashCode * 59 + IdsSrc.GetHashCode();
         }
         if (CustomDataSrc != null)
         {
             hashCode = hashCode * 59 + CustomDataSrc.GetHashCode();
         }
         if (MetaSrc != null)
         {
             hashCode = hashCode * 59 + MetaSrc.GetHashCode();
         }
         if (HoverInfoSrc != null)
         {
             hashCode = hashCode * 59 + HoverInfoSrc.GetHashCode();
         }
         if (XSrc != null)
         {
             hashCode = hashCode * 59 + XSrc.GetHashCode();
         }
         if (OpenSrc != null)
         {
             hashCode = hashCode * 59 + OpenSrc.GetHashCode();
         }
         if (HighSrc != null)
         {
             hashCode = hashCode * 59 + HighSrc.GetHashCode();
         }
         if (LowSrc != null)
         {
             hashCode = hashCode * 59 + LowSrc.GetHashCode();
         }
         if (CloseSrc != null)
         {
             hashCode = hashCode * 59 + CloseSrc.GetHashCode();
         }
         if (TextSrc != null)
         {
             hashCode = hashCode * 59 + TextSrc.GetHashCode();
         }
         if (HoverTextSrc != null)
         {
             hashCode = hashCode * 59 + HoverTextSrc.GetHashCode();
         }
         return(hashCode);
     }
 }
示例#3
0
        /// <inheritdoc />
        public bool Equals([AllowNull] Candlestick other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                     ) &&
                 (
                     Visible == other.Visible ||
                     Visible != null &&
                     Visible.Equals(other.Visible)
                 ) &&
                 (
                     ShowLegend == other.ShowLegend ||
                     ShowLegend != null &&
                     ShowLegend.Equals(other.ShowLegend)
                 ) &&
                 (
                     LegendGroup == other.LegendGroup ||
                     LegendGroup != null &&
                     LegendGroup.Equals(other.LegendGroup)
                 ) &&
                 (
                     Opacity == other.Opacity ||
                     Opacity != null &&
                     Opacity.Equals(other.Opacity)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     UId == other.UId ||
                     UId != null &&
                     UId.Equals(other.UId)
                 ) &&
                 (
                     Equals(Ids, other.Ids) ||
                     Ids != null && other.Ids != null &&
                     Ids.SequenceEqual(other.Ids)
                 ) &&
                 (
                     Equals(CustomData, other.CustomData) ||
                     CustomData != null && other.CustomData != null &&
                     CustomData.SequenceEqual(other.CustomData)
                 ) &&
                 (
                     Meta == other.Meta ||
                     Meta != null &&
                     Meta.Equals(other.Meta)
                 ) &&
                 (
                     Equals(MetaArray, other.MetaArray) ||
                     MetaArray != null && other.MetaArray != null &&
                     MetaArray.SequenceEqual(other.MetaArray)
                 ) &&
                 (
                     SelectedPoints == other.SelectedPoints ||
                     SelectedPoints != null &&
                     SelectedPoints.Equals(other.SelectedPoints)
                 ) &&
                 (
                     HoverInfo == other.HoverInfo ||
                     HoverInfo != null &&
                     HoverInfo.Equals(other.HoverInfo)
                 ) &&
                 (
                     Equals(HoverInfoArray, other.HoverInfoArray) ||
                     HoverInfoArray != null && other.HoverInfoArray != null &&
                     HoverInfoArray.SequenceEqual(other.HoverInfoArray)
                 ) &&
                 (
                     Stream == other.Stream ||
                     Stream != null &&
                     Stream.Equals(other.Stream)
                 ) &&
                 (
                     Equals(Transforms, other.Transforms) ||
                     Transforms != null && other.Transforms != null &&
                     Transforms.SequenceEqual(other.Transforms)
                 ) &&
                 (
                     UiRevision == other.UiRevision ||
                     UiRevision != null &&
                     UiRevision.Equals(other.UiRevision)
                 ) &&
                 (
                     Equals(X, other.X) ||
                     X != null && other.X != null &&
                     X.SequenceEqual(other.X)
                 ) &&
                 (
                     Equals(Open, other.Open) ||
                     Open != null && other.Open != null &&
                     Open.SequenceEqual(other.Open)
                 ) &&
                 (
                     Equals(High, other.High) ||
                     High != null && other.High != null &&
                     High.SequenceEqual(other.High)
                 ) &&
                 (
                     Equals(Low, other.Low) ||
                     Low != null && other.Low != null &&
                     Low.SequenceEqual(other.Low)
                 ) &&
                 (
                     Equals(Close, other.Close) ||
                     Close != null && other.Close != null &&
                     Close.SequenceEqual(other.Close)
                 ) &&
                 (
                     Line == other.Line ||
                     Line != null &&
                     Line.Equals(other.Line)
                 ) &&
                 (
                     Increasing == other.Increasing ||
                     Increasing != null &&
                     Increasing.Equals(other.Increasing)
                 ) &&
                 (
                     Decreasing == other.Decreasing ||
                     Decreasing != null &&
                     Decreasing.Equals(other.Decreasing)
                 ) &&
                 (
                     Text == other.Text ||
                     Text != null &&
                     Text.Equals(other.Text)
                 ) &&
                 (
                     Equals(TextArray, other.TextArray) ||
                     TextArray != null && other.TextArray != null &&
                     TextArray.SequenceEqual(other.TextArray)
                 ) &&
                 (
                     HoverText == other.HoverText ||
                     HoverText != null &&
                     HoverText.Equals(other.HoverText)
                 ) &&
                 (
                     Equals(HoverTextArray, other.HoverTextArray) ||
                     HoverTextArray != null && other.HoverTextArray != null &&
                     HoverTextArray.SequenceEqual(other.HoverTextArray)
                 ) &&
                 (
                     WhiskerWidth == other.WhiskerWidth ||
                     WhiskerWidth != null &&
                     WhiskerWidth.Equals(other.WhiskerWidth)
                 ) &&
                 (
                     HoverLabel == other.HoverLabel ||
                     HoverLabel != null &&
                     HoverLabel.Equals(other.HoverLabel)
                 ) &&
                 (
                     XCalendar == other.XCalendar ||
                     XCalendar != null &&
                     XCalendar.Equals(other.XCalendar)
                 ) &&
                 (
                     XAxis == other.XAxis ||
                     XAxis != null &&
                     XAxis.Equals(other.XAxis)
                 ) &&
                 (
                     YAxis == other.YAxis ||
                     YAxis != null &&
                     YAxis.Equals(other.YAxis)
                 ) &&
                 (
                     IdsSrc == other.IdsSrc ||
                     IdsSrc != null &&
                     IdsSrc.Equals(other.IdsSrc)
                 ) &&
                 (
                     CustomDataSrc == other.CustomDataSrc ||
                     CustomDataSrc != null &&
                     CustomDataSrc.Equals(other.CustomDataSrc)
                 ) &&
                 (
                     MetaSrc == other.MetaSrc ||
                     MetaSrc != null &&
                     MetaSrc.Equals(other.MetaSrc)
                 ) &&
                 (
                     HoverInfoSrc == other.HoverInfoSrc ||
                     HoverInfoSrc != null &&
                     HoverInfoSrc.Equals(other.HoverInfoSrc)
                 ) &&
                 (
                     XSrc == other.XSrc ||
                     XSrc != null &&
                     XSrc.Equals(other.XSrc)
                 ) &&
                 (
                     OpenSrc == other.OpenSrc ||
                     OpenSrc != null &&
                     OpenSrc.Equals(other.OpenSrc)
                 ) &&
                 (
                     HighSrc == other.HighSrc ||
                     HighSrc != null &&
                     HighSrc.Equals(other.HighSrc)
                 ) &&
                 (
                     LowSrc == other.LowSrc ||
                     LowSrc != null &&
                     LowSrc.Equals(other.LowSrc)
                 ) &&
                 (
                     CloseSrc == other.CloseSrc ||
                     CloseSrc != null &&
                     CloseSrc.Equals(other.CloseSrc)
                 ) &&
                 (
                     TextSrc == other.TextSrc ||
                     TextSrc != null &&
                     TextSrc.Equals(other.TextSrc)
                 ) &&
                 (
                     HoverTextSrc == other.HoverTextSrc ||
                     HoverTextSrc != null &&
                     HoverTextSrc.Equals(other.HoverTextSrc)
                 ));
        }
示例#4
0
        public override string ToString()
        {
            string formatedDate = Date.ToString("d-MMM-y");

            return(string.Format("{0},{1},{2},{3},{4},{5}", formatedDate, Open.ToString("0.00"), High.ToString("0.00"), Low.ToString("0.00"), Close.ToString("0.00"), Volume));
        }
 public override string ToString()
 {
     return(Time.ToShortDateString() + " " + Open.ToString() + " " + High.ToString() + " " + Low.ToString() + " " + Close.ToString());
 }
示例#6
0
        public override void Calculate(int index)
        {
            CurrentBar = index;

            if (saveCurrentBar != CurrentBar)
            {
                swingHighSwings[index] = 0;
                swingLowSwings[index]  = 0;
                swingHighSeries[index] = 0;
                swingLowSeries[index]  = 0;
                lastHighCache.Add(High.Last(0));

                if (lastHighCache.Count > (2 * Strength) + 1)
                {
                    lastHighCache.RemoveAt(0);
                }
                lastLowCache.Add(Low.Last(0));
                if (lastLowCache.Count > (2 * Strength) + 1)
                {
                    lastLowCache.RemoveAt(0);
                }

                if (lastHighCache.Count == (2 * Strength) + 1)
                {
                    bool   isSwingHigh             = true;
                    double swingHighCandidateValue = (double)lastHighCache[Strength];
                    for (int i = 0; i < Strength; i++)
                    {
                        if ((double)lastHighCache[i] >= swingHighCandidateValue - double.Epsilon)
                        {
                            isSwingHigh = false;
                        }
                    }

                    for (int i = Strength + 1; i < lastHighCache.Count; i++)
                    {
                        if ((double)lastHighCache[i] > swingHighCandidateValue - double.Epsilon)
                        {
                            isSwingHigh = false;
                        }
                    }

                    swingHighSwings[index - Strength] = isSwingHigh ? swingHighCandidateValue : 0.0;
                    if (isSwingHigh)
                    {
                        lastSwingHighValue = swingHighCandidateValue;
                    }

                    if (isSwingHigh)
                    {
                        currentSwingHigh = swingHighCandidateValue;
                        for (int i = 0; i <= Strength; i++)
                        {
                            SwingHighPlot[index - i] = currentSwingHigh;
                        }
                    }
                    else if (High.Last(0) > currentSwingHigh)
                    {
                        currentSwingHigh     = 0.0;
                        SwingHighPlot[index] = double.NaN;
                    }
                    else
                    {
                        SwingHighPlot[index] = currentSwingHigh;
                    }

                    if (isSwingHigh)
                    {
                        for (int i = 0; i <= Strength; i++)
                        {
                            swingHighSeries[index - i] = lastSwingHighValue;
                        }
                    }
                    else
                    {
                        swingHighSeries[index] = lastSwingHighValue;
                    }
                }

                if (lastLowCache.Count == (2 * Strength) + 1)
                {
                    bool   isSwingLow             = true;
                    double swingLowCandidateValue = (double)lastLowCache[Strength];
                    for (int i = 0; i < Strength; i++)
                    {
                        if ((double)lastLowCache[i] <= swingLowCandidateValue + double.Epsilon)
                        {
                            isSwingLow = false;
                        }
                    }

                    for (int i = Strength + 1; i < lastLowCache.Count; i++)
                    {
                        if ((double)lastLowCache[i] < swingLowCandidateValue + double.Epsilon)
                        {
                            isSwingLow = false;
                        }
                    }

                    swingLowSwings[index - Strength] = isSwingLow ? swingLowCandidateValue : 0.0;
                    if (isSwingLow)
                    {
                        lastSwingLowValue = swingLowCandidateValue;
                    }

                    if (isSwingLow)
                    {
                        currentSwingLow = swingLowCandidateValue;
                        for (int i = 0; i <= Strength; i++)
                        {
                            SwingLowPlot[index - i] = currentSwingLow;
                        }
                    }
                    else if (Low.Last(0) < currentSwingLow)
                    {
                        currentSwingLow     = double.MaxValue;
                        SwingLowPlot[index] = double.NaN;
                    }
                    else
                    {
                        SwingLowPlot[index] = currentSwingLow;
                    }

                    if (isSwingLow)
                    {
                        for (int i = 0; i <= Strength; i++)
                        {
                            swingLowSeries[index - i] = lastSwingLowValue;
                        }
                    }
                    else
                    {
                        swingLowSeries[index] = lastSwingLowValue;
                    }
                }

                saveCurrentBar = CurrentBar;
            }
            else
            {
                if (High.Last(0) > High.Last(Strength) && swingHighSwings.Last(Strength) > 0.0)
                {
                    swingHighSwings[index - Strength] = 0.0;
                    for (int i = 0; i <= Strength; i++)
                    {
                        SwingHighPlot[index - i] = double.NaN;
                    }
                    currentSwingHigh = 0.0;
                }
                else if (High.Last(0) > High.Last(Strength) && currentSwingHigh != 0.0)
                {
                    SwingHighPlot[index] = double.NaN;
                    currentSwingHigh     = 0.0;
                }
                else if (High.Last(0) <= currentSwingHigh)
                {
                    SwingHighPlot[index] = currentSwingHigh;
                }

                if (Low.Last(0) < Low.Last(Strength) && swingLowSwings.Last(Strength) > 0.0)
                {
                    swingLowSwings[index - Strength] = 0.0;
                    for (int i = 0; i <= Strength; i++)
                    {
                        SwingLowPlot[index - i] = double.NaN;
                    }
                    currentSwingLow = double.MaxValue;
                }
                else if (Low.Last(0) < Low.Last(Strength) && currentSwingLow != double.MaxValue)
                {
                    SwingLowPlot[index] = double.NaN;
                    currentSwingLow     = double.MaxValue;
                }
                else if (Low.Last(0) >= currentSwingLow)
                {
                    SwingLowPlot[index] = currentSwingLow;
                }
            }
        }
示例#7
0
        public override string ToString()
        {
            if (Low == 0 && High == 0)
            {
                return("Full: 0x0");
            }

            if (HasEntry())
            {
                StoreNameType type = Utilities.ObjectTypeToStore(GetObjectType());

                // ReSharper disable once UseStringInterpolation
                return(string.Format("Full: 0x{0}{1} {2}/{3} R{4}/S{5} Map: {6} Entry: {7} Low: {8}", High.ToString("X16"), Low.ToString("X16"),
                                     GetHighType(), GetSubType(), GetRealmId(), GetServerId(), StoreGetters.GetName(StoreNameType.Map, GetMapId()),
                                     StoreGetters.GetName(type, (int)GetEntry()), GetLow()));
            }

            // TODO: Implement extra format for battleground, see WowGuid64.ToString()

            string name = StoreGetters.GetName(this);

            // ReSharper disable once UseStringInterpolation
            return(string.Format("Full: 0x{0}{1} {2}/{3} R{4}/S{5} Map: {6} Low: {7}", High.ToString("X16"), Low.ToString("X16"),
                                 GetHighType(), GetSubType(), GetRealmId(), GetServerId(), StoreGetters.GetName(StoreNameType.Map, GetMapId()),
                                 GetLow() + (String.IsNullOrEmpty(name) ? String.Empty : (" Name: " + name))));
        }
示例#8
0
        public string ToCSV()
        {
            string word = ID.ToString() + ',' + ChannelID.ToString() + ',' + Name.Replace(',', '-') + ',' + AlarmTypeID.ToString() + ',' + Severity.ToString() + ',' + High.ToString() + ',' + Low.ToString() + ',' + RangeInclusive.ToString() + ','
                          + PerUnit.ToString() + ',' + Enabled.ToString() + ',' + MeasurementType + ',' + MeasurementTypeID.ToString() + ',' + MeasurementCharacteristic + ',' + MeasurementCharacteristicID.ToString() + ',' +
                          Phase + ',' + PhaseID.ToString() + ',' + HarmonicGroup.ToString() + ',' + IsDefault.ToString();

            return(word);
        }
示例#9
0
 public string[] ToStrings()
 {
     return(new string[] { DateTime.FromFileTime(_dateTime).ToString(), Open.ToString(), Close.ToString(), Low.ToString(), High.ToString(), Volume.ToString() });
 }
示例#10
0
        /// <summary>
        /// Calculate the simple moving average
        /// </summary>
        /// <param name="startTime">The time to start the calculation from</param>
        protected void CalculateSMA(DateTime startTime)
        {
            foreach (var key in Open.Keys.Where(i => i >= startTime))
            {
                switch (AppliesTo)
                {
                case AppliesToEnum.Open:
                {
                    var val = Open.GetPreviousDataValues(key, Period).Sum() / Period;

                    Data["Buffer"][key] = val;

                    break;
                }

                case AppliesToEnum.High:
                {
                    var val = High.GetPreviousDataValues(key, Period).Sum() / Period;

                    Data["Buffer"][key] = val;

                    break;
                }

                case AppliesToEnum.Low:
                {
                    var val = Low.GetPreviousDataValues(key, Period).Sum() / Period;

                    Data["Buffer"][key] = val;

                    break;
                }

                case AppliesToEnum.Close:
                {
                    var val = Close.GetPreviousDataValues(key, Period).Sum() / Period;

                    Data["Buffer"][key] = val;

                    break;
                }

                case AppliesToEnum.MedianPrice:
                {
                    var val = High.GetPreviousDataValues(key, Period).Sum();
                    val += Low.GetPreviousDataValues(key, Period).Sum();
                    val  = val / 2;
                    val  = val / Period;

                    Data["Buffer"][key] = val;

                    break;
                }

                case AppliesToEnum.TypicalPrice:
                {
                    var val = High.GetPreviousDataValues(key, Period).Sum();
                    val += Low.GetPreviousDataValues(key, Period).Sum();
                    val += Close.GetPreviousDataValues(key, Period).Sum();
                    val  = val / 3;
                    val  = val / Period;

                    Data["Buffer"][key] = val;

                    break;
                }

                case AppliesToEnum.WeightedClosePrice:
                {
                    Data["Buffer"][key] = 0;

                    break;
                }
                }
            }
        }
示例#11
0
        protected override void OnBarUpdate()
        {
            DateTime dtBegin = DateTime.MaxValue;

            switch (IntervalType)
            {
            case EnumIntervalType.Sec:
                dtBegin = MinBar.D.Date.AddHours(MinBar.D.Hour).AddMinutes(MinBar.D.Minute).AddSeconds(MinBar.D.Second / Interval * Interval);
                break;

            case EnumIntervalType.Min:
                dtBegin = MinBar.D.Date.AddHours(MinBar.D.Hour).AddMinutes(MinBar.D.Minute / Interval * Interval);
                break;

            case EnumIntervalType.Hour:
                dtBegin = MinBar.D.Date.AddHours(MinBar.D.Hour / Interval * Interval);
                break;

            case EnumIntervalType.Day:
                dtBegin = DateTime.ParseExact(MinBar.TradingDay.ToString(), "yyyyMMdd", null);
                break;

            case EnumIntervalType.Week:
                dtBegin = DateTime.ParseExact(MinBar.TradingDay.ToString(), "yyyyMMdd", null);
                dtBegin = dtBegin.Date.AddDays(1 - (byte)dtBegin.DayOfWeek);
                break;

            case EnumIntervalType.Month:
                dtBegin = DateTime.ParseExact(MinBar.TradingDay.ToString(), "yyyyMMdd", null);
                dtBegin = new DateTime(dtBegin.Year, dtBegin.Month, 1);
                break;

            case EnumIntervalType.Year:
                dtBegin = DateTime.ParseExact(MinBar.TradingDay.ToString(), "yyyyMMdd", null);
                dtBegin = new DateTime(dtBegin.Year, 1, 1);
                break;

            default:
                throw new Exception("参数错误");
            }
            if (bar == null)             //首次调用
            {
                bar = new Bar
                {
                    D = dtBegin,
                    I = MinBar.I,
                    V = MinBar.V,                     // kOld.preVol == 0 ? 0 : _tick.Volume - kOld.preVol;
                };
                bar.H  = MinBar.H;
                bar.L  = MinBar.L;
                bar.O  = MinBar.O;
                bar.C  = MinBar.C;
                newbar = true;
            }
            else
            {
                if (bar.D == dtBegin)                 //在当前K线范围内
                {
                    newbar = false;
                    bar.H  = Math.Max(bar.H, MinBar.H);
                    bar.L  = Math.Min(bar.L, MinBar.L);
                    bar.C  = MinBar.C;
                    bar.V  = bar.V + MinBar.V;
                    bar.I  = MinBar.I;
                }
                else if (dtBegin > bar.D)
                {
                    newbar = true;
                    bar.D  = dtBegin;
                    bar.V  = MinBar.V;
                    bar.I  = MinBar.I;
                    bar.O  = MinBar.O;
                    bar.H  = MinBar.H;
                    bar.L  = MinBar.L;
                    bar.C  = MinBar.C;
                }
            }

            if (newbar)
            {
                Date.Add(double.Parse(bar.D.ToString("yyyyMMdd")));
                Time.Add(double.Parse(bar.D.ToString("0.HHmmss")));
                Open.Add(bar.O);
                High.Add(bar.H);
                Low.Add(bar.L);
                Close.Add(bar.C);
                Volume.Add(bar.V);
                OpenInterest.Add(bar.I);
            }
            else
            {
                High[0]         = bar.H;
                Low[0]          = bar.L;
                Close[0]        = bar.C;
                Volume[0]       = bar.V;
                OpenInterest[0] = bar.I;
            }
        }
示例#12
0
 public override string ToString()
 {
     return("OHLC (" + bardate + "/" + _time + ") " + Open.ToString("F2") + "," + High.ToString("F2") + "," + Low.ToString("F2") + "," + Close.ToString("F2"));
 }
示例#13
0
 public override Double Get(Double x, Double y, Double z, Double w, Double u, Double v)
 {
     return(Utilities.Clamp(Source.Get(x, y, z, w, u, v), Low.Get(x, y, z, w, u, v), High.Get(x, y, z, w, u, v)));
 }
示例#14
0
 public override Double Get(Double x, Double y, Double z)
 {
     return(Utilities.Clamp(Source.Get(x, y, z), Low.Get(x, y, z), High.Get(x, y, z)));
 }
示例#15
0
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     return(Low.GetHashCode() ^
            High.GetHashCode());
 }
示例#16
0
 /// <summary>
 /// Gets all the information about a reading
 /// </summary>
 /// <returns>All information as a neatly padded out string</returns>
 public override string ToString()
 {
     return(Date.PadRight(15) + High.ToString().PadRight(10) + Low.ToString().PadRight(10) + AveTemp);
 }
示例#17
0
        /// <summary>
        /// Returns true if BookSummary instances are equal
        /// </summary>
        /// <param name="other">Instance of BookSummary to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BookSummary other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     UnderlyingIndex == other.UnderlyingIndex ||
                     UnderlyingIndex != null &&
                     UnderlyingIndex.Equals(other.UnderlyingIndex)
                     ) &&
                 (
                     Volume == other.Volume ||
                     Volume != null &&
                     Volume.Equals(other.Volume)
                 ) &&
                 (
                     VolumeUsd == other.VolumeUsd ||
                     VolumeUsd != null &&
                     VolumeUsd.Equals(other.VolumeUsd)
                 ) &&
                 (
                     UnderlyingPrice == other.UnderlyingPrice ||
                     UnderlyingPrice != null &&
                     UnderlyingPrice.Equals(other.UnderlyingPrice)
                 ) &&
                 (
                     BidPrice == other.BidPrice ||
                     BidPrice != null &&
                     BidPrice.Equals(other.BidPrice)
                 ) &&
                 (
                     OpenInterest == other.OpenInterest ||
                     OpenInterest != null &&
                     OpenInterest.Equals(other.OpenInterest)
                 ) &&
                 (
                     QuoteCurrency == other.QuoteCurrency ||
                     QuoteCurrency != null &&
                     QuoteCurrency.Equals(other.QuoteCurrency)
                 ) &&
                 (
                     High == other.High ||
                     High != null &&
                     High.Equals(other.High)
                 ) &&
                 (
                     EstimatedDeliveryPrice == other.EstimatedDeliveryPrice ||
                     EstimatedDeliveryPrice != null &&
                     EstimatedDeliveryPrice.Equals(other.EstimatedDeliveryPrice)
                 ) &&
                 (
                     Last == other.Last ||
                     Last != null &&
                     Last.Equals(other.Last)
                 ) &&
                 (
                     MidPrice == other.MidPrice ||
                     MidPrice != null &&
                     MidPrice.Equals(other.MidPrice)
                 ) &&
                 (
                     InterestRate == other.InterestRate ||
                     InterestRate != null &&
                     InterestRate.Equals(other.InterestRate)
                 ) &&
                 (
                     Funding8h == other.Funding8h ||
                     Funding8h != null &&
                     Funding8h.Equals(other.Funding8h)
                 ) &&
                 (
                     MarkPrice == other.MarkPrice ||
                     MarkPrice != null &&
                     MarkPrice.Equals(other.MarkPrice)
                 ) &&
                 (
                     AskPrice == other.AskPrice ||
                     AskPrice != null &&
                     AskPrice.Equals(other.AskPrice)
                 ) &&
                 (
                     InstrumentName == other.InstrumentName ||
                     InstrumentName != null &&
                     InstrumentName.Equals(other.InstrumentName)
                 ) &&
                 (
                     Low == other.Low ||
                     Low != null &&
                     Low.Equals(other.Low)
                 ) &&
                 (
                     BaseCurrency == other.BaseCurrency ||
                     BaseCurrency != null &&
                     BaseCurrency.Equals(other.BaseCurrency)
                 ) &&
                 (
                     CreationTimestamp == other.CreationTimestamp ||
                     CreationTimestamp != null &&
                     CreationTimestamp.Equals(other.CreationTimestamp)
                 ) &&
                 (
                     CurrentFunding == other.CurrentFunding ||
                     CurrentFunding != null &&
                     CurrentFunding.Equals(other.CurrentFunding)
                 ));
        }
示例#18
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (UnderlyingIndex != null)
         {
             hashCode = hashCode * 59 + UnderlyingIndex.GetHashCode();
         }
         if (Volume != null)
         {
             hashCode = hashCode * 59 + Volume.GetHashCode();
         }
         if (VolumeUsd != null)
         {
             hashCode = hashCode * 59 + VolumeUsd.GetHashCode();
         }
         if (UnderlyingPrice != null)
         {
             hashCode = hashCode * 59 + UnderlyingPrice.GetHashCode();
         }
         if (BidPrice != null)
         {
             hashCode = hashCode * 59 + BidPrice.GetHashCode();
         }
         if (OpenInterest != null)
         {
             hashCode = hashCode * 59 + OpenInterest.GetHashCode();
         }
         if (QuoteCurrency != null)
         {
             hashCode = hashCode * 59 + QuoteCurrency.GetHashCode();
         }
         if (High != null)
         {
             hashCode = hashCode * 59 + High.GetHashCode();
         }
         if (EstimatedDeliveryPrice != null)
         {
             hashCode = hashCode * 59 + EstimatedDeliveryPrice.GetHashCode();
         }
         if (Last != null)
         {
             hashCode = hashCode * 59 + Last.GetHashCode();
         }
         if (MidPrice != null)
         {
             hashCode = hashCode * 59 + MidPrice.GetHashCode();
         }
         if (InterestRate != null)
         {
             hashCode = hashCode * 59 + InterestRate.GetHashCode();
         }
         if (Funding8h != null)
         {
             hashCode = hashCode * 59 + Funding8h.GetHashCode();
         }
         if (MarkPrice != null)
         {
             hashCode = hashCode * 59 + MarkPrice.GetHashCode();
         }
         if (AskPrice != null)
         {
             hashCode = hashCode * 59 + AskPrice.GetHashCode();
         }
         if (InstrumentName != null)
         {
             hashCode = hashCode * 59 + InstrumentName.GetHashCode();
         }
         if (Low != null)
         {
             hashCode = hashCode * 59 + Low.GetHashCode();
         }
         if (BaseCurrency != null)
         {
             hashCode = hashCode * 59 + BaseCurrency.GetHashCode();
         }
         if (CreationTimestamp != null)
         {
             hashCode = hashCode * 59 + CreationTimestamp.GetHashCode();
         }
         if (CurrentFunding != null)
         {
             hashCode = hashCode * 59 + CurrentFunding.GetHashCode();
         }
         return(hashCode);
     }
 }
示例#19
0
        public override int GetHashCode()
        {
            unchecked
            {
                //TODO extract the constants to a separate file
                // Choose large primes to avoid hashing collisions
                const int HashingBase       = (int)2166136261;
                const int HashingMultiplier = 16777619;

                int hash = HashingBase;
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, Low) ? Low.GetHashCode() : 0);
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, High) ? High.GetHashCode() : 0);
                return(hash);
            }
        }
 /// <inheritdoc />
 public override int GetHashCode()
 {
     return(HashCode.Combine(
                Low != null ? Low.GetHashCode() : 0,
                High != null ? High.GetHashCode() : 0));
 }
示例#21
0
        public void Print()
        {
            var color = IsGreen ? "Green" : "Red";

            //Debug.WriteLine($"T={TimeStamp.ToShortDateString()}, O={Open.ToString("0.00")}, H={High.ToString("0.00")}, L={Low.ToString("0.00")}, C={Close.ToString("0.00")}, V={Volume}, NV={CandleVolume}, Color = {color}");
            Debug.WriteLine($"T={TimeStamp.ToShortTimeString()}, O={Open.ToString("0.00")}, H={High.ToString("0.00")}, L={Low.ToString("0.00")}, C={Close.ToString("0.00")}, V={Volume}, NV={CandleVolume}, Color = {color}");
        }
示例#22
0
        public override string ToString()
        {
            var date  = OpenTime.ToDefaultString();
            var chars = 8;
            var vol   = Volume > 0 ? $" [v:{Volume.ToString().PadLeft(chars)}]" : "";

            return($"{date} o:{Open.ToString().PadRight(chars, '0')} h:{High.ToString().PadRight(chars, '0')} l:{Low.ToString().PadRight(chars, '0')} c:{Close.ToString().PadRight(chars, '0')}{vol}");
        }
示例#23
0
文件: Bar.cs 项目: mpvyard/Trading
        public override string ToString()
        {
            var chars   = 8;
            var padChar = ' ';
            //var padChar = '0';
            var vol = Volume > 0 ? $" [v:{Volume.ToString().PadLeft(chars)}]" : "";

            return($"o:{Open.ToString().PadRight(chars, padChar)} h:{High.ToString().PadRight(chars, padChar)} l:{Low.ToString().PadRight(chars, padChar)} c:{Close.ToString().PadRight(chars, padChar)}{vol}");
        }
示例#24
0
 public void OnLow()
 {
     Low?.Invoke(this, EventArgs.Empty);
 }
示例#25
0
 public override string ToString()
 {
     return($"\nSymbol: {Symbol.PadRight(10)}Date: {Date.PadRight(20)}\n" +
            $"High: {High.ToString().PadRight(10)}  Open: {Open.ToString().PadRight(10)}\n " +
            $"Low: {Low.ToString().PadRight(10)} Close: {Close.ToString().PadRight(10)}");
 }