예제 #1
0
 public void Setup()
 {
     TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock);
     conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();
     QuoteMaker.FillQuoteStorageWithDefaultValues();
     platformManager = new PlatformManager();
 }
예제 #2
0
 public void InitTest()
 {
     // временно удалить файл начального наполнения (открытые ордера)
     TradeSharpConnectionPersistent.RenameCsvFilesInMoqDbFolder(typeof(POSITION));
     conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();
     MakeTestOrders();
 }
 public void Setup()
 {
     conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();
     ManagerTrade.MakeTestInstance();
     SetupFakeStatistics();
     FindSubscriber();
 }
예제 #4
0
        public void InitTest()
        {
            // забить котировки
            QuoteMaker.FillQuoteStorageWithDefaultValues();

            // словари
            TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock);
            DalSpot.Instantiate(TradeSharpDictionary.Instance.proxy);

            tradeManager = new TradeManager(
                null,
                null,
                QuoteStorage.Instance, accountId =>
                    {
                        // ReSharper disable ConvertToLambdaExpression
                        return LinqToEntity.DecorateAccountGroup(conn.ACCOUNT.First(a => a.ID == accountId).ACCOUNT_GROUP);
                        // ReSharper restore ConvertToLambdaExpression
                    });
            ManagerTrade.MakeTestInstance();

            // временно удалить файл начального наполнения (открытые ордера)
            TradeSharpConnectionPersistent.RestoreCsvFilesInMoqDbFolder();
            TradeSharpConnectionPersistent.RenameCsvFilesContainingAccountDataInMoqDbFolder();
            conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();
            MakeTestContents();
        }
예제 #5
0
        public static List<POSITION> MakePositions(TradeSharpConnectionPersistent conn, int accountId)
        {
            var allPositions = new List<POSITION>();

            // создать сделки по счету
            var tickers = new[] { "EURUSD", "USDJPY", "AUDUSD", "EURCAD" };
            var timeNow = DateTime.Now;
            var times = new[] { timeNow.AddDays(-2), timeNow.AddDays(-1), timeNow.AddHours(-1) };
            var sides = new[] { -1, 1 };

            foreach (var ticker in tickers)
            foreach (var side in sides)
            foreach (var time in times)
            {
                var quote = QuoteStorage.Instance.ReceiveValue(ticker);
                var pos = new POSITION
                {
                    AccountID = accountId,
                    Symbol = ticker,
                    Side = side,
                    TimeEnter = time,
                    State = (int)PositionState.Opened,
                    PriceEnter = (decimal)(side == 1 ? quote.ask : quote.bid),
                    Volume = 100000
                };
                allPositions.Add(pos);
                conn.POSITION.Add(pos);
            }

            return allPositions;
        }
예제 #6
0
 public void SetupTest()
 {
     // подготовить свежие котировки
     QuoteMaker.FillQuoteStorageWithDefaultValues();
     conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();
     ACCOUNT eurAccount;
     AccountShareTestDataMaker.MakePammData(conn, out testAccount, out shareOwner, out eurAccount);
 }
 public static TradeSharpConnectionPersistent InitializeTradeSharpConnection()
 {
     var path = GetCsvFilesFolder();
     var loader = new CsvDataLoader(path);
     var connection = Effort.EntityConnectionFactory.CreateTransient("name=TradeSharpConnection", loader);
     var connectionPersistent = new TradeSharpConnectionPersistent(connection);
     DatabaseContext.InitializeFake(connectionPersistent);
     return connectionPersistent;
 }
예제 #8
0
        public void SetupTest()
        {
            MakeFakeTradeProxy();

            conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();

            // очистить подписки на портфели
            foreach (var sub in conn.USER_TOP_PORTFOLIO.ToList())
                conn.USER_TOP_PORTFOLIO.Remove(sub);
            foreach (var portf in conn.TOP_PORTFOLIO.ToList())
                conn.TOP_PORTFOLIO.Remove(portf);
            conn.SaveChanges();

            // определить владельцев портфелей и подписантов
            portOwners =
                conn.PLATFORM_USER_ACCOUNT.Where(a => a.RightsMask == (int) AccountRights.Управление).Take(2).ToArray();
            var lastOwnerId = portOwners[portOwners.Length - 1].PlatformUser;
            portSubs =
                conn.PLATFORM_USER_ACCOUNT.Where(a => a.RightsMask == (int)AccountRights.Управление).Where(a => a.PlatformUser > lastOwnerId).Take(2).ToArray();

            // создать портфели
            portfolios = new []
                {
                    new TOP_PORTFOLIO
                        {
                            Criteria = "AYP",
                            ParticipantCount = 3,
                            OwnerUser = portOwners[0].PlatformUser,
                            Name = "P1"
                        },
                    new TOP_PORTFOLIO
                        {
                            Criteria = "DD",
                            ParticipantCount = 2,
                            OwnerUser = portOwners[1].PlatformUser,
                            Name = "P1"
                        }
                };
            foreach (var pf in portfolios)
                conn.TOP_PORTFOLIO.Add(pf);
            conn.SaveChanges();

            // подписать пользователей на портфели
            var curPortfolioIndex = 0;
            foreach (var usr in portSubs)
            {
                var port = portfolios[curPortfolioIndex++];
                if (curPortfolioIndex == portfolios.Length) curPortfolioIndex = 0;
                conn.USER_TOP_PORTFOLIO.Add(new USER_TOP_PORTFOLIO
                    {
                        User = usr.PlatformUser,
                        Portfolio = port.Id
                    });
            }
            conn.SaveChanges();
        }
예제 #9
0
        public static TradeSharpConnectionPersistent InitializeTradeSharpConnection()
        {
            var path                 = GetCsvFilesFolder();
            var loader               = new CsvDataLoader(path);
            var connection           = Effort.EntityConnectionFactory.CreateTransient("name=TradeSharpConnection", loader);
            var connectionPersistent = new TradeSharpConnectionPersistent(connection);

            DatabaseContext.InitializeFake(connectionPersistent);
            return(connectionPersistent);
        }
예제 #10
0
        public void InitTest()
        {
            // забить котировки
            QuoteMaker.FillQuoteStorageWithDefaultValues();

            // словари
            TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock);

            // временно удалить файл начального наполнения (открытые ордера)
            TradeSharpConnectionPersistent.RestoreCsvFilesInMoqDbFolder();
            //TradeSharpConnectionPersistent.RenameCsvFilesContainingAccountDataInMoqDbFolder();
            conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();
            MakeTestData();
        }
예제 #11
0
        public void Setup()
        {
            conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();
            // подготовить свежие котировки
            QuoteMaker.FillQuoteStorageWithDefaultValues();

            // словари
            TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock);

            ManagerTrade.MakeTestInstance();
            testManager = ManagerAccount.Instance;

            // тестовые данные
            MakeTestData();
        }
예제 #12
0
        public void TestSetup()
        {
            connectionPersistent = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();
            TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock);
            walletManager = new WalletManager();

            DatabaseContext.InitializeFake(connectionPersistent);
        }
예제 #13
0
        public void Setup()
        {
            // подыграть за торговый контракт
            SetupFakeServer();

            // инициализировать словари (прежде всего - словарь тикеров)
            TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock);

            connection = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();

            // пользователь - владелец тестового сервиса
            var ownerUser = new PLATFORM_USER
                {
                    Email = "*****@*****.**",
                    Login = "******",
                    Title = "Vafel",
                    RoleMask = 0,
                    Password = "******",
                    RegistrationDate = DateTime.Now
                };
            connection.PLATFORM_USER.Add(ownerUser);
            connection.SaveChanges();

            // добавить категорию сигналов
            var srv = new SERVICE
                {
                    FixedPrice = 0,
                    Currency = "USD",
                    User = ownerUser.ID
                };
            connection.SERVICE.Add(srv);
            connection.SaveChanges();
            serviceId = srv.ID;

            // добавить пользователя
            var user = new PLATFORM_USER
                {
                    Email = "*****@*****.**",
                    Login = "******",
                    Password = "******",
                    Title = "test",
                    RegistrationDate = DateTime.Now
                };
            connection.PLATFORM_USER.Add(user);
            connection.SaveChanges();
            testUserId = user.ID;

            // добавить счет и сделок
            var group = connection.ACCOUNT_GROUP.First(g => !g.IsReal);
            var account = new ACCOUNT
                {
                    AccountGroup = group.Code,
                    Currency = AccountCurrency,
                    Balance = 30000
                };
            connection.ACCOUNT.Add(account);
            connection.SaveChanges();
            testAccountId = account.ID;

            // назначить пользователя владельцем счета
            connection.PLATFORM_USER_ACCOUNT.Add(new PLATFORM_USER_ACCOUNT
                {
                    Account = testAccountId,
                    PlatformUser = testUserId,
                    RightsMask = (int) AccountRights.Управление
                });

            // подписать счет на сигнал
            connection.SUBSCRIPTION.Add(new SUBSCRIPTION
                {
                    User = testUserId,
                    Service = serviceId,
                    RenewAuto = true,
                    TimeEnd = DateTime.Now.Date.AddDays(1)
                });
            connection.SUBSCRIPTION_SIGNAL.Add(new SUBSCRIPTION_SIGNAL
            {
                User = testUserId,
                Service = serviceId,
                AutoTrade = true,
                PercentLeverage = 120,
                MinVolume = 10000,
                TargetAccount = testAccountId
            });
            connection.SaveChanges();

            // позиции
            MakeOrdersForTest();
            foreach (var order in ordersForTest)
            {
                var pos = LinqToEntity.UndecorateOpenedPosition(order);
                connection.POSITION.Add(pos);
            }
            connection.SaveChanges();

            // прописать срез котировок
            var nowTime = DateTime.Now;
            Contract.Util.BL.QuoteStorage.Instance.UpdateValues(new []
                {
                    "EURUSD", "GBPUSD", "USDJPY", "EURGBP"
                },
                new []
                    {
                        new QuoteData(1.3820f, 1.3822f, nowTime),
                        new QuoteData(1.5350f, 1.5354f, nowTime),
                        new QuoteData(90.81f, 90.83f, nowTime),
                        new QuoteData(1.1107f, 1.1112f, nowTime)
                    }
                );
        }
예제 #14
0
 private void SetupDatabase()
 {
     connectionPersistent = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();
 }
예제 #15
0
 public void Setup()
 {
     connectionPersistent = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();
     DatabaseContext.InitializeFake(connectionPersistent);
 }
예제 #16
0
 public void InitTest()
 {
     connectionPersistent = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();
 }