コード例 #1
0
        public AddNewOrderViewModel(OrderId orderId, string userEmail)
        {
            Argument.ExpectNotNull(() => orderId);

            OrderId = orderId;
            Email = userEmail;
            OriginalEmail = userEmail;
        }
コード例 #2
0
        public ActionResult Details(OrderId id)
        {
            Argument.ExpectNotNull(() => id);

            UserOrderDetails userOrder = _readModel.GetOrderDetails(UserId, id);
            IEnumerable<OrderItemDetails> orderItems = _readModel.GetOrderItems(id);

            return View(new OrderDetailsViewModel(userOrder, orderItems));
        }
コード例 #3
0
 public MyOrder(OrderId orderId, OrderType orderType,
     DateTime created, decimal price, decimal quantity, decimal originalQuantity,
     MarketId marketId)
     : base(orderType, price, quantity)
 {
     this.OrderId = orderId;
     this.Created = created;
     this.OriginalQuantity = originalQuantity;
     this.MarketId = marketId;
 }
コード例 #4
0
 public MyTrade(TradeId tradeId, OrderType tradeType,
     DateTime dateTime, decimal price, decimal? fee,
     decimal quantity,
     MarketId marketId, OrderId orderId)
     : base(tradeId, dateTime, price, quantity, marketId)
 {
     this.Fee = fee;
     this.OrderId = orderId;
     this.TradeType = tradeType;
 }
コード例 #5
0
        public ActionResult Add()
        {
            OrderId activeOrderId = _readModel.GetUserActiveOrderId(UserId);
            UserDetails userDetails = _readModel.GetUserDetails(UserId);

            if (activeOrderId == null)
            {
                activeOrderId = new OrderId(ServiceLocator.IdentityGenerator.GenerateNewId());
                _bus.Send(new CreateNewOrder(activeOrderId, UserId));
            }

            var model = new AddNewOrderViewModel(activeOrderId, userDetails.Email);

            return View(model);
        }
コード例 #6
0
 public void ShouldNotBe(OrderLine other, bool sameIds)
 {
     if (sameIds)
     {
         Id.ShouldBe(other.Id);
         OrderId.ShouldBe(other.OrderId);
     }
     else
     {
         Id.ShouldNotBe(other.Id);
         OrderId.ShouldNotBe(other.OrderId);
     }
     Quantity.ShouldNotBe(other.Quantity);
     SellPrice.ShouldNotBe(other.SellPrice);
 }
コード例 #7
0
ファイル: Order.cs プロジェクト: vslee/ExchangeSharp
            public ExchangeOrderResult ToExchangeOrderResult(Dictionary <string, long> symbolToIdMapping)
            {
                ExchangeAPIOrderResult orderResult;

                switch (OrderState.ToLowerInvariant())
                {
                case "unknown":
                    orderResult = ExchangeAPIOrderResult.Unknown;
                    break;

                case "working":
                    orderResult = ExchangeAPIOrderResult.Open;
                    break;

                case "rejected":
                    orderResult = ExchangeAPIOrderResult.Rejected;
                    break;

                case "canceled":
                    orderResult = ExchangeAPIOrderResult.Canceled;
                    break;

                case "expired":
                    orderResult = ExchangeAPIOrderResult.Canceled;
                    break;

                case "fullyexecuted":
                    orderResult = ExchangeAPIOrderResult.Filled;
                    break;

                default:
                    throw new NotImplementedException($"Unexpected status type: {OrderState.ToLowerInvariant()}");
                }
                ;
                var symbol = symbolToIdMapping.Where(pair => pair.Value.Equals(Instrument));

                return(new ExchangeOrderResult()
                {
                    Amount = Quantity,
                    IsBuy = Side.Equals("buy", StringComparison.InvariantCultureIgnoreCase),
                    MarketSymbol = symbol.Any() ? symbol.First().Key : null,
                    Price = Price,
                    Result = orderResult,
                    OrderDate = ReceiveTime.UnixTimeStampToDateTimeMilliseconds(),

                    OrderId = OrderId.ToStringInvariant(),
                });
            }
コード例 #8
0
        public async Task <Order> Update(OrderId orderId, OrderUpdate order)
        {
            if (orderId == null)
            {
                throw new ArgumentNullException(nameof(orderId));
            }

            if (order == null)
            {
                throw new ArgumentNullException(nameof(order));
            }

            var updated = await this._ordersRepository.Update(orderId, order);

            return(updated);
        }
コード例 #9
0
        public async Task <IActionResult> Get([FromRoute] Guid orderId)
        {
            var orderIdValue  = OrderId.With(orderId).Value;
            var domainResults = await _processor.ProcessAsync(new GetOrderLinesByOrderIdQuery(orderIdValue), new CancellationToken());

            var results = domainResults.Select(x => new OrderLineRead
            {
                Id        = OrderLineId.With(x.Id).GetGuid(),
                ProductId = ProductId.With(x.ProductId).GetGuid(),
                Title     = x.Title,
                Price     = x.Price,
                Amount    = x.Amount
            }).ToList();

            return(Ok(results));
        }
コード例 #10
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ExpiredBlockIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)Type;
         hashCode = (hashCode * 397) ^ SellerAgentAddress.GetHashCode();
         hashCode = (hashCode * 397) ^ SellerAvatarAddress.GetHashCode();
         hashCode = (hashCode * 397) ^ OrderId.GetHashCode();
         hashCode = (hashCode * 397) ^ Price.GetHashCode();
         hashCode = (hashCode * 397) ^ TradableId.GetHashCode();
         hashCode = (hashCode * 397) ^ StartedBlockIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)ItemSubType;
         return(hashCode);
     }
 }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OrderDenied"/> class.
        /// </summary>
        /// <param name="orderId">The event order identifier.</param>
        /// <param name="deniedReason">The event denied reason.</param>
        /// <param name="eventId">The event identifier.</param>
        /// <param name="eventTimestamp">The event timestamp.</param>
        public OrderDenied(
            OrderId orderId,
            string deniedReason,
            Guid eventId,
            ZonedDateTime eventTimestamp)
            : base(
                orderId,
                EventType,
                eventId,
                eventTimestamp)
        {
            Debug.NotDefault(eventId, nameof(eventId));
            Debug.NotDefault(eventTimestamp, nameof(eventTimestamp));

            this.DeniedReason = deniedReason;
        }
コード例 #12
0
ファイル: PaperWaybill.cs プロジェクト: amburin/Test-Tasks
 public PaperWaybill(
     WaybillId id,
     CephFileId sourceFileId,
     OrderId orderId,
     WaybillContent content,
     WaybillContentStructuralValidationResult structuralValidationResult,
     WaybillInteractionState interactionState)
     : base(
         id,
         orderId,
         content)
 {
     SourceFileId = sourceFileId;
     StructuralValidationResult = structuralValidationResult;
     InteractionState           = interactionState;
 }
コード例 #13
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is CalculateLoyaltyPointsRequest other &&
                   ((OrderId == null && other.OrderId == null) || (OrderId?.Equals(other.OrderId) == true)) &&
                   ((TransactionAmountMoney == null && other.TransactionAmountMoney == null) || (TransactionAmountMoney?.Equals(other.TransactionAmountMoney) == true)));
        }
コード例 #14
0
        public override int GetHashCode()
        {
            int hashCode = -1468286611;

            if (OrderId != null)
            {
                hashCode += OrderId.GetHashCode();
            }

            if (TransactionAmountMoney != null)
            {
                hashCode += TransactionAmountMoney.GetHashCode();
            }

            return(hashCode);
        }
コード例 #15
0
        public override async Task <Order> GetOrder(OrderId orderId, ServerCallContext context)
        {
            var order = await _shopContext
                        .Orders
                        .Include(x => x.Items)
                        .ThenInclude(x => x.Product)
                        .Where(x => x.Id == orderId.Id)
                        .FirstOrDefaultAsync();

            if (order == null)
            {
                throw new RpcException(new Status(StatusCode.NotFound, $"No order found with Id {orderId.Id}"));
            }

            return(order.ToProto());
        }
コード例 #16
0
        public void CreateReturnsNewOrder()
        {
            var john    = new UserId("john");
            var cartId  = new ShoppingCartId(Guid.NewGuid().ToString());
            var orderId = new OrderId(Guid.NewGuid().ToString());

            var orderIdGenMock = new Mock <IOrderIdGenerator>();
            var basketRepoMock = new Mock <IBasketRepository>();

            orderIdGenMock.Setup(gen => gen.Next()).Returns(orderId);

            var sut    = new OrderService(orderIdGenMock.Object, basketRepoMock.Object);
            var actual = sut.Create(john, cartId);

            Assert.Equal(orderId, actual.Id);
        }
コード例 #17
0
 public bool Equals(OrderItem other)
 {
     if (!OrderId.Equals(other.OrderId))
     {
         return(false);
     }
     if (!ProductId.Equals(other.ProductId))
     {
         return(false);
     }
     if (!Count.Equals(other.Count))
     {
         return(false);
     }
     return(true);
 }
コード例 #18
0
        public Task <OrderDetails?> OrderDetailsWithId(OrderId id, CancellationToken token = default)
        {
            Order?order;

            lock (syncLock)
            {
                order = orders.GetValueOrDefault(id);
            }

            if (order == null)
            {
                return(Task.FromResult <OrderDetails?>(null));
            }

            return(Task.FromResult <OrderDetails?>(ToOrderDetails(order)));
        }
コード例 #19
0
        public void PerformanceTestForOrderFill()
        {
            IList <CurrencyPair> currencyPairs = new List <CurrencyPair>();

            currencyPairs.Add(new CurrencyPair("BTCLTC", "LTC", "BTC"));

            _exchange = new Exchange(currencyPairs);
            List <OrderId> orderIds = new List <OrderId>();

            // Create Orders
            Order[] sellOrders = new Order[_orderCount];
            Random  random     = new Random();

            var startOrderObjectCreation = DateTime.Now;

            for (int i = 0; i < sellOrders.Length; i++)
            {
                decimal delta = 1884;
                Price   price = new Price(1 + delta);

                Volume  volume  = new Volume(1);
                OrderId orderId = new OrderId((i + 1).ToString());
                orderIds.Add(orderId);
                sellOrders[i] = new Order(orderId, "BTCLTC", price, OrderSide.Sell, OrderType.Limit, volume, new TraderId(random.Next(1, 100).ToString()));
            }

            Order[] buyOrders = new Order[_orderCount];

            for (int i = 0; i < buyOrders.Length; i++)
            {
                Price   price   = new Price(0);
                Volume  volume  = new Volume(1);
                OrderId orderId = new OrderId((i + 1 + _orderCount).ToString());
                orderIds.Add(orderId);
                buyOrders[i] = new Order(orderId, "BTCLTC", price, OrderSide.Buy, OrderType.Market, volume, new TraderId(random.Next(1, 100).ToString()));
            }

            var endOrderObjectCreation = DateTime.Now;

            Console.WriteLine("Order Objects created SELL: {0} BUY: {0}| Time elapsed: {1} seconds", _orderCount, (startOrderObjectCreation - endOrderObjectCreation).TotalSeconds);

            // Add SELL side orders to Order Book
            AddOrders(_exchange.ExchangeEssentials.First().LimitOrderBook, sellOrders);

            // Add BUY side orders for Trade Execution
            AddOrders(_exchange.ExchangeEssentials.First().LimitOrderBook, buyOrders);
        }
コード例 #20
0
            public void ShouldProvideSameResultAsBaseIdsDoForObject()
            {
                // arrange
                var stronglyTypedId        = new OrderId(Guid.NewGuid());
                var anotherStronglyTypedId = new OrderId(Guid.NewGuid());

                // act
                var result1 = stronglyTypedId.CompareTo((object)anotherStronglyTypedId);
                var result2 = anotherStronglyTypedId.CompareTo((object)stronglyTypedId);

                var baseResult1 = stronglyTypedId.Value.CompareTo(anotherStronglyTypedId.Value);
                var baseResult2 = anotherStronglyTypedId.Value.CompareTo(stronglyTypedId.Value);

                // assert
                result1.Should().Be(baseResult1);
                result2.Should().Be(baseResult2);
            }
コード例 #21
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (OrderId != null)
         {
             hashCode = hashCode * 59 + OrderId.GetHashCode();
         }
         if (InitialMargin != null)
         {
             hashCode = hashCode * 59 + InitialMargin.GetHashCode();
         }
         return(hashCode);
     }
 }
コード例 #22
0
        /// <summary>
        /// Cancel an order.
        /// </summary>
        /// <param name="orderId">Order identifier to cancel.</param>
        public async Task CancelOrder(OrderId orderId)
        {
            var builder = new UriBuilder(BaseUri + "/rest/order/cancelById");
            var query   = HttpUtility.ParseQueryString(builder.Query);

            query["clOrdId"]     = orderId.ClientOrderId;
            query["proprietary"] = orderId.Proprietary;
            builder.Query        = query.ToString();

            var jsonResponse = await HttpClient.GetStringAsync(builder.Uri);

            var response = JsonConvert.DeserializeObject <OrderIdResponse>(jsonResponse);
            //if (response.Status == Status.Error)
            //{
            //    throw new Exception($"{response.Message} ({response.Description})");
            //}
        }
コード例 #23
0
        public void PerformanceTest()
        {
            // Initialize the output Disruptor and assign the journaler as the event handler

            /*// NOTE: Passing in NULL as RavenDB event store is no longer operational
             * //IEventStore eventStore = new RavenNEventStore(Constants.OUTPUT_EVENT_STORE);
             * Journaler journaler = new Journaler(null);
             *
             * OutputDisruptor.InitializeDisruptor(new IEventHandler<byte[]>[] { journaler });*/
            IList <CurrencyPair> currencyPairs = new List <CurrencyPair>();

            currencyPairs.Add(new CurrencyPair("BTCLTC", "LTC", "BTC"));
            currencyPairs.Add(new CurrencyPair("BTCUSD", "USD", "BTC"));
            currencyPairs.Add(new CurrencyPair("BTCDOGE", "DOGE", "BTC"));

            _exchange = new Exchange(currencyPairs);
            List <OrderId> orderIds = new List <OrderId>();

            // Create Orders
            Order[] orders = new Order[_orderCount];
            Random  random = new Random();

            var startOrderObjectCreation = DateTime.Now;

            for (int i = 0; i < orders.Length; i++)
            {
                bool    isBuy = ((i % 2) == 0);
                decimal delta = isBuy ? 1880 : 1884;

                Price price = new Price(random.Next(1, 10) + delta);
                //Volume volume = new Volume(random.Next() % 10 + 1 * 100);
                Volume volume = new Volume(1);

                OrderId orderId = new OrderId(random.Next(1, 100).ToString(CultureInfo.InvariantCulture));
                orderIds.Add(orderId);
                orders[i] = new Order(orderId, "BTCLTC", price, isBuy ? OrderSide.Buy :
                                      OrderSide.Sell, OrderType.Limit, volume, new TraderId(random.Next(1, 100).ToString()));
            }

            var endOrderObjectCreation = DateTime.Now;

            Console.WriteLine("Order Objects created : {0} | Time elapsed: {1} seconds", _orderCount, (endOrderObjectCreation - startOrderObjectCreation).TotalSeconds);

            //JustAddOrdersToList(orders);
            AddOrdersAndCancel(_exchange.ExchangeEssentials.First().LimitOrderBook, orders, orderIds);
        }
コード例 #24
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = StartedBlockIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ ExpiredBlockIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ OrderId.GetHashCode();
         hashCode = (hashCode * 397) ^ TradableId.GetHashCode();
         hashCode = (hashCode * 397) ^ Price.GetHashCode();
         hashCode = (hashCode * 397) ^ CombatPoint;
         hashCode = (hashCode * 397) ^ Level;
         hashCode = (hashCode * 397) ^ ItemId;
         hashCode = (hashCode * 397) ^ SellerAgentAddress.GetHashCode();
         hashCode = (hashCode * 397) ^ ItemCount;
         return(hashCode);
     }
 }
コード例 #25
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is OrderEntry other &&
                   ((OrderId == null && other.OrderId == null) || (OrderId?.Equals(other.OrderId) == true)) &&
                   ((Version == null && other.Version == null) || (Version?.Equals(other.Version) == true)) &&
                   ((LocationId == null && other.LocationId == null) || (LocationId?.Equals(other.LocationId) == true)));
        }
コード例 #26
0
        /// <summary>
        /// Updates the specified Order in the list
        /// </summary>
        /// <returns></returns>
        internal bool Update(OrderId orderId, string currencyPair, Volume volume, Price price)
        {
            if (_currencyPair == currencyPair)
            {
                Order selectedOrder = FindOrder(orderId);

                if (selectedOrder != null)
                {
                    selectedOrder.Volume = volume;
                    selectedOrder.Price  = price;
                    return(true);
                }
            }
            Log.Error("Order with OrderId = " + orderId + " not found in " + _currencyPair + " " + _orderSide.ToString() +
                      " list.");
            return(false);
        }
コード例 #27
0
        public async Task <ActionResult> Add(long goodzonOrderId, IFormFileCollection files)
        {
            files = GetCollectionFromArgumentOrRequest(files);

            if (!files.Any())
            {
                throw new BusinessException("No files uploaded");
            }

            var orderId    = new OrderId(goodzonOrderId);
            var excelFiles = CreateExcelFiles(files);

            await TransactionRunner.RunWithTransactionAsync(
                () => _waybillImporter.ImportFromFiles(orderId, excelFiles));

            return(new OkResult());
        }
コード例 #28
0
ファイル: WaybillProvider.cs プロジェクト: amburin/Test-Tasks
        public async Task <IReadOnlyList <GetWaybillsResult> > Get(OrderId orderId)
        {
            var documents = await _context.Waybills
                            .Where(x => x.OrderId == orderId.Value)
                            .Include(x => x.Content)
                            .ThenInclude(x => x.Items)
                            .Include(x => x.File)
                            .Include(x => x.ValidationResult)
                            .ThenInclude(x => x.ItemValidationResults)
                            .OrderByDescending(x => x.File.UploadTime)
                            .ToArrayAsync();

            return(documents
                   .Select(x => new { Waybill = x, x.File.UploadTime, x.File.Name })
                   .Select(x => GetWaybillsResult(x.Waybill, x.Name, x.UploadTime))
                   .ToArray());
        }
コード例 #29
0
        public static void Serialize(OrderId orderId, int timestamp, Span <byte> bytes)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }

            if (bytes.Length < sizeOfMessage)
            {
                throw new ArgumentException(Constant.INVALID_SIZE, nameof(bytes));
            }

            Write(bytes.Slice(messageLengthOffset), sizeOfMessage);
            bytes[messageTypeOffset] = (byte)MessageType.OrderAccept;
            Write(bytes.Slice(versionOffset), (long)version);
            Write(bytes.Slice(orderIdOffset), orderId);
            Write(bytes.Slice(timestampOffset), timestamp);
        }
コード例 #30
0
        public async Task <IActionResult> GetOrder([FromRoute] OrderIdQuery query)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var orderId = new OrderId(query.OrderId);

            var result = await this._ordersManagementService.Get(orderId);

            if (result == null)
            {
                return(NoContent());
            }

            return(Ok(result));
        }
コード例 #31
0
        public void SendOrderConfirmation()
        {
            var basket = new Basket(ryan,
                                    DateTime.Parse("2020-12-01"),
                                    this.inventory);
            var orderId = new OrderId(Guid.NewGuid().ToString());
            var order   = new Order(orderId, basket);

            orderSvcMock.Setup(svc => svc.Create(ryan, cartId)).Returns(order);
            var paymentRef = new PaymentReference();

            this.paymentGatewayMock.Setup(svc => svc.Pay(order, ryan, payment))
            .Returns(paymentRef);

            this.sut.MakePayment(ryan, cartId, payment);
            this.orderConfirmationStub
            .Verify(oc => oc.Send(ryan, orderId, paymentRef));
        }
コード例 #32
0
        public void RemoveOrder(OrderId id)
        {
            string errorMessage;

            Market.Model.Trade.Cancel(Market, id, out errorMessage);

            if (string.IsNullOrEmpty(errorMessage))
            {
                _balanceUpdater.UpdateNowAsync();
                _openedOrdersUpdater.UpdateNowAsync();

                OnInfoMessage(InfoMessages.SuccessfullCancelLimitOrder);
            }
            else
            {
                OnErrorOccured(errorMessage);
            }
        }
コード例 #33
0
        public async Task Delete(OrderId orderId)
        {
            if (orderId == null)
            {
                throw new ArgumentNullException(nameof(orderId));
            }

            var order = await GetOrder(orderId);

            if (order == null)
            {
                throw new OrderDoesNotExistException(orderId.Value);
            }

            this._dbContext.Orders.Remove(order);

            await this._dbContext.SaveChangesAsync();
        }
コード例 #34
0
        private void Button_Buy(object sender, RoutedEventArgs e)
        {
            if (this.login == null)
            {
                return;
            }

            string tag = Guid.NewGuid().ToString().Replace("-", string.Empty);

            if (tag.Length > 8)
            {
                tag = tag.Substring(0, 8);
            }

            string payload = Payload.PlaceOrder("NSE", "RELIANCE", "BUY", "LIMIT", "MIS", 1, 1225.0d, 0.0d);

            this.orderId = Kite.Post <OrderId>(apiKey, login.access_token, KiteConnectAPI.Url.PlaceOrder(), payload, logger: this);
        }
コード例 #35
0
        public async Task SearchIssuesByOrderId_Returns_Paginated_List_Jira_Issue_When_Executed_Successfully()
        {
            var issueRecord = JiraIssuesSeed.Records.Value.FirstOrDefault();

            Assert.NotNull(issueRecord);

            var client = new HttpClient(new JiraSearchIssuesHandler())
            {
                BaseAddress = Settings.RestApiUri
            };
            var service = new JiraSearchIssuesService(client);
            var orderId = OrderId.FromString(issueRecord.OrderId);

            var result = await service.SearchIssuesByOrderId(orderId);

            Assert.NotNull(result);
            Assert.True(result.Items.Count == issueRecord.Issues.Count);
        }
コード例 #36
0
 /// <summary>
 /// Improvise a trade ID based on order ID
 /// </summary>
 /// <param name="setValue"></param>
 public CoinsETradeId(OrderId setValue)
     : base(setValue.ToString())
 {
 }
コード例 #37
0
 public ActionResult Submitted(OrderId id)
 {
     return View();
 }
コード例 #38
0
 public VoSMyOrder(OrderId orderId, OrderType orderType,
     DateTime created, decimal price, decimal quantity, decimal originalQuantity,
     MarketId marketId)
     : base(orderId, orderType, created, price, quantity, originalQuantity, marketId)
 {
 }
コード例 #39
0
        public ActionResult Details(OrderId id)
        {
            Argument.ExpectNotNull(() => id);

            UserOrderDetails userOrder = ThrowNotFoundIfNull(_orderDetailsView.GetOrderDetails(UserId, id), "Order {0} not found for user {1}", id.Id, UserId.Id);

            IEnumerable<OrderItemDetails> orderItems = _orderItemsView.GetOrderItems(id);

            return View(new OrderDetailsViewModel(userOrder, orderItems));
        }