コード例 #1
0
ファイル: StrategyTradeRule.cs プロジェクト: aum-inv/AUM
        public override void Analysis(CurrentPrice price)
        {
            try
            {
                RPrice = Math.Round(Convert.ToDouble(price.price), RoundNum);

                switch (PriceType)
                {
                case "0":
                    CPrice = RPrice;
                    break;

                case "1":
                    CPrice = Math.Round(price.price3, RoundNum);
                    break;

                case "2":
                    CPrice = Math.Round(price.price5, RoundNum);
                    break;

                case "3":
                    CPrice = Math.Round(price.price7, RoundNum);
                    break;

                default:
                    CPrice = Math.Round(Convert.ToDouble(price.price), RoundNum);
                    break;
                }

                if (BPrice == CPrice)
                {
                    return;
                }
                if (HPrice < CPrice)
                {
                    HPrice = Math.Round(CPrice, RoundNum);
                }
                if (LPrice > CPrice)
                {
                    LPrice = Math.Round(CPrice, RoundNum);
                }

                PriceList.Insert(CPrice);

                if (!IsUse)
                {
                    return;
                }

                // //매수포지션 사용여부
                if (!IsBuyed)
                {
                    if (IsUseBuy)
                    {
                        //터치여부
                        if (!IsTouchedBasePrice)
                        {
                            if (PointsUtil.IsBreakThrough(BasePattern, BasePrice, PriceList))
                            {
                                IsTouchedBasePrice = true;
                                onStrategyTradeRuleHandler("터치", $"베이스 가격터치::현재가{CPrice}");
                            }
                        }
                        if (IsTouchedBasePrice && !IsBuyed)
                        {
                            //매도
                            if (Position == "1")
                            {
                                if (CPrice == BuyPrice)
                                {
                                    IsBuyed = true;
                                    SellBuy("진입", Position);
                                    onStrategyTradeRuleHandler("진입", $"매도진입::현재가{CPrice}");
                                }
                            }
                            //매수
                            if (Position == "2")
                            {
                                if (CPrice == BuyPrice)
                                {
                                    IsBuyed = true;
                                    SellBuy("진입", Position);
                                    onStrategyTradeRuleHandler("진입", $"매수진입::현재가{CPrice}");
                                }
                            }
                        }
                    }
                }
                if (IsBuyed && IsUseLosscut && !IsLosscuted && !IsRevenued)
                {
                    if (Position == "1")
                    {
                        if (RPrice == LosscutPrice)
                        {
                            IsLosscuted = true;
                            SellBuy("청산", "2");
                            onStrategyTradeRuleHandler("청산", $"매수청산::현재가{CPrice}");
                        }
                    }
                    //매수
                    if (Position == "2")
                    {
                        if (RPrice == LosscutPrice)
                        {
                            IsLosscuted = true;
                            SellBuy("청산", "1");
                            onStrategyTradeRuleHandler("청산", $"매도청산::현재가{CPrice}");
                        }
                    }
                }
                if (IsBuyed && IsUseRevenue && !IsRevenued && !IsLosscuted)
                {
                    if (Position == "1")
                    {
                        if (RPrice == RevenuePrice)
                        {
                            IsRevenued = true;
                            SellBuy("청산", "2");
                            onStrategyTradeRuleHandler("청산", $"매수청산::현재가{CPrice}");
                        }
                    }
                    //매수
                    if (Position == "2")
                    {
                        if (RPrice == RevenuePrice)
                        {
                            IsRevenued = true;
                            SellBuy("청산", "1");
                            onStrategyTradeRuleHandler("청산", $"매도청산::현재가{CPrice}");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                onStrategyTradeRuleHandler("ERROR", ex.Message);
            }
            finally
            {
                BPrice = CPrice;
            }
        }
コード例 #2
0
ファイル: BasicPatternTradeRule2.cs プロジェクト: aum-inv/AUM
        public override void Analysis(CurrentPrice price)
        {
            try
            {
                switch (PriceType)
                {
                case "0":
                    CPrice = Math.Round(Convert.ToDouble(price.price), RoundNum);
                    break;

                case "1":
                    CPrice = Math.Round(price.price3, RoundNum);
                    break;

                case "2":
                    CPrice = Math.Round(price.price5, RoundNum);
                    break;

                case "3":
                    CPrice = Math.Round(price.price7, RoundNum);
                    break;

                default:
                    CPrice = Math.Round(Convert.ToDouble(price.price), RoundNum);
                    break;
                }

                if (BPrice == CPrice)
                {
                    return;
                }
                if (HPrice < CPrice)
                {
                    HPrice = Math.Round(CPrice, RoundNum);
                }
                if (LPrice > CPrice)
                {
                    LPrice = Math.Round(CPrice, RoundNum);
                }
                PriceList.Insert(CPrice);
                if (!IsUse)
                {
                    return;
                }

                // //매수포지션 사용여부
                if (!IsBuyDone)
                {
                    if (IsUseP2)
                    {
                        //터치여부
                        if (!IsTouchedP2)
                        {
                            if (IsBaseLine)
                            {
                                if (PointsUtil.GetUpDownPattern(PriceList, P2BuyPrice1) == P2BuyPattern)
                                {
                                    IsTouchedP2 = true;
                                    SellBuy("가격패턴매칭", "매수");
                                }
                            }
                            else
                            {
                                if (PointsUtil.GetUpDownPattern(PriceList, P2BuyPrice1, P2BuyPrice2) == P2BuyPattern)
                                {
                                    IsTouchedP2 = true;
                                    SellBuy("가격패턴매칭", "매수");
                                }
                            }
                        }
                        if (IsTouchedP2)
                        {
                            //매수포지션 진입
                            IsBuyDone = true;
                            BuyPrice  = CPrice;
                            Position  = "매수";
                            SellBuy("신규진입", "매수");
                        }
                    }
                }
                //매도포지션 사용여부
                if (!IsBuyDone)
                {
                    if (IsUseP1)
                    {
                        //터치여부
                        if (!IsTouchedP1)
                        {
                            if (IsBaseLine)
                            {
                                if (PointsUtil.GetUpDownPattern(PriceList, P1BuyPrice1) == P1BuyPattern)
                                {
                                    IsTouchedP1 = true;
                                    SellBuy("가격패턴매칭", "매도");
                                }
                            }
                            else
                            {
                                if (PointsUtil.GetUpDownPattern(PriceList, P1BuyPrice1, P1BuyPrice2) == P1BuyPattern)
                                {
                                    IsTouchedP1 = true;
                                    SellBuy("가격패턴매칭", "매도");
                                }
                            }
                        }
                        if (IsTouchedP1)
                        {
                            IsBuyDone = true;
                            BuyPrice  = CPrice;
                            Position  = "매도";
                            SellBuy("신규진입", "매도");
                        }
                    }
                }
                if (!IsBuyDone)
                {
                    return;
                }

                if (Position == "매수" && IsMinimumRevenue2 && MinimumRevenuePrice2 > 0)
                {
                    if (MinimumRevenuePrice2 < CPrice)
                    {
                        return;
                    }
                }
                if (Position == "매도" && IsMinimumRevenue1 && MinimumRevenuePrice1 > 0)
                {
                    if (MinimumRevenuePrice1 > CPrice)
                    {
                        return;
                    }
                }

                //손실체크
                if (Position == "매수")
                {
                    if (PointsUtil.IsBreakThrough(P2LosscutPattern1, P2LosscutPrice1, PriceList))
                    {
                        InitRule();
                        SellBuy("손실청산1", "매도");
                    }

                    if (P2LosscutPrice2 > 0 && P2LosscutPrice2 >= CPrice)
                    {
                        //매도진입
                        InitRule();
                        SellBuy("손실청산2", "매도");
                    }
                }
                if (Position == "매도")
                {
                    if (PointsUtil.IsBreakThrough(P1LosscutPattern1, P1LosscutPrice1, PriceList))
                    {
                        InitRule();
                        SellBuy("손실청산1", "매수");
                    }

                    if (P1LosscutPrice2 > 0 && P1LosscutPrice2 <= CPrice)
                    {
                        //매수진입
                        InitRule();
                        SellBuy("손실청산2", "매수");
                    }
                }

                //수익체크
                if (IsUseRevenue1)
                {
                    double revenuePrice = Math.Round(GetRevenuePrice1(), RoundNum);
                    if (revenuePrice == 0)
                    {
                        return;
                    }
                    if (Position == "매수")
                    {
                        if (revenuePrice <= CPrice)
                        {
                            //매도진입
                            InitRule();
                            SellBuy("수익청산", "매도");
                        }
                    }
                    if (Position == "매도")
                    {
                        if (revenuePrice >= CPrice)
                        {
                            //매수진입
                            InitRule();
                            SellBuy("수익청산", "매수");
                        }
                    }
                }
                if (IsUseRevenue2)
                {
                    double revenuePrice = Math.Round(GetRevenuePrice2(), RoundNum);
                    if (revenuePrice == 0)
                    {
                        return;
                    }
                    if (Position == "매수")
                    {
                        if (revenuePrice <= CPrice)
                        {
                            //매도진입
                            InitRule();
                            SellBuy("수익청산", "매도");
                        }
                    }
                    if (Position == "매도")
                    {
                        if (revenuePrice >= CPrice)
                        {
                            //매수진입
                            InitRule();
                            SellBuy("수익청산", "매수");
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                BPrice = CPrice;
            }
        }
コード例 #3
0
        public override void Analysis(CurrentPrice price)
        {
            try
            {
                GetSise(price);

                switch (ruleInfo.PriceType)
                {
                case "0":
                    CPrice = Math.Round(Convert.ToDouble(price.price), RoundNum);
                    break;

                case "1":
                    CPrice = Math.Round(price.price3, RoundNum);
                    break;

                case "2":
                    CPrice = Math.Round(price.price5, RoundNum);
                    break;

                case "3":
                    CPrice = Math.Round(price.price7, RoundNum);
                    break;

                default:
                    CPrice = Math.Round(Convert.ToDouble(price.price), RoundNum);
                    break;
                }

                if (BPrice == CPrice)
                {
                    return;
                }
                if (HPrice < CPrice)
                {
                    HPrice = Math.Round(CPrice, RoundNum);
                }
                if (LPrice > CPrice)
                {
                    LPrice = Math.Round(CPrice, RoundNum);
                }

                PriceList.Insert(CPrice);

                double touchPrice매도 = Math.Round(GetTouchPrice("매도"), RoundNum);
                double touchPrice매수 = Math.Round(GetTouchPrice("매수"), RoundNum);

                if (ruleInfo.IsUse == "N")
                {
                    return;
                }
                if (touchPrice매도 == 0)
                {
                    return;
                }
                if (touchPrice매수 == 0)
                {
                    return;
                }

                // 진입
                if (!ruleInfo.IsBuyDone)
                {
                    //기준가 터치여부 체크
                    if (!ruleInfo.IsTouchedBasePrice)
                    {
                        if (PointsUtil.IsBreakThroughUp(touchPrice매수, PriceList))
                        {
                            ruleInfo.BasePrice          = ruleInfo.BuyPrice = Math.Round(touchPrice매수, RoundNum).ToString();
                            ruleInfo.Position           = "매수";
                            ruleInfo.IsTouchedBasePrice = true;
                            ruleInfo.BasePriceTouchTime = DateTime.Now;
                            TradeEvents.Instance.OnTradeRuleHandler(AtmanName, ItemCode, $"매수라인터치::{ruleInfo.TimeType}::{touchPrice매수}::{CPrice}");
                        }

                        if (PointsUtil.IsBreakThroughDown(touchPrice매도, PriceList))
                        {
                            ruleInfo.BasePrice          = ruleInfo.BuyPrice = Math.Round(touchPrice매도, RoundNum).ToString();
                            ruleInfo.Position           = "매도";
                            ruleInfo.IsTouchedBasePrice = true;
                            ruleInfo.BasePriceTouchTime = DateTime.Now;
                            TradeEvents.Instance.OnTradeRuleHandler(AtmanName, ItemCode, $"매도라인터치::{ruleInfo.TimeType}::{touchPrice매도}::{CPrice}");
                        }
                    }

                    //매입여부 체크
                    if (ruleInfo.IsTouchedBasePrice)
                    {
                        double basePrice = Math.Round(Convert.ToDouble(ruleInfo.BasePrice), RoundNum);
                        double buyPrice  = Math.Round(GetBuyPrice(ruleInfo.Position), RoundNum);
                        //기준가 터치후 제약시간이상 넘었을 경우

                        if (ruleInfo.Position == "매수")
                        {
                            if (PointsUtil.IsBreakThroughDownUp(buyPrice, PriceList))
                            {
                                //매수진입
                                ruleInfo.IsBuyDone = true;
                                ruleInfo.BuyedTime = DateTime.Now;
                                ruleInfo.LossPrice = Math.Round(touchPrice매도, RoundNum).ToString();
                                ruleInfo.BuyPrice  = Math.Round(buyPrice, RoundNum).ToString();
                                SellBuy("신규매입", "매수");
                            }
                        }
                        else if (ruleInfo.Position == "매도")
                        {
                            if (PointsUtil.IsBreakThroughUpDown(buyPrice, PriceList))
                            {
                                //매도진입
                                ruleInfo.IsBuyDone = true;
                                ruleInfo.BuyedTime = DateTime.Now;
                                ruleInfo.LossPrice = Math.Round(touchPrice매수, RoundNum).ToString();
                                ruleInfo.BuyPrice  = Math.Round(buyPrice, RoundNum).ToString();
                                SellBuy("신규매입", "매도");
                            }
                        }
                    }
                }
                if (!ruleInfo.IsBuyDone)
                {
                    return;
                }
                double lossPrice = GetLossPrice();
                //손실체크
                if (lossPrice > 0 && ruleInfo.IsBuyDone)
                {
                    if (ruleInfo.Position == "매수")
                    {
                        if (PointsUtil.IsBreakThroughDown(lossPrice, PriceList))
                        {
                            //매도진입
                            InitRule();
                            SellBuy("손실청산", "매도");
                        }
                    }
                    else if (ruleInfo.Position == "매도")
                    {
                        if (PointsUtil.IsBreakThroughUp(lossPrice, PriceList))
                        {
                            //매수진입
                            InitRule();
                            SellBuy("손실청산", "매수");
                        }
                    }
                }
                double revenuePrice = GetRevenuePrice();
                //수익체크
                if (revenuePrice > 0 && ruleInfo.IsBuyDone && ruleInfo.IsCanRevenue)
                {
                    if (ruleInfo.Position == "매수")
                    {
                        if (PointsUtil.IsBreakThroughUpDown(revenuePrice, PriceList))
                        {
                            //매도진입
                            InitRule();
                            SellBuy("수익청산", "매도");
                        }
                    }
                    else if (ruleInfo.Position == "매도")
                    {
                        if (PointsUtil.IsBreakThroughDownUp(revenuePrice, PriceList))
                        {
                            //매수진입
                            InitRule();
                            SellBuy("수익청산", "매수");
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                BPrice = CPrice;
            }
        }
コード例 #4
0
 public void UpdatePoints()
 {
     text      = GetComponent <Text>();
     text.text = $"points : {PointsUtil.GetCurrentPoints()}";
 }
コード例 #5
0
ファイル: GameSession.cs プロジェクト: matthewmics/SpikeRoll
    public void AddScore(int teamIndex)
    {
        var sd = GameObject.FindObjectsOfType <SuperKickDestination>();

        foreach (var i in sd)
        {
            Destroy(i.gameObject);
        }

        if (SelectionSingleton.instance.IsPractice)
        {
            return;
        }

        TeamProps t  = teams[teamIndex];
        TeamProps to = teams[(teamIndex == 0) ? 1 : 0];
        string    sr = "ROUND";

        t.Score       += 1;
        t.UIScore.text = t.Score.ToString();
        string c = (teamIndex == 0) ? "red" : "blue";

        if ((t.Score + to.Score) % 3 == 0)
        {
            isTopServe = !isTopServe;
        }

        if (t.Score >= currentScoreToWin && t.Score - to.Score > 1)
        {
            currentSet++;

            sr                = "SET";
            t.SetCore        += 1;
            t.UISetScore.text = t.SetCore.ToString();
            t.Score           = 0;
            t.UIScore.text    = t.Score.ToString();
            to.Score          = 0;
            to.UIScore.text   = t.Score.ToString();


            if (currentSet == FINAL_SET)
            {
                Debug.Log("FINAL SET");
                currentScoreToWin = SCORE_TO_WIN_LAST_SET;
            }
        }

        if (t.SetCore == SETS_TO_WIN)
        {
            MatchFinishedPanel.SetActive(true);
            hasWinner = true;
            sr        = "MATCH";

            if (teamIndex == 1)
            {
                if (!SelectionSingleton.instance.IsMinigame)
                {
                    TextEndGame.text = "You've earned <color=\"yellow\">100</color> points";
                    EarnedPointsUI.SetActive(true);
                    PointsUtil.AddPoints(100);
                }
                else
                {
                    TextEndGame.text = "You've earned <color=\"yellow\">5</color> allocation points";
                    EarnedPointsUI.SetActive(true);
                    var vsac = VSAllCountriesModel.GetCurrentGame();
                    vsac.RemainingPoints += 5;
                    vsac.CurrentLevel     = vsac.CurrentLevel < 4 ? vsac.CurrentLevel + 1 : 0;
                    VSAllCountriesModel.SaveInstance(vsac);
                    //PointsUtil.AddPoints(100);
                }
            }
        }

        ScoredTeamText.text = $"<color={c}>{t.TeamName}</color> WIN {sr}";
    }
コード例 #6
0
ファイル: AtomTradeRule.cs プロジェクト: aum-inv/AUM
        public override void Analysis(CurrentPrice price)
        {
            try
            {
                switch (ruleInfo.PriceType)
                {
                case "0":
                    CPrice = Math.Round(Convert.ToDouble(price.price), RoundNum);
                    break;

                case "1":
                    CPrice = Math.Round(price.price3, RoundNum);
                    break;

                case "2":
                    CPrice = Math.Round(price.price5, RoundNum);
                    break;

                case "3":
                    CPrice = Math.Round(price.price7, RoundNum);
                    break;

                default:
                    CPrice = Math.Round(Convert.ToDouble(price.price), RoundNum);
                    break;
                }

                if (BPrice == CPrice)
                {
                    return;
                }
                if (HPrice < CPrice)
                {
                    HPrice = Math.Round(CPrice, RoundNum);
                }
                if (LPrice > CPrice)
                {
                    LPrice = Math.Round(CPrice, RoundNum);
                }

                PriceList.Insert(CPrice);

                double basePrice = Math.Round(Convert.ToDouble(ruleInfo.BasePrice), RoundNum);
                double buyPrice  = Math.Round(GetBuyPrice(basePrice), RoundNum);

                if (ruleInfo.IsUse == "N")
                {
                    return;
                }
                if (buyPrice == 0)
                {
                    return;
                }

                // 진입
                if (!ruleInfo.IsBuyDone)
                {
                    //기준가 터치여부 체크
                    if (!ruleInfo.IsTouchedBasePrice)
                    {
                        if (ruleInfo.Position == "매수")
                        {
                            if (PointsUtil.IsBreakThroughUpDown(basePrice, PriceList))
                            {
                                ruleInfo.IsTouchedBasePrice = true;
                                ruleInfo.BasePriceTouchTime = DateTime.Now;

                                TradeEvents.Instance.OnTradeRuleHandler(AtmanName, ItemCode, $"기준가터치::{ruleInfo.Position}::{CPrice}");
                            }
                        }
                        else if (ruleInfo.Position == "매도")
                        {
                            if (PointsUtil.IsBreakThroughDownUp(basePrice, PriceList))
                            {
                                ruleInfo.IsTouchedBasePrice = true;
                                ruleInfo.BasePriceTouchTime = DateTime.Now;

                                TradeEvents.Instance.OnTradeRuleHandler(AtmanName, ItemCode, $"기준가터치::{ruleInfo.Position}::{CPrice}");
                            }
                        }
                    }

                    //매입여부 체크
                    if (ruleInfo.IsTouchedBasePrice)
                    {
                        //기준가 터치후 제약시간이상 넘었을 경우
                        if (ruleInfo.BuyLimitTime != 0 &&
                            ruleInfo.BasePriceTouchTime.AddMinutes(ruleInfo.BuyLimitTime) < DateTime.Now)
                        {
                            ruleInfo.IsUse = "N";
                            return;
                        }
                        if (ruleInfo.Position == "매수")
                        {
                            if (PointsUtil.IsBreakThroughDownUp(buyPrice, PriceList))
                            {
                                //매수진입
                                ruleInfo.IsBuyDone = true;
                                ruleInfo.BuyedTime = DateTime.Now;
                                SellBuy("신규매입", "매수");
                            }
                        }
                        else if (ruleInfo.Position == "매도")
                        {
                            if (PointsUtil.IsBreakThroughUpDown(buyPrice, PriceList))
                            {
                                //매도진입
                                ruleInfo.IsBuyDone = true;
                                ruleInfo.BuyedTime = DateTime.Now;
                                SellBuy("신규매입", "매도");
                            }
                        }
                    }
                }

                if (!ruleInfo.IsBuyDone)
                {
                    return;
                }
                double lossPrice = Math.Round(GetLossPrice(basePrice), RoundNum);
                //손실체크
                if (lossPrice > 0 && ruleInfo.IsBuyDone)
                {
                    if (ruleInfo.Position == "매수")
                    {
                        if (lossPrice >= CPrice)
                        {
                            //매도진입
                            InitRule();
                            SellBuy("손실청산", "매도");
                        }
                    }
                    else if (ruleInfo.Position == "매도")
                    {
                        if (lossPrice <= CPrice)
                        {
                            //매수진입
                            InitRule();
                            SellBuy("손실청산", "매수");
                        }
                    }
                }
                double revenuePrice = Math.Round(GetRevenuePrice(basePrice), RoundNum);
                //수익체크
                if (revenuePrice > 0 && ruleInfo.IsBuyDone)
                {
                    if (ruleInfo.RevenueLimitTime != 0 &&
                        ruleInfo.BuyedTime.AddMinutes(ruleInfo.RevenueLimitTime) < DateTime.Now)
                    {
                        //강제청산
                        if (ruleInfo.Position == "매수")
                        {
                            //매도진입
                            InitRule();
                            SellBuy("수익강제청산", "매도");
                        }
                        else if (ruleInfo.Position == "매도")
                        {
                            //매수진입
                            InitRule();
                            SellBuy("수익강제청산", "매수");
                        }
                    }
                    else
                    {
                        if (ruleInfo.Position == "매수")
                        {
                            if (revenuePrice <= CPrice)
                            {
                                //매도진입
                                InitRule();
                                SellBuy("수익청산", "매도");
                            }
                        }
                        else if (ruleInfo.Position == "매도")
                        {
                            if (revenuePrice >= CPrice)
                            {
                                //매수진입
                                InitRule();
                                SellBuy("수익청산", "매수");
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                BPrice = CPrice;
            }
        }
コード例 #7
0
 public void Reduce25Points()
 {
     PointsUtil.AddPoints(-25);
     PointsDisplay.UpdatePoints();
 }
コード例 #8
0
 public void Add25Points()
 {
     PointsUtil.AddPoints(25);
     PointsDisplay.UpdatePoints();
 }