예제 #1
0
        public void GetAllFundEmpty()
        {
            var alloc = new AllocationManager(LoggerFactory, _fetcher, null);

            alloc.SetInitialConfiguration(new Portfolio(new Dictionary <Currency, Balance>()));
            var funds = alloc.GetAllFunds();

            Assert.NotNull(funds);
            Assert.Empty(funds.AllBalances());
        }
예제 #2
0
        public void SetAllocationNoLockedFunds()
        {
            var alloc    = new AllocationManager(LoggerFactory, _fetcher, null);
            var currency = new Currency("ETH");

            Assert.Throws <AllocationUnavailableException>(() =>
                                                           alloc.SetInitialConfiguration(new Portfolio(new Dictionary <Currency, Balance>()
            {
                { currency, new Balance(currency, 1, 2) },
            })));
        }
예제 #3
0
        public void SetAllocationNoFreeFunds()
        {
            var alloc    = new AllocationManager(LoggerFactory, _fetcher, null);
            var currency = new Currency("ETH");
            var allMoney = _fetcher.GetPortfolio().Data.GetAllocation(currency).Free;

            Assert.Throws <AllocationUnavailableException>(() =>
                                                           alloc.SetInitialConfiguration(new Portfolio(new Dictionary <Currency, Balance>()
            {
                { currency, new Balance(currency, allMoney + 1, 0) },
            })));
        }
예제 #4
0
        public void SetAllocationHappyFlow()
        {
            var alloc    = new AllocationManager(LoggerFactory, _fetcher, null);
            var currency = new Currency("ETH");

            alloc.SetInitialConfiguration(new Portfolio(new Dictionary <Currency, Balance>()
            {
                { currency, new Balance(currency, 2, 0) },
            }));

            Assert.Equal(2, alloc.GetAvailableFunds(currency).Free);
            Assert.Equal(0, alloc.GetAvailableFunds(currency).Locked);
        }
예제 #5
0
        private AllocationManager MakeDefaultAllocation()
        {
            var alloc = new AllocationManager(LoggerFactory, _fetcher, null);

            alloc.SetInitialConfiguration(_fetcher.GetPortfolio().Data);

            // Free up at least 10 SNGLS (ObscureCoin)
            alloc.UpdateAllocation(
                new TradeExecution(
                    Balance.Empty(new Currency(ObscureCoin)),
                    new Balance(new Currency(ObscureCoin), 10, 0)));
            return(alloc);
        }