示例#1
0
        public void save_update_load_find_delete_strategy()
        {
            TestActorRef<PersistenceActor> persistenceActorRef = ActorOfAsTestActorRef<PersistenceActor>("persistence");
            EStrategy strategy = new EStrategy() { Type = "Quanter.Strategy.Demo.DemoStrategyActor, Quanter.Strategy.Demo", Desc="测试策略", Name = "策略DEMO", Date=DateTime.Now };
            PersistenceRequest req = new PersistenceRequest() { Type = PersistenceType.SAVE, Body = strategy};
            persistenceActorRef.Tell(req);

        }
示例#2
0
        public void save_update_load_find_delete_strategy()
        {
            ETrader trader = new ETrader() { Username = "******", Password = "******", ServicePwd = "012345678", Path = "c:/xiadan/xiadan.exe", Date = DateTime.Now };
            PersistenceRequest req = new PersistenceRequest() { Type = PersistenceType.SAVE, Body = trader };
            persistenceActorRef.Tell(req);
            var result = ExpectMsg<ETrader>();

            EStrategy strategy = new EStrategy() { Type = "Quanter.Strategy.Demo.DemoStrategyActor, Quanter.Strategy.Demo", Desc="测试策略", Name = "策略DEMO", EnableBalance=50000, FrozenBalance =0, Enabled = true, Date=DateTime.Now, Trader = result };
            req = new PersistenceRequest() { Type = PersistenceType.SAVE, Body = strategy};
            persistenceActorRef.Tell(req);
            var result1 = ExpectMsg<EStrategy>();
            Assert.NotEqual(0, result1.Id);

            req = new PersistenceRequest() { Type = PersistenceType.FIND, Body = "from EStrategy where Id=1" };
            persistenceActorRef.Tell(req);
            var result2 = ExpectMsg<EStrategy>();
            Assert.Equal(1, result2.Id);
            Assert.Equal("012345678", result2.Trader.Username);

        }
示例#3
0
        public void save_update_load_find_delete_cube()
        {
            PersistenceRequest req = new PersistenceRequest() { Type = PersistenceType.LIST, Body = "from ECube" };
            persistenceActorRef.Tell(req);
            var result0 = ExpectMsg<List<object>>();

            Assert.Equal(0, result0.Count);

            // 先保存Trader
            ETrader trader = new ETrader() { Username = "******", Password = "******", ServicePwd = "012345678", Path = "c:/xiadan/xiadan.exe", Date = DateTime.Now };
             req = new PersistenceRequest() { Type = PersistenceType.SAVE, Body = trader };
            persistenceActorRef.Tell(req);
            var result = ExpectMsg<ETrader>();

            // 保存strategy
            EStrategy strategy = new EStrategy() { Type = "Quanter.Strategy.XueQiuStrategy.TraceXueQiuStrategyActor, Quanter.Strategy.XueQiuStrategy", Desc = "测试策略", Name = "组合策略DEMO", EnableBalance = 50000, FrozenBalance = 0, Enabled = true, Date = DateTime.Now, Trader = null };
            EStockHolder holder = new EStockHolder() { Strategy = strategy, Code = "000001", Symbol = "000001.XSHE", Name = "平安银行", CostPrice = 11.03f, LastPrice = 12.0f, IncomeAmount = 1000, EnableAmount = 1000 };
            EStockHolder holder1 = new EStockHolder() { Strategy = strategy, Code = "000002", Symbol = "000002.XSHE", Name = "万科A", CostPrice = 9.03f, LastPrice = 12.0f, IncomeAmount = 1000, EnableAmount = 1000 };
            strategy.Holders.Add(holder);
            strategy.Holders.Add(holder1);


            ECube cube = new ECube()
            {
                Strategy = strategy,
                Symbol = "ZH000003",
                PreAdjustmentId = 0,
            };

            req = new PersistenceRequest() { Type = PersistenceType.SAVE, Body = cube };
            persistenceActorRef.Tell(req);
            var result2 = ExpectMsg<ECube>();
            Assert.NotEqual(0, result2.Id);
            Assert.Equal(result2.Symbol, "ZH000003");

            req = new PersistenceRequest() { Type = PersistenceType.LIST, Body = "from ECube" };
            persistenceActorRef.Tell(req);
            var result3 = ExpectMsg<List<object>>();

            Assert.NotEqual(0, result3.Count);
            Assert.Equal("ZH000003", ((ECube)result3[0]).Symbol); 
        }
示例#4
0
 public void Remove(EStrategy sd)
 {
     sds.Remove(sd);
 }
示例#5
0
 public void Add(EStrategy sd)
 {
     sds.Add(sd);
 }
示例#6
0
        private void btnRegStrategy_Click(object sender, EventArgs e)
        {
            // Load一个新的策略实例
            EStrategy strategy1 = new EStrategy()
            {
                Id = 1,
                Type = "Quanter.Strategy.Demo.DemoStrategyActor, Quanter.Strategy.Demo",
                Name= "Demo示例",
                Desc = "Demo实例"
            };

            EStrategy strategy2 = new EStrategy()
            {
                Id = 2,
                Type = "Quanter.Strategy.XueQiuStrategy.TraceXueQiuStrategyActor, Quanter.Strategy.XueQiuStrategy",
                Name = "雪球策略",
                Desc = "雪球实例"
            };

            EStrategy strategy3 = new EStrategy()
            {
                Id = 3,
                Type = "Quanter.Strategy.RationBStrategyActor, Quanter.Strategy.RationB",
                Name = "分级策略",
                Desc = "雪球实例"
            };

            StrategyRequest req = new StrategyRequest() { Type = StrategyRequestType.CREATE, Body = strategy1 };
            strategyActor.Tell(req);
            //req = new StrategyRequest() { Type = StrategyRequestType.CREATE, Body = strategy2 };
            //strategyActor.Tell(req);
            //req = new StrategyRequest() { Type = StrategyRequestType.CREATE, Body = strategy3 };
            //strategyActor.Tell(req);

        }
示例#7
0
 public DemoStrategyActor(EStrategy strategy) : base(strategy)
 {
     _log.Debug("创建编码为 {0} StrategyActor实例", strategy.Id);
 }