예제 #1
0
        private void Open(double price, double qty, OpenType ot, SecurityInfo si, TickData td, string tr)
        {
            PolicyResultEventArgs arg = new PolicyResultEventArgs();

            arg.PolicyName1 = this.policyName;
            arg.SecInfo     = si;
            arg.IsReal      = currentTick.IsReal;
            OpenPoint op = new OpenPoint();

            op.SecInfo             = si;
            op.OpenTime            = td.Time;
            op.OpenPrice           = price;
            op.OpenType            = ot;
            op.OpenQty             = qty;
            op.DealQty             = 0;
            op.Openop              = true;
            op.FirstTradePriceType = parameter.EnterOrderPriceType;
            op.CancelLimitTime     = parameter.EnterOrderWaitSecond;
            op.ReEnterPecentage    = parameter.ReEnterPercent;

            TradePoints tp = new TradePoints(op, 0);

            tp.Fee      = parameter.Fee;
            tp.TpRemark = tr;
            /////////////add//////////////////////
            tp.IsReal = arg.IsReal;
            this.tps.TryAdd(tp.TradeGuid, tp);
            arg.PairePoint   = tp;
            arg.PolicyObject = this;
            arg.Tickdata     = td;
            RaiseResult(arg);
        }
예제 #2
0
        private void Leave(double qty, double price, Guid tradeGuid)
        {
            foreach (var tp in tps)
            {
                if (tp.TradeGuid == tradeGuid)
                {
                    if (tp.OutPoint == null)
                    {
                        OpenPoint op = new OpenPoint();
                        op.SecInfo = currentTick.SecInfo;
                        //op.FirstTradePriceType = TradeSendOrderPriceType.ShiJiaWeiTuo_SH_SZ_WuDangJiChenShenChe;
                        op.FirstTradePriceType = parameter.CloseOrderPriceType;
                        op.CancelLimitTime     = parameter.CloseOrderWaitSecond;
                        op.ReTradePriceType    = parameter.ReCloseOrderPriceType;
                        op.ReEnterPecentage    = 1;
                        op.Openop = false;
                        //op.Remark = string.Format("MA2:{0},Close{1}", args.Bar.MA.MA2, args.Bar.Close);
                        tp.OutPoint = op;
                        openPoints.Add(op);
                        tp.HowToClose = CloseType.Normal;
                        tp.Status     = OpenStatus.Closed;
                    }
                    tp.OutPoint.OpenTime = currentTick.Time;
                    tp.OutPoint.OpenQty  = qty;
                    if (tp.EnterPoint.OpenType == OpenType.KaiDuo)
                    {
                        tp.OutPoint.OpenType  = OpenType.PingDuo;
                        tp.OutPoint.OpenPrice = price;
                    }
                    else
                    {
                        tp.OutPoint.OpenType  = OpenType.PingKong;
                        tp.OutPoint.OpenPrice = price;
                    }
                    PolicyResultEventArgs arg = new PolicyResultEventArgs();
                    arg.Tickdata    = currentTick;
                    arg.PolicyName1 = this.policyName;
                    arg.SecInfo     = this.SecInfo;
                    arg.IsReal      = tp.IsReal;
                    arg.PairePoint  = tp;
                    arg.OpenRmks    = tp.EnterPoint.Remark;

                    RaiseResult(arg);

                    close_complete = 1;
                    break;
                }
            }
        }
예제 #3
0
 public TradeDetail()
 {
     this.closed             = false;
     this.openWeiTuo         = new List <TradeWeiTuo>();
     this.tradeCloseOrderQty = 0;
     this.tradeOHQty         = 0;
     this.closeWeiTuo        = new List <TradeWeiTuo>();
     this.policyClosePoint   = new OpenPoint();
     this.policyOpenPoint    = new OpenPoint();
     this.remark             = string.Empty;
     this.poicyFee           = 0;
     this.gainActure         = 0;
     this.gainPolicy         = 0;
     this.createTime         = DateTime.Now;
 }
예제 #4
0
        private void Open(double price, double qty, OpenType ot, SecurityInfo si, TickData td, double zhuidan, string _tr = "")
        {
            PolicyResultEventArgs arg = new PolicyResultEventArgs();

            arg.PolicyName1 = this.policyName;
            arg.SecInfo     = si;
            arg.IsReal      = currentTick.IsReal;
            OpenPoint op = new OpenPoint();

            op.SecInfo   = si;
            op.OpenTime  = td.Time;
            op.OpenPrice = price;
            op.OpenType  = ot;
            op.OpenQty   = qty;
            op.DealQty   = 0;
            op.Openop    = true;
            if (zhuidan < 0)
            {
                op.FirstTradePriceType = parameter.EnterOrderPriceType;
                op.CancelLimitTime     = parameter.EnterOrderWaitSecond;
                op.ReEnterPecentage    = zhuidan;
            }
            else
            {
                op.FirstTradePriceType = TradeSendOrderPriceType.Market;
                op.CancelLimitTime     = parameter.EnterOrderWaitSecond;
                op.ReEnterPecentage    = zhuidan;
            }
            openPoints.Add(op);
            string tr = _tr;

            if (tr == "")
            {
                tr = DateTime.Now.ToString("yyyyMMddHHmmss");
            }
            TradePoints tp = new TradePoints(op, 0);

            tp.TpRemark = tr;
            tp.Fee      = parameter.Fee;
            tp.IsReal   = arg.IsReal;
            this.tps.Add(tp);
            arg.PairePoint = tp;
            arg.Tickdata   = currentTick;
            RaiseResult(arg);
        }
예제 #5
0
        private void Open(double price, double qty, OpenType ot)
        {
            PolicyResultEventArgs arg = new PolicyResultEventArgs();

            arg.PolicyName1 = this.policyName;
            arg.SecInfo     = this.SecInfo;
            arg.IsReal      = currentTick.IsReal;
            OpenPoint op = new OpenPoint();

            op.SecInfo             = currentTick.SecInfo;
            op.OpenTime            = currentTick.Time;
            op.OpenPrice           = price;
            op.OpenType            = ot;
            op.OpenQty             = qty;
            op.DealQty             = 0;
            op.Openop              = true;
            op.FirstTradePriceType = parameter.EnterOrderPriceType;
            op.CancelLimitTime     = parameter.EnterOrderWaitSecond;
            op.ReEnterPecentage    = parameter.ReEnterPercent;
            //op.CancelLimitTime = 60;
            //op.ReEnterPecentage = 0.05;
            openPoints.Add(op);
            PTradePoints tp = new PTradePoints(op, 0);

            if (ot == OpenType.KaiDuo)
            {
                tp.Y      = (1 + parameter.ZhiYingBeiShu) * price;
                tp.ZhiSun = (1 - parameter.ZhiSunBiLi) * price;
            }
            if (ot == OpenType.KaiKong)
            {
                tp.Y      = (1 - parameter.ZhiYingBeiShu) * price;
                tp.ZhiSun = (1 + parameter.ZhiSunBiLi) * price;
            }
            tp.Fee = parameter.Fee;
            /////////////add//////////////////////
            tp.IsReal = arg.IsReal;
            this.tps.TryAdd(tp.TradeGuid, tp);
            arg.PairePoint   = tp;
            arg.PolicyObject = this;
            arg.Tickdata     = currentTick;
            RaiseResult(arg);
        }
예제 #6
0
        private void Open(double price, double qty, OpenType ot)
        {
            PolicyResultEventArgs arg = new PolicyResultEventArgs();

            arg.PolicyName1 = this.policyName;
            arg.SecInfo     = this.SecInfo;
            arg.IsReal      = currentTick.IsReal;
            OpenPoint op = new OpenPoint();

            op.SecInfo             = currentTick.SecInfo;
            op.OpenTime            = currentTick.Time;
            op.OpenPrice           = price;
            op.OpenType            = ot;
            op.OpenQty             = qty;
            op.DealQty             = 0;
            op.Openop              = true;
            op.FirstTradePriceType = parameter.EnterOrderPriceType;
            op.CancelLimitTime     = parameter.EnterOrderWaitSecond;
            op.ReEnterPecentage    = parameter.ReEnterPercent;
            //op.CancelLimitTime = 60;
            //op.ReEnterPecentage = 0.05;
            openPoints.Add(op);

            TradePoints tp = new TradePoints(op, 0);

            tp.Fee = parameter.Fee;
            /////////////add//////////////////////
            tp.IsReal = arg.IsReal;
            this.tps.Add(tp);
            arg.PairePoint = tp;
            arg.Tickdata   = currentTick;

            open_complete = 1;

            RaiseResult(arg);
        }
예제 #7
0
 public PTradePoints(OpenPoint openpoint, double stoplossPercent) : base(openpoint, stoplossPercent)
 {
     this._zPrice = 0;
 }
예제 #8
0
        private void showQuestionMark(Point point)
        {
            leftSide.Opacity  = 0;
            rightSide.Opacity = 0;
            upSide.Opacity    = 0;
            downSide.Opacity  = 0;
            double           height = Application.Current.RootVisual.RenderSize.Height;
            double           width  = Application.Current.RootVisual.RenderSize.Width;
            bool             found  = false;
            PanoramaItem     panoramaItem;
            FrameworkElement item = (FrameworkElement)this.FindName(itemID);
            var parent            = item.Parent;

            while (parent.GetType() != typeof(PanoramaItem) && parent != null)
            {
                parent = ((FrameworkElement)parent).Parent;
            }

            if (parent.GetType() == typeof(PanoramaItem))
            {
                panoramaItem = (PanoramaItem)parent;
                Debug.WriteLine("look up");
                if (pagePanorama.Items.IndexOf(panoramaItem) != pagePanorama.SelectedIndex)
                {
                    int count = 0;
                    foreach (PanoramaItem pi in pagePanorama.Items)
                    {
                        if (pi.Visibility == Visibility.Visible)
                        {
                            count++;
                        }
                    }
                    int leftSteps  = 0;
                    int rightSteps = 0;
                    int index      = pagePanorama.SelectedIndex;

                    while (index != pagePanorama.Items.IndexOf(panoramaItem))
                    {
                        index++;
                        rightSteps++;
                        if (index == count)
                        {
                            index = 0;
                        }
                    }
                    index = pagePanorama.SelectedIndex;
                    while (index != pagePanorama.Items.IndexOf(panoramaItem))
                    {
                        index--;
                        leftSteps++;
                        if (index == -1)
                        {
                            index = count - 1;
                        }
                    }
                    //Debug.WriteLine("da is er: " + pagePanorama.SelectedIndex + " da will ich hin:" + pagePanorama.Items.IndexOf(panoramaItem) + "(left:" + leftSteps + ", right:" + rightSteps);

                    if (leftSteps < rightSteps)
                    {
                        point.X          = 10;
                        leftSide.Opacity = 1;
                        Debug.WriteLine("left out");
                    }
                    else
                    {
                        point.X           = width - 50;
                        rightSide.Opacity = 1;
                        Debug.WriteLine("right out");
                    }
                }
                else
                {
                    if (point.Y < 280)
                    {
                        point.Y        = 280;
                        upSide.Opacity = 1;
                    }
                    if (point.Y > height - 110)
                    {
                        point.Y          = height - 110;
                        downSide.Opacity = 1;
                    }
                }
            }
            OpenPoint.SetValue(Canvas.LeftProperty, point.X);
            OpenPoint.SetValue(Canvas.TopProperty, point.Y);
            OpenPointQuestionMark.SetValue(Canvas.LeftProperty, point.X);
            OpenPointQuestionMark.SetValue(Canvas.TopProperty, point.Y);

            upSide.SetValue(Canvas.LeftProperty, point.X);
            upSide.SetValue(Canvas.TopProperty, point.Y - 12);

            downSide.SetValue(Canvas.LeftProperty, point.X);
            downSide.SetValue(Canvas.TopProperty, point.Y + 12);

            leftSide.SetValue(Canvas.LeftProperty, point.X - 12);
            leftSide.SetValue(Canvas.TopProperty, point.Y);

            rightSide.SetValue(Canvas.LeftProperty, point.X + 12);
            rightSide.SetValue(Canvas.TopProperty, point.Y);
            showOpenPoint.Begin();
        }
예제 #9
0
        private void updateOpenPoint(object sender, EventArgs e)
        {
            try
            {
                if (itemID != "")
                {
                    var   transform = ((FrameworkElement)(this.FindName(itemID))).TransformToVisual(Application.Current.RootVisual);
                    Point point     = transform.Transform(new Point(0, 0));
                    leftSide.Opacity  = 0;
                    rightSide.Opacity = 0;
                    upSide.Opacity    = 0;
                    downSide.Opacity  = 0;
                    double           height = Application.Current.RootVisual.RenderSize.Height;
                    double           width  = Application.Current.RootVisual.RenderSize.Width;
                    bool             found  = false;
                    PanoramaItem     panoramaItem;
                    FrameworkElement item = (FrameworkElement)this.FindName(itemID);
                    var parent            = item.Parent;

                    while (parent.GetType() != typeof(PanoramaItem) && parent != null)
                    {
                        parent = ((FrameworkElement)parent).Parent;
                    }

                    if (parent.GetType() == typeof(PanoramaItem))
                    {
                        panoramaItem = (PanoramaItem)parent;
                        zahl++;
                        if (pagePanorama.Items.IndexOf(panoramaItem) != pagePanorama.SelectedIndex)
                        {
                            int count = 0;
                            foreach (PanoramaItem pi in pagePanorama.Items)
                            {
                                if (pi.Visibility == Visibility.Visible)
                                {
                                    count++;
                                }
                            }
                            int leftSteps  = 0;
                            int rightSteps = 0;
                            int index      = pagePanorama.SelectedIndex;

                            while (index != pagePanorama.Items.IndexOf(panoramaItem))
                            {
                                index++;
                                rightSteps++;
                                if (index == count)
                                {
                                    index = 0;
                                }
                            }
                            index = pagePanorama.SelectedIndex;
                            while (index != pagePanorama.Items.IndexOf(panoramaItem))
                            {
                                index--;
                                leftSteps++;
                                if (index == -1)
                                {
                                    index = count - 1;
                                }
                            }
                            //Debug.WriteLine("da is er: " + pagePanorama.SelectedIndex + " da will ich hin:" + pagePanorama.Items.IndexOf(panoramaItem) + "(left:" + leftSteps + ", right:" + rightSteps);

                            if (leftSteps < rightSteps)
                            {
                                point.X          = 10;
                                leftSide.Opacity = 1;
                            }
                            else
                            {
                                point.X           = width - 50;
                                rightSide.Opacity = 1;
                            }
                        }
                        else
                        {
                            if (point.Y < 280)
                            {
                                point.Y        = 280;
                                upSide.Opacity = 1;
                            }
                            if (point.Y > height - 110)
                            {
                                point.Y          = height - 110;
                                downSide.Opacity = 1;
                            }
                        }
                        OpenPoint.SetValue(Canvas.LeftProperty, point.X);
                        OpenPoint.SetValue(Canvas.TopProperty, point.Y);
                        OpenPointQuestionMark.SetValue(Canvas.LeftProperty, point.X);
                        OpenPointQuestionMark.SetValue(Canvas.TopProperty, point.Y);

                        upSide.SetValue(Canvas.LeftProperty, point.X);
                        upSide.SetValue(Canvas.TopProperty, point.Y - 12);

                        downSide.SetValue(Canvas.LeftProperty, point.X);
                        downSide.SetValue(Canvas.TopProperty, point.Y + 12);

                        leftSide.SetValue(Canvas.LeftProperty, point.X - 12);
                        leftSide.SetValue(Canvas.TopProperty, point.Y);

                        rightSide.SetValue(Canvas.LeftProperty, point.X + 12);
                        rightSide.SetValue(Canvas.TopProperty, point.Y);
                    }
                }
                else
                {
                    timer.Stop();
                }
            }
            catch
            {
                timer.Stop();
            }
        }
 public PTradePoints(OpenPoint openpoint, double stoplossPercent) : base(openpoint, stoplossPercent)
 {
 }