示例#1
0
        private void tbAvgPrice1_KeyDown(object sender, KeyEventArgs e)
        {
            if (tbAvgPrice1.Text.Length == 0)
            {
                return;
            }
            int lossTick1   = 15;
            int lossTick2   = 30;
            int revenueTick = 60;

            if (e.KeyCode == Keys.Enter)
            {
                if (tbLossPrice1.Text == "0")
                {
                    tbLossPrice1.Text = PriceTick.GetUpPriceOfTick(rule.ItemCode, rule.AvgPrice1, lossTick1).ToString();
                }
                if (tbLossPrice2.Text == "0")
                {
                    tbLossPrice2.Text = PriceTick.GetUpPriceOfTick(rule.ItemCode, rule.AvgPrice1, lossTick2).ToString();
                }
                if (tbMinimumRevenue1.Text == "0")
                {
                    tbMinimumRevenue1.Text = PriceTick.GetDownPriceOfTick(rule.ItemCode, rule.AvgPrice1, revenueTick).ToString();
                }
            }
        }
示例#2
0
        private void tbP1BuyPrice1_KeyDown(object sender, KeyEventArgs e)
        {
            if (tbP1BuyPrice1.Text.Length == 0)
            {
                return;
            }
            int lossTick1   = 10;
            int lossTick2   = 20;
            int revenueTick = 30;

            if (rdoSType1.Checked)
            {
                lossTick1   = 20;
                lossTick2   = 30;
                revenueTick = 50;
            }
            else if (rdoSType2.Checked)
            {
                lossTick1   = 5;
                lossTick2   = 10;
                revenueTick = 30;
            }
            else if (rdoSType3.Checked)
            {
                lossTick1   = 20;
                lossTick2   = 40;
                revenueTick = 100;
            }

            if (e.KeyCode == Keys.Enter)
            {
                if (tbP1BuyPrice2.Text == "0")
                {
                    tbP1BuyPrice2.Text = PriceTick.GetDownPriceOfTick(rule.Item, rule.P1BuyPrice1[0], 5).ToString();
                }
                if (tbP1BuyPrice3.Text == "0")
                {
                    tbP1BuyPrice3.Text = PriceTick.GetDownPriceOfTick(rule.Item, rule.P1BuyPrice1[0], 10).ToString();
                }

                if (tbP1LossPrice1.Text == "0")
                {
                    tbP1LossPrice1.Text = PriceTick.GetUpPriceOfTick(rule.Item, rule.P1BuyPrice1[2], lossTick1).ToString();
                }
                if (tbP1LossPrice2.Text == "0")
                {
                    tbP1LossPrice2.Text = PriceTick.GetUpPriceOfTick(rule.Item, rule.P1BuyPrice1[2], lossTick2).ToString();
                }
                if (tbMinimumRevenue1.Text == "0")
                {
                    tbMinimumRevenue1.Text = PriceTick.GetDownPriceOfTick(rule.Item, rule.P1BuyPrice1[2], revenueTick).ToString();
                }
            }
        }
示例#3
0
        public static string Calculator(string itemCode, string strategyType, string position, double buyPrice, double currrentPrice)
        {
            string revenuePrice = "0";
            int    revenueTick  = 0;

            try
            {
                if (strategyType == "1")
                {
                    revenueTick = Config.RevenueConfig.LOW_LIMIT_TICKS;
                }
                else if (strategyType == "2")
                {
                    revenueTick = Config.RevenueConfig.MIDDLE_LIMIT_TICKS;
                }
                else if (strategyType == "3")
                {
                    revenueTick = Config.RevenueConfig.HIGH_LIMIT_TICKS;
                }
                int roundNum = ItemCodeUtil.GetItemCodeRoundNum(itemCode);
                //매도
                if (position == "1")
                {
                    //손실
                    if (buyPrice < currrentPrice)
                    {
                        revenuePrice = Math.Round(PriceTick.GetDownPriceOfTick(itemCode, buyPrice, revenueTick), roundNum).ToString();
                    }
                    //수익
                    else
                    {
                        revenuePrice = Math.Round(PriceTick.GetDownPriceOfTick(itemCode, buyPrice, revenueTick), roundNum).ToString();
                    }
                }
                //매수
                else if (position == "2")
                {
                    //손실
                    if (buyPrice > currrentPrice)
                    {
                        revenuePrice = Math.Round(PriceTick.GetUpPriceOfTick(itemCode, buyPrice, revenueTick), roundNum).ToString();
                    }
                    //수익
                    else
                    {
                        revenuePrice = Math.Round(PriceTick.GetUpPriceOfTick(itemCode, buyPrice, revenueTick), roundNum).ToString();
                    }
                }
            }
            catch (Exception)
            {
            }
            return(revenuePrice);
        }
示例#4
0
        public double GetRevenuePrice(double basePrice)
        {
            double revenuePrice = 0;

            try
            {
                if (ruleInfo.RevenuePrice != "0")
                {
                    revenuePrice = Convert.ToDouble(ruleInfo.RevenuePrice);
                }
                else if (ruleInfo.RevenueTick != "0")
                {
                    if (ruleInfo.Position == "매수")
                    {
                        revenuePrice = PriceTick.GetDownPriceOfTick(ItemCode, HPrice, Convert.ToInt32(ruleInfo.RevenueTick));
                    }
                    if (ruleInfo.Position == "매도")
                    {
                        revenuePrice = PriceTick.GetUpPriceOfTick(ItemCode, LPrice, Convert.ToInt32(ruleInfo.RevenueTick));
                    }
                }
                else if (ruleInfo.RevenueRate != "0")
                {
                    if (ruleInfo.Position == "매수")
                    {
                        revenuePrice = PriceTick.GetDownPriceOfRate(ItemCode, HPrice, Convert.ToDouble(ruleInfo.RevenueRate));
                    }
                    if (ruleInfo.Position == "매도")
                    {
                        revenuePrice = PriceTick.GetUpPriceOfRate(ItemCode, LPrice, Convert.ToDouble(ruleInfo.RevenueRate));
                    }
                }

                if (ruleInfo.Position == "매수" && revenuePrice <= basePrice)
                {
                    revenuePrice = 0;
                }
                if (ruleInfo.Position == "매도" && revenuePrice >= basePrice)
                {
                    revenuePrice = 0;
                }
            }
            catch (Exception ex) { string err = ex.Message; }

            return(revenuePrice);
        }
示例#5
0
        public double GetLossPrice(double basePrice)
        {
            double lossPrice = 0;

            try
            {
                if (ruleInfo.LossPrice != "0")
                {
                    lossPrice = Convert.ToDouble(ruleInfo.LossPrice);
                }
                else if (ruleInfo.LossTick != "0")
                {
                    if (ruleInfo.Position == "매수")
                    {
                        lossPrice = PriceTick.GetDownPriceOfTick(ItemCode, basePrice, Convert.ToInt32(ruleInfo.LossTick));
                    }
                    if (ruleInfo.Position == "매도")
                    {
                        lossPrice = PriceTick.GetUpPriceOfTick(ItemCode, basePrice, Convert.ToInt32(ruleInfo.LossTick));
                    }
                }
                else if (ruleInfo.LossRate != "0")
                {
                    if (ruleInfo.Position == "매수")
                    {
                        lossPrice = PriceTick.GetDownPriceOfRate(ItemCode, basePrice, Convert.ToDouble(ruleInfo.LossRate));
                    }
                    if (ruleInfo.Position == "매도")
                    {
                        lossPrice = PriceTick.GetUpPriceOfRate(ItemCode, basePrice, Convert.ToDouble(ruleInfo.LossRate));
                    }
                }

                if (ruleInfo.Position == "매수" && lossPrice <= CPrice)
                {
                    lossPrice = 0;
                }
                if (ruleInfo.Position == "매도" && lossPrice >= CPrice)
                {
                    lossPrice = 0;
                }
            }
            catch (Exception ex) { string err = ex.Message; }

            return(lossPrice);
        }
示例#6
0
        public double GetBuyPrice(double basePrice)
        {
            double buyPrice = 0;

            try
            {
                if (ruleInfo.BuyPrice != "0")
                {
                    buyPrice = Convert.ToDouble(ruleInfo.BuyPrice);
                }
                else if (ruleInfo.BuyTick != "0")
                {
                    if (ruleInfo.Position == "매수")
                    {
                        buyPrice = PriceTick.GetDownPriceOfTick(ItemCode, basePrice, Convert.ToInt32(ruleInfo.BuyTick));
                    }
                    if (ruleInfo.Position == "매도")
                    {
                        buyPrice = PriceTick.GetUpPriceOfTick(ItemCode, basePrice, Convert.ToInt32(ruleInfo.BuyTick));
                    }
                }
                else if (ruleInfo.BuyRate != "0")
                {
                    if (ruleInfo.Position == "매수")
                    {
                        buyPrice = PriceTick.GetDownPriceOfRate(ItemCode, basePrice, Convert.ToDouble(ruleInfo.BuyRate));
                    }
                    if (ruleInfo.Position == "매도")
                    {
                        buyPrice = PriceTick.GetUpPriceOfRate(ItemCode, basePrice, Convert.ToDouble(ruleInfo.BuyRate));
                    }
                }
            }
            catch (Exception ex) { string err = ex.Message; }

            return(buyPrice);
        }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static string Calculator(string itemCode, string strategyType, string position, double buyPrice, double currrentPrice, double highPrice, double lowPrice)
        {
            string losscutPrice = "0";
            int    losscutTick  = 0;

            try
            {
                int roundNum = ItemCodeUtil.GetItemCodeRoundNum(itemCode);
                //매도
                if (position == "1")
                {
                    //손실
                    if (buyPrice < currrentPrice)
                    {
                        if (strategyType == "1")
                        {
                            losscutTick = Config.LosscutConfig.LOSS_LOW_LIMIT_TICKS;
                        }
                        else if (strategyType == "2")
                        {
                            losscutTick = Config.LosscutConfig.LOSS_MIDDLE_LIMIT_TICKS;
                        }
                        else if (strategyType == "3")
                        {
                            losscutTick = Config.LosscutConfig.LOSS_HIGH_LIMIT_TICKS;
                        }

                        losscutPrice = Math.Round(PriceTick.GetUpPriceOfTick(itemCode, buyPrice, losscutTick), roundNum).ToString();
                    }
                    //수익
                    else
                    {
                        if (strategyType == "1")
                        {
                            losscutTick = Config.LosscutConfig.REVENUE_LOW_LIMIT_TICKS;
                        }
                        else if (strategyType == "2")
                        {
                            losscutTick = Config.LosscutConfig.REVENUE_MIDDLE_LIMIT_TICKS;
                        }
                        else if (strategyType == "3")
                        {
                            losscutTick = Config.LosscutConfig.REVENUE_HIGH_LIMIT_TICKS;
                        }

                        losscutPrice = Math.Round(PriceTick.GetUpPriceOfTick(itemCode, lowPrice, losscutTick), roundNum).ToString();
                    }
                }
                //매수
                else if (position == "2")
                {
                    //손실
                    if (buyPrice > currrentPrice)
                    {
                        if (strategyType == "1")
                        {
                            losscutTick = Config.LosscutConfig.LOSS_LOW_LIMIT_TICKS;
                        }
                        else if (strategyType == "2")
                        {
                            losscutTick = Config.LosscutConfig.LOSS_MIDDLE_LIMIT_TICKS;
                        }
                        else if (strategyType == "3")
                        {
                            losscutTick = Config.LosscutConfig.LOSS_HIGH_LIMIT_TICKS;
                        }

                        losscutPrice = Math.Round(PriceTick.GetDownPriceOfTick(itemCode, buyPrice, losscutTick), roundNum).ToString();
                    }
                    //수익
                    else
                    {
                        if (strategyType == "1")
                        {
                            losscutTick = Config.LosscutConfig.REVENUE_LOW_LIMIT_TICKS;
                        }
                        else if (strategyType == "2")
                        {
                            losscutTick = Config.LosscutConfig.REVENUE_MIDDLE_LIMIT_TICKS;
                        }
                        else if (strategyType == "3")
                        {
                            losscutTick = Config.LosscutConfig.REVENUE_HIGH_LIMIT_TICKS;
                        }

                        losscutPrice = Math.Round(PriceTick.GetDownPriceOfTick(itemCode, highPrice, losscutTick), roundNum).ToString();
                    }
                }
            }
            catch (Exception)
            {
            }
            return(losscutPrice);
        }