/// <summary>
 /// Smoothly interpolates the companion rotation to face the target position   	
 /// </summary>
 /// <param name="target">The position to look at</param>
 void LookAtTarget(Vector3 target)
 {
     Quaternion lookAngle = StaticCalculations.GetLookRotation(target, transform.position, transform.forward, out bool rotate);
     if (rotate)
     {
         transform.localRotation = Quaternion.Slerp(transform.localRotation, lookAngle, Time.deltaTime * 5);
     }
 }
        /// <summary>
        /// Passes the name of the collided object to an event.
        /// An objective can then use this to detect if the correct item has been picked up
        /// </summary>
        protected virtual void Process(Collider col)
        {
            string colname = StaticCalculations.ProcessObjectName(col.name);

            if (acceptedItemSlugs.Length == 0)
            {
                QuestEvents.ItemCollected(colname);
            }
            else
            {
                for (int i = 0; i < acceptedItemSlugs.Length; i++)
                {
                    if (colname.Equals(acceptedItemSlugs[i]))
                    {
                        QuestEvents.ItemCollected(colname);
                        AudioManager.instance.PlayObjectiveComplete();
                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
        // end opt

        public static void Algoritm(ParametrTradesBolinger pcT, TestTradesCollection testTradColl, TestTradesCollection testTradCollOPT, string file_name, double price, DateTime dateTimeTrade, ref int tp, ref int countTrades, ref int countTradesOpt, ref double profitPortfolio, ref double profitPortfolioOpt, ref double maxProfit, ref double maxProfitOpt, ref double minProfit, ref double minProfitOpt, ref int countProfitTrades, ref int countProfitTradesOpt, ref int countLossTrades, ref int countLossTradesOpt)
        {
            double profit = 0; // прибыль самой сделки
            double qty    = 0;

            lineUp   = pcT.LineUp;
            lineDown = pcT.LineDown;
            lineMidl = pcT.LineMidl;

            // long
            if (tp <= 0 && price > lineUp)
            {
                price_buy = price + SettingsClass.slipPrice;
                profit    = StaticCalculations.CalcProfit(price_buy, price_sell);

                qty = Math.Abs(tp) + 1; //--1--
                tp += Math.Abs(tp) + 1; //--2--

                StaticCalculations.CalcParametrTest(profit, dateTimeTrade, ref countTrades, ref profitPortfolio, ref maxProfit, ref minProfit, ref countProfitTrades, ref countLossTrades);

                testTradColl.Add(new ParametrTestTrades(pcT.NumberTrades, dateTimeTrade, price_buy, qty, Operation.Buuy, profitPortfolio));

                // log
                StaticService.LogFileWrite("-----" + "\t" + pcT.NumberTrades + "\t" + dateTimeTrade + "\t" + price_buy + "\t" + qty + "\t" + Operation.Buuy + " \t" + profit + "\t" + profitPortfolio + "\tlongProfit: " + longProfit + "\tshortProfit: " + shortProfit + "\t level_0", file_name, true);

                //---Opt---
                //if (StaticOptimizer.PsevdoRealTrades(profit, dateTimeTrade, ref counter_prof, ref counter_loss))
                //{
                //    CalcParametrTest(profit, dateTimeTrade, ref countTradesOpt, ref profitPortfolioOpt, ref maxProfitOpt, ref minProfitOpt, ref countProfitTradesOpt, ref countLossTradesOpt);
                //    testTradCollOPT.Add(new ParametrTestTrades(pcT.NumberTrades, dateTimeTrade, price_buy, qty, Operation.Buy, profitPortfolioOpt));

                //    // log Opt
                //    StaticService.LogFileWrite("-----" + "\t" + pcT.NumberTrades + "\t" + dateTimeTrade + "\t" + price_buy + "\t" + qty + "\t" + Operation.Buy + "\t" + profitPortfolioOpt + "\t level_1", file_name, true);
                //}

                if (shortProfit)
                {
                    StaticCalculations.CalcParametrTest(profit, dateTimeTrade, ref countTradesOpt, ref profitPortfolioOpt, ref maxProfitOpt, ref minProfitOpt, ref countProfitTradesOpt, ref countLossTradesOpt);
                    testTradCollOPT.Add(new ParametrTestTrades(pcT.NumberTrades, dateTimeTrade, price_buy, qty, Operation.Buuy, profitPortfolioOpt));

                    // log Opt
                    StaticService.LogFileWrite("-----" + "\t" + pcT.NumberTrades + "\t" + dateTimeTrade + "\t" + price_buy + "\t" + qty + "\t" + Operation.Buuy + " \t" + profit + "\t" + profitPortfolioOpt + "\tshortProfit: " + shortProfit + "\t level_1", file_name, true);
                }

                StaticOptimizer.PsevdoRealTrades(profit, false, ref longProfit, ref shortProfit);

                //---end Opt---
            }

            // short
            if (tp >= 0 && price < lineDown)
            {
                price_sell = price - SettingsClass.slipPrice;
                profit     = StaticCalculations.CalcProfit(price_buy, price_sell);

                qty = Math.Abs(tp) + 1; //--1--
                tp -= Math.Abs(tp) + 1; //--2--

                StaticCalculations.CalcParametrTest(profit, dateTimeTrade, ref countTrades, ref profitPortfolio, ref maxProfit, ref minProfit, ref countProfitTrades, ref countLossTrades);

                testTradColl.Add(new ParametrTestTrades(pcT.NumberTrades, dateTimeTrade, price_sell, qty, Operation.Sell, profitPortfolio));

                // log
                StaticService.LogFileWrite("-----" + "\t" + pcT.NumberTrades + "\t" + dateTimeTrade + "\t" + price_sell + "\t" + qty + "\t" + Operation.Sell + "\t" + profit + "\t" + profitPortfolio + "\tlongProfit: " + longProfit + "\tshortProfit: " + shortProfit + "\t level_0", file_name, true);

                // Opt
                //if (StaticOptimizer.PsevdoRealTrades(profit, dateTimeTrade, ref counter_prof, ref counter_loss))
                //{
                //    CalcParametrTest(profit, dateTimeTrade, ref countTradesOpt, ref profitPortfolioOpt, ref maxProfitOpt, ref minProfitOpt, ref countProfitTradesOpt, ref countLossTradesOpt);
                //    testTradCollOPT.Add(new ParametrTestTrades(pcT.NumberTrades, dateTimeTrade, price_sell, qty, Operation.Sell, profitPortfolioOpt));

                //    // log Opt
                //    StaticService.LogFileWrite("-----" + "\t" + pcT.NumberTrades + "\t" + dateTimeTrade + "\t" + price_sell + "\t" + qty + "\t" + Operation.Sell + "\t" + profitPortfolioOpt + "\t level_1", file_name, true);

                //}

                if (longProfit)
                {
                    StaticCalculations.CalcParametrTest(profit, dateTimeTrade, ref countTradesOpt, ref profitPortfolioOpt, ref maxProfitOpt, ref minProfitOpt, ref countProfitTradesOpt, ref countLossTradesOpt);
                    testTradCollOPT.Add(new ParametrTestTrades(pcT.NumberTrades, dateTimeTrade, price_sell, qty, Operation.Sell, profitPortfolioOpt));

                    // log Opt
                    StaticService.LogFileWrite("-----" + "\t" + pcT.NumberTrades + "\t" + dateTimeTrade + "\t" + price_sell + "\t" + qty + "\t" + Operation.Sell + "\t" + profit + "\t" + profitPortfolioOpt + "\tlongProfit: " + longProfit + "\t level_1", file_name, true);
                }

                StaticOptimizer.PsevdoRealTrades(profit, true, ref longProfit, ref shortProfit);

                //---end Opt---
            }
        }