예제 #1
0
        public override bool onStart(int ticks)
        {
            spreadAnalyzer = new SpreadAnalyzer(100);
            strategyTime   = new StrategyTime(param["ProhibitedStartHour"], param["ProhibitedStartMinute"], param["ProhibitedDuration"], (param.Keys.Contains("GMT") ? param["GMT"] : 0), 31);

            return(true);
        }
        public override bool onStart(int ticks)
        {
            spreadAnalyzer = new SpreadAnalyzer(100);

            int maxCountParam = 1000;

            //history simulator initialize only first parameter.
            if (this.TestingMode)
            {
                maxCountParam = 1;
            }
            for (int i = 1; i <= maxCountParam; i++)
            {
                string paramName = string.Format("P{0}String", i);
                if (this.param.ContainsString(paramName))
                {
                    BuyLimitAndWaitParam cparam = new BuyLimitAndWaitParam();
                    cparam.RawStrategyParam = this.param.GetStringParameter(paramName);
                    string[] paramStr = cparam.RawStrategyParam.Split(new char[] { ',' });
                    cparam.Symbol             = paramStr[0];
                    cparam.TP                 = Int32.Parse(paramStr[1]);
                    cparam.OpenOrderShift     = Int32.Parse(paramStr[2]);
                    cparam.BasicVolume        = Int32.Parse(paramStr[3]);
                    cparam.OpenMode           = (OpenMode)Int32.Parse(paramStr[4]);
                    cparam.StartDate          = new DateTime(Int32.Parse(paramStr[5]), Int32.Parse(paramStr[6]), 1);
                    cparam.ID                 = i;
                    cparam.InitHistoryMinutes = this.TestingMode ? 0 : Int32.Parse(paramStr[7]);
                    cparam.ReadOnly           = Int32.Parse(paramStr[8]);
                    cparam.MinTradeVolume     = Int32.Parse(paramStr[9]);

                    customParams.Add(cparam);
                }
            }

            if (this.customParams.Count == 0)
            {
                BuyLimitAndWaitParam cparam = new BuyLimitAndWaitParam();
                cparam.Symbol             = base.Symbol;
                cparam.TP                 = param["TP"];
                cparam.OpenOrderShift     = param["OpenOrderShift"];
                cparam.BasicVolume        = param["BasicVolume"];
                cparam.OpenMode           = (OpenMode)this.param["OpenMode"];
                cparam.InitHistoryMinutes = this.param["InitHistoryMinutes"];
                cparam.StartDate          = new DateTime(this.param["StartYear"], this.param["StartMonth"], 1);
                cparam.MinTradeVolume     = this.param["MinTradeVolume"];
                cparam.ID                 = 0;

                cparam.ReadOnly = this.param[ReadOnlyParamName];
                customParams.Add(cparam);
            }
            foreach (BuyLimitAndWaitParam cparam in customParams)
            {
                cparam.TralTP = (cparam.TP + cparam.OpenOrderShift) * 5;
            }

            return(true);
        }
예제 #3
0
        public void AnalyzeTest()
        {
            var mConfigRepository = new Mock <IConfigStore>();
            var mPositionService  = new Mock <IPositionService>();
            var config            = new ConfigRoot {
                MaxSize = 0.5m
            };

            mConfigRepository.Setup(x => x.Config).Returns(config);
            mPositionService.Setup(x => x.PositionMap).Returns(new Dictionary <Broker, BrokerPosition>
            {
                {
                    Broker.Coincheck,
                    new BrokerPosition
                    {
                        AllowedLongSize  = 10,
                        AllowedShortSize = 10,
                        LongAllowed      = true,
                        ShortAllowed     = true
                    }
                },
                {
                    Broker.Quoine,
                    new BrokerPosition
                    {
                        AllowedLongSize  = 10,
                        AllowedShortSize = 10,
                        LongAllowed      = true,
                        ShortAllowed     = true
                    }
                }
            });

            var configStore     = mConfigRepository.Object;
            var positionService = mPositionService.Object;

            var quotes = new List <Quote>
            {
                new Quote(Broker.Coincheck, QuoteSide.Ask, 3, 1),
                new Quote(Broker.Coincheck, QuoteSide.Bid, 2, 2),
                new Quote(Broker.Quoine, QuoteSide.Ask, 3.5m, 3),
                new Quote(Broker.Quoine, QuoteSide.Bid, 2.5m, 4)
            };

            var target = new SpreadAnalyzer(configStore, positionService);
            var result = target.Analyze(quotes);

            Assert.AreEqual(Broker.Coincheck, result.BestAsk.Broker);
            Assert.AreEqual(3, result.BestAsk.Price);
            Assert.AreEqual(1, result.BestAsk.Volume);
            Assert.AreEqual(Broker.Quoine, result.BestBid.Broker);
            Assert.AreEqual(2.5m, result.BestBid.Price);
            Assert.AreEqual(4, result.BestBid.Volume);
            Assert.AreEqual(-0.5m, result.InvertedSpread);
            Assert.AreEqual(0.5m, result.TargetVolume);
        }
예제 #4
0
        public override bool onStart(int ticks)
        {
            ExtremumPoint  = new ExtremumPointStrategy((param["TP"] * param["TPCoefExtremum"]) / 10);
            ExtremumPoint2 = new ExtremumPointStrategy((param["TP"] * param["TPCoefExtremum2"]) / 10);
            strategyTime   = new StrategyTime(param["ProhibitedStartHour"], param["ProhibitedStartMinute"], param["ProhibitedDuration"], (param.Keys.Contains("GMT") ? param["GMT"] : 0), 31);
            spreadAnalyzer = new SpreadAnalyzer(100);

            InitExtremum(1000);
            if (logger != null)
            {
                this.logger.AddMessage("Start strategy with parameter {0}", param.ToString());
            }

            return(true);
        }
예제 #5
0
        public override bool onStart(int ticks)
        {
            ExtremumPoint = new ExtremumPointStrategy(param["TP"]);
            InitExtremum(param["NumberInitPeriods"]);
            if (ExtremumPoint.Count <= param["NumberEndFluctuation"])
            {
                logger.AddMessage("onStart error. Number of extremums in history is too low = " + ExtremumPoint.Count.ToString());
                return(false);
            }

            fluctuationList = new FluctuationCollection(param["NumberStartFluctuation"], param["NumberEndFluctuation"]);

            for (int i = fluctuationList.StartIndex; i < fluctuationList.EndIndex; i++)
            {
                Meta.ObjectCreate(GetHLineName(i), MetaObjectType.OBJ_HLINE, 0, DateTime.Now, 148000, FxAdvisorCore.Convertor.startTime, 0, FxAdvisorCore.Convertor.startTime, 0).ToString();
                Meta.ObjectSetText(GetHLineName(i), i.ToString(), 10, "", 0);
            }
            newsPeriod     = new NewsPeriods(param.NewsFilePath, 300, 600, base.Symbol, base.TestingMode, (param.Keys.Contains("GMT") ? param["GMT"] : 0), this.logger);
            spreadAnalyzer = new SpreadAnalyzer(100);
            strategyTime   = new StrategyTime(param["ProhibitedStartHour"], param["ProhibitedStartMinute"], param["ProhibitedDuration"], (param.Keys.Contains("GMT") ? param["GMT"] : 0), 31);

            return(true);
        }
예제 #6
0
        public override bool onStart(int ticks)
        {
            spreadAnalyzer = new SpreadAnalyzer(100);
            for (int i = 0; i < 1000; i++)
            {
                string paramName = string.Format("P{0}String", i);
                if (this.param.ContainsString(paramName))
                {
                    string[]             paramStr = this.param.GetStringParameter(paramName).Split(new char[] { ',' });
                    BuyLimitAndWaitParam cparam   = new BuyLimitAndWaitParam();
                    cparam.Symbol             = paramStr[0];
                    cparam.TP                 = Int32.Parse(paramStr[1]);
                    cparam.OpenOrderShift     = Int32.Parse(paramStr[2]);
                    cparam.BasicVolume        = Int32.Parse(paramStr[3]);
                    cparam.ID                 = i;
                    cparam.InitHistoryMinutes = this.param["InitHistoryMinutes"];
                    customParams.Add(cparam);
                }
            }
            if (this.customParams.Count == 0)
            {
                BuyLimitAndWaitParam cparam = new BuyLimitAndWaitParam();
                cparam.ID                 = 0;
                cparam.TP                 = param["TP"];
                cparam.OpenOrderShift     = param["OpenOrderShift"];
                cparam.Symbol             = base.Symbol;
                cparam.BasicVolume        = param["BasicVolume"];
                cparam.InitHistoryMinutes = this.param["InitHistoryMinutes"];
                customParams.Add(cparam);
            }
            foreach (BuyLimitAndWaitParam cparam in customParams)
            {
                TralTP = cparam.OpenOrderShift * cparam.TralTP;
            }

            return(true);
        }
예제 #7
0
 public override bool onStart(int ticks)
 {
     spreadAnalyzer = new SpreadAnalyzer(100);
     return(true);
 }
예제 #8
0
        public override bool onStart(int ticks)
        {
            for (int i = 0; i < 1000; i++)
            {
                string paramName = string.Format("P{0}String", i);
                if (this.param.ContainsString(paramName))
                {
                    string[]        paramStr = this.param.GetStringParameter(paramName).Split(new char[] { ',' });
                    MartinGaleParam cparam   = new MartinGaleParam();
                    cparam.Symbol      = paramStr[0];
                    cparam.TP          = Int32.Parse(paramStr[1]);
                    cparam.MaxSteps    = Int32.Parse(paramStr[2]);
                    cparam.StartShift  = Int32.Parse(paramStr[3]) * cparam.TP / 10;
                    cparam.CoefVolume  = Int32.Parse(paramStr[4]);
                    cparam.BasicVolume = Int32.Parse(paramStr[5]);
                    cparam.ID          = i;
                    if (this.param.Contains("InitHistoryMinutes"))
                    {
                        cparam.InitHistoryMinutes = this.param["InitHistoryMinutes"];
                    }
                    else
                    {
                        cparam.InitHistoryMinutes = 0;
                    }
                    if (this.param.Contains(ReadOnlyParamName))
                    {
                        cparam.ReadOnly = this.param[ReadOnlyParamName];
                    }
                    else
                    {
                        cparam.ReadOnly = 0;
                    }
                    customParams.Add(cparam);
                }
            }
            if (this.customParams.Count == 0)
            {
                MartinGaleParam cparam = new MartinGaleParam();
                cparam.Symbol      = base.Symbol;
                cparam.TP          = param["TP"];
                cparam.MaxSteps    = param["MaxSteps"];
                cparam.StartShift  = param["StartShift"] * cparam.TP / 10;
                cparam.CoefVolume  = param["CoefVolume"];
                cparam.BasicVolume = param["BasicVolume"];
                cparam.ID          = 0;
                if (this.param.Contains("InitHistoryMinutes"))
                {
                    cparam.InitHistoryMinutes = this.param["InitHistoryMinutes"];
                }
                else
                {
                    cparam.InitHistoryMinutes = 0;
                }
                if (this.param.Contains(ReadOnlyParamName))
                {
                    cparam.ReadOnly = this.param[ReadOnlyParamName];
                }
                else
                {
                    cparam.ReadOnly = 0;
                }
                customParams.Add(cparam);
            }

            this.logger.AddMessage("Start strategy with parameter {0}", param.ToString());
            foreach (MartinGaleParam cParam in customParams)
            {
                ExtremumPoints.Add(new ExtremumPointStrategy(cParam.TP));
            }
            //this.logger.AddMessage("Init Extremums 1000");
            //InitExtremum(1000);
            spreadAnalyzer = new SpreadAnalyzer(100);
            return(true);
        }