public void CanUpdateOrderTest()
        {
            BrokerageMessageEvent message;

            Assert.AreEqual(false, _gdaxBrokerageModel.CanUpdateOrder(TestsHelpers.GetSecurity(), Mock.Of <Order>(),
                                                                      new UpdateOrderRequest(DateTime.UtcNow, 1, new UpdateOrderFields()), out message));
        }
        public void FeeModelReturnsCorrectOrderFeeForMakerLimitOrdersMinuteResolution()
        {
            var time     = new DateTime(2018, 4, 10);
            var security = TestsHelpers.GetSecurity();

            security.FeeModel = new GDAXFeeModel();
            security.SetMarketPrice(new TradeBar {
                Symbol = security.Symbol, Close = 5000m, EndTime = time.AddSeconds(75)
            });

            var orderFee = security.FeeModel.GetOrderFee(new OrderFeeParameters(
                                                             security, new LimitOrder(security.Symbol, 1, 4999.99m, time)
            {
                OrderSubmissionData = new OrderSubmissionData(security.BidPrice, security.AskPrice, security.Price)
            }));

            Assert.AreEqual(0, orderFee.Value.Amount);
            Assert.AreEqual(Currencies.USD, orderFee.Value.Currency);

            orderFee = security.FeeModel.GetOrderFee(new OrderFeeParameters(
                                                         security, new LimitOrder(security.Symbol, -1, 5000.01m, time)
            {
                OrderSubmissionData = new OrderSubmissionData(security.BidPrice, security.AskPrice, security.Price)
            }));

            Assert.AreEqual(0, orderFee.Value.Amount);
            Assert.AreEqual(Currencies.USD, orderFee.Value.Currency);
        }
        public void CanOnlySubmitCryptoOrders(SecurityType securityType, bool isValidSecurityType)
        {
            BrokerageMessageEvent message;
            var order = new Mock <Order>();

            order.Object.Quantity = 10.0m;

            Assert.AreEqual(isValidSecurityType, _gdaxBrokerageModel.CanSubmitOrder(TestsHelpers.GetSecurity(1.0m, securityType), order.Object, out message));
        }
        public void CanSubmitOrder_WhenQuantityIsLargeEnough(decimal orderQuantity, bool isValidOrderQuantity)
        {
            BrokerageMessageEvent message;
            var order = new Mock <Order>();

            order.Object.Quantity = orderQuantity;

            Assert.AreEqual(isValidOrderQuantity, _gdaxBrokerageModel.CanSubmitOrder(TestsHelpers.GetSecurity(), order.Object, out message));
        }
        public void CanSubmit_CertainOrderTypes(OrderType orderType, int year, int month, int day, int hour, int minute, int second, bool isValidOrderType)
        {
            var utcTime = new DateTime(year, month, day, hour, minute, second);

            BrokerageMessageEvent message;
            var security = TestsHelpers.GetSecurity();
            var order    = Order.CreateOrder(new SubmitOrderRequest(orderType, SecurityType.Crypto, security.Symbol, 10.0m, 1.0m, 10.0m, utcTime, "Test Order"));

            Assert.AreEqual(isValidOrderType, _gdaxBrokerageModel.CanSubmitOrder(security, order, out message));
        }
        public void FeeModelReturnsCorrectOrderFeeForTakerMarketOrder()
        {
            var security = TestsHelpers.GetSecurity();

            security.FeeModel = new GDAXFeeModel();
            security.SetMarketPrice(new TradeBar {
                Symbol = security.Symbol, Close = 5000m
            });
            var orderFee = security.FeeModel.GetOrderFee(new OrderFeeParameters(
                                                             security,
                                                             new MarketOrder(security.Symbol, 1, DateTime.MinValue)));

            Assert.AreEqual(15m, orderFee.Value.Amount);
            Assert.AreEqual(Currencies.USD, orderFee.Value.Currency);
        }
        public void CanSubmitOrder_WhenBrokerageIdIsCorrect(bool isUpdate)
        {
            BrokerageMessageEvent message;
            var order = new Mock <Order>();

            order.Object.Quantity = 10.0m;

            if (isUpdate)
            {
                order.Object.BrokerId = new List <string>()
                {
                    "abc123"
                };
            }

            Assert.AreEqual(!isUpdate, _gdaxBrokerageModel.CanSubmitOrder(TestsHelpers.GetSecurity(), order.Object, out message));
        }
        public void FeeModelReturnsCorrectOrderFeeForTakerLimitOrdersTickResolution()
        {
            var security = TestsHelpers.GetSecurity(resolution: Resolution.Tick);

            security.FeeModel = new GDAXFeeModel();
            security.SetMarketPrice(new Tick {
                Symbol = security.Symbol, Value = 5000m
            });
            var orderFee = security.FeeModel.GetOrderFee(new OrderFeeParameters(
                                                             security, new LimitOrder(security.Symbol, 1, 5000.01m, DateTime.MinValue)
            {
                OrderSubmissionData = new OrderSubmissionData(security.BidPrice, security.AskPrice, security.Price)
            }));

            // marketable buy limit fill at 5000
            Assert.AreEqual(15m, orderFee.Value.Amount);
            Assert.AreEqual(Currencies.USD, orderFee.Value.Currency);

            security.SetMarketPrice(new Tick {
                Symbol = security.Symbol, BidPrice = 5000m, AskPrice = 5000.01m, TickType = TickType.Quote
            });
            orderFee = security.FeeModel.GetOrderFee(new OrderFeeParameters(
                                                         security, new LimitOrder(security.Symbol, 1, 5000.01m, DateTime.MinValue)
            {
                OrderSubmissionData = new OrderSubmissionData(security.BidPrice, security.AskPrice, security.Price)
            }));

            // marketable buy limit fill at 5000.01
            Assert.AreEqual(15.00003m, orderFee.Value.Amount);
            Assert.AreEqual(Currencies.USD, orderFee.Value.Currency);

            orderFee = security.FeeModel.GetOrderFee(new OrderFeeParameters(
                                                         security, new LimitOrder(security.Symbol, -1, 5000m, DateTime.MinValue)
            {
                OrderSubmissionData = new OrderSubmissionData(security.BidPrice, security.AskPrice, security.Price)
            }));

            // marketable sell limit fill at 5000
            Assert.AreEqual(15m, orderFee.Value.Amount);
            Assert.AreEqual(Currencies.USD, orderFee.Value.Currency);
        }
 public void GetBuyingPowerModelTest()
 {
     Assert.IsInstanceOf <CashBuyingPowerModel>(_gdaxBrokerageModel.GetBuyingPowerModel(TestsHelpers.GetSecurity()));
 }
 public void GetFeeModelTest()
 {
     Assert.IsInstanceOf <GDAXFeeModel>(_gdaxBrokerageModel.GetFeeModel(TestsHelpers.GetSecurity()));
 }
 public void GetLeverageTest()
 {
     Assert.AreEqual(1, _gdaxBrokerageModel.GetLeverage(TestsHelpers.GetSecurity()));
 }