public void ModifyOrder(string orderId, decimal?sl, decimal?tp, bool isServerSide, AccountInfo account) { //(optional) analyze/process provided order details before passing them to broker var original = Broker?.GetOrder(orderId, account); if (original == null) { return; } var processed = new OrderParams(original) { SLOffset = sl, TPOffset = tp }; processed = AnalyzePreTrade(processed); if (processed == null) { return; } if (State != SignalState.Backtesting) { Broker?.Modify(orderId, processed.SLOffset, processed.TPOffset, isServerSide, account); } }
public async Task <ResponseModel <PageResponse> > pendingOrders(string Token) { try { _client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token); OrderParams request = new OrderParams() { page = 1, type = -1, status = 4, persianToDate = "", persianFromDate = "", contractId = -1, orderbookId = 0, }; StringContent stringContent = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json"); var response = await _client.PostAsync(string.Format(_baseUrl, "api/orders"), stringContent); return(await ResponseHandler <PageResponse>(response)); } catch { return(new ResponseModel <PageResponse> { Status = ResponseStatus.NetworkError }); } }
public static OrderParams GetOrderParamsByID(int orderID) { using (var db = new GameStoreDBContext()) { var currentOrder = (from order in db.Order where order.ID == orderID select order).First(); var connections = (from connection in db.Orders_Games where connection.Order_ID == orderID select connection); var orderParams = new OrderParams(); orderParams.Date = currentOrder.Date; orderParams.ID = currentOrder.ID; orderParams.games = new List <GameParams>(); foreach (var connection in connections) { var currentGame = ExtractGameParams((from game in db.Game where game.ID == connection.Game_ID select game).First()); currentGame.Quantity = connection.Games_number; orderParams.games.Add(currentGame); } return(orderParams); } }
private OrderParams FillParams(OrderRegisterMessage regMsg, OrderParams orderParams) { if (regMsg == null) { throw new ArgumentNullException(nameof(regMsg)); } if (orderParams == null) { throw new ArgumentNullException(nameof(orderParams)); } orderParams.Symbol = regMsg.SecurityId.SecurityCode; orderParams.Exchange = regMsg.SecurityId.BoardCode; orderParams.Account = _accounts[regMsg.PortfolioName]; orderParams.BuySellType = regMsg.Side.ToRithmic(); orderParams.UserMsg = regMsg.Comment; orderParams.UserTag = regMsg.UserOrderId; orderParams.Qty = (int)regMsg.Volume; orderParams.Tag = regMsg.TransactionId.To <string>(); orderParams.Duration = regMsg.TimeInForce.ToRithmic(regMsg.ExpiryDate); orderParams.EntryType = Constants.ORDER_ENTRY_TYPE_AUTO; return(orderParams); }
public static List <OrderParams> GetOrdersParams(DateTime dateFrom, DateTime dateTo) { var orders = new List <OrderParams>(); var actualDateTo = dateTo.AddDays(1); Console.WriteLine(actualDateTo); using (var db = new GameStoreDBContext()) { var currentOrders = from order in db.Order where order.Date >= dateFrom && order.Date <= actualDateTo select order; foreach (var order in currentOrders) { var currentOrder = new OrderParams() { Date = order.Date, ID = order.ID, games = ExtractGamesFromOrder(order) }; orders.Add(currentOrder); } } return(orders); }
public async Task RemoveCartAsync(OrderParams orderParams) { if (Carts.Remove(orderParams)) { await UpdateCartAsync(); } }
public OrderToReport(OrderParams order) { ID = order.ID; Date = order.Date; Sum = (from game in order.games select game.Price).Sum(); Quantity = (from game in order.games select game).Count(); }
public async Task <IActionResult> Get([FromQuery] OrderParams orderParams) { var orders = await this._repo.GetOrdersAsync(orderParams); Response.AddPaginationHeader(orders.CurrentPage, orders.PageSize, orders.TotalCount, orders.TotalPages); return(Ok(orders.ToOrderViewModelList())); }
private async Task CheckoutPayPalAsync(OrderParams orderParams) { orderParams.PaymentMethod = PaymentContants.PayPal; var response = await HttpClient.PostAsJsonAsync("api/orders", orderParams); var order = await response.Content.ReadFromJsonAsync <OrderModel>(); NavigationManager.NavigateTo(order.PaymentUrl, true); await CartService.RemoveCartAsync(orderParams); }
public async Task <IActionResult> GetOrders([FromQuery] OrderParams orderParams) { var orders = await _repo.GetOrders(orderParams); var ordersToReturn = _mapper.Map <IEnumerable <OrdersForListDto> >(orders); Response.AddPagination(orders.CurrentPage, orders.PageSize, orders.TotalCount, orders.TotalPages); return(Ok(ordersToReturn)); }
public static OrderModel FromParams(OrderParams orderParams) { return(new OrderModel() { BuyerId = orderParams.BuyerId, SellerId = orderParams.SellerId, PaymentMethod = orderParams.PaymentMethod, Items = new List <OrderItemModel>() }); }
public Order PlaceOrder(OrderParams orderParamsModel) { Dictionary <string, object> parameters = new Dictionary <string, object>(); foreach (var prop in orderParamsModel.GetType().GetProperties()) { parameters.Add(prop.Name, prop.GetValue(orderParamsModel)); } return(_dataLayer.GetItem <Order>("sp_OnlineShop_PlaceOrder", parameters)); }
public async Task RemoveFromCartAsync(OrderParams orderParams, OrderItemParams item) { orderParams.Items.Remove(item); if (orderParams.Items.Count == 0) { Carts.Remove(orderParams); } await UpdateCartAsync(); }
public async Task <PagedList <Order> > GetAllOrdersByUser(OrderParams orderParams) { var orders = oContext.Orders .Include(p => p.OrderDetails) .Where(p => p.UserId == orderParams.UserId) .OrderByDescending(p => p.OrderDate) .AsQueryable(); return(await PagedList <Order> .CreateAsync(orders, orderParams.PageNumber, orderParams.PageSize)); }
public int PostOrder([FromBody] OrderParams orderParams) { string cartId = orderParams.cartId; string userName = orderParams.userName; int orderId = _cartRepository.CreateOrder(cartId, userName); _cartRepository.MigrateCart(cartId, userName); _cartRepository.EmptyCart(cartId); return(orderId); }
/// <summary> /// replace/withdraw the target order /// </summary> /// <param name="targetClOrdID">target order clOrdID</param> /// <param name="newQty">new order qty, 0 means withdraw the target order</param> /// <param name="newLimitPrice"></param> /// <param name="newStopPrice"></param> /// <returns>ansyc task result for this request</returns> public Task <Tuple <Request, Response> > replaceOrWithdrawOrder(ulong targetClOrdID, uint newQty, ulong newLimitPrice, ulong newStopPrice) { OrderParams orderParams = new OrderParams(); orderParams.OrigClOrdID = targetClOrdID; orderParams.OrderQty = newQty; orderParams.LimitPrice = newLimitPrice; orderParams.StopPrice = newStopPrice; return(submitOrder(orderParams)); }
public async Task <ActionResult <int> > ApproveSelectedOrders([FromBody] OrderParams orderUpdParams) { var ordersUpdatedCount = await _orderService.UpdateOrdersStatusForApproveRejectAsync(orderUpdParams.OrderIds, OrderStatus.Approved, orderUpdParams.OrderSpecParams); if (ordersUpdatedCount <= 0) { return(BadRequest(new ApiResponse(500, "Problem approving orders"))); } return(Ok(ordersUpdatedCount)); }
public Order PlaceOrder(OrderParams orderParamsModel) { try { return(_salesRepository.PlaceOrder(orderParamsModel)); } catch (Exception) { throw; } }
public async Task RemoveCartAsync(OrderParams orderParams) { if (Carts == null) { await ReloadCartAsync(); } if (Carts.Remove(orderParams)) { await SaveCartAsync(); } }
public async Task <MOrder> CreateOrderAsync(OrderParams orderParams) { MOrder order = MOrder.FromParams(orderParams); order.Seller = await usersRepository.GetUserAsync <Seller>(order.SellerId); order.Status = OrderConstants.Status.Pending; order.Currency = "USD"; order.PaymentMethod = orderParams.PaymentMethod; order.PaymentReceiver = order.GetReceiver(order.PaymentMethod); foreach (var itemParams in orderParams.Items) { MOrderItem item = MOrderItem.FromParams(itemParams); item.Product = await productsRepository.GetProductAsync(item.ProductId, order.BuyerId); if (item.Product == null) { return(null); } if (order.SellerId != item.Product.SellerId) { return(null); } if (item.Product.Customer != null) { return(null); } item.ProductName = item.Product.Name; item.Price = item.Product.Price; order.TotalPrice += item.Price; order.Items.Add(item); } Payment payment = Payment.Create(order.PaymentMethod, string.Empty, order.GetReceiver(order.PaymentMethod), order.Currency, order.TotalPrice); foreach (MOrderItem item in order.Items) { payment.AddItem(item.ProductName, 1, item.Price); } order.PaymentId = await PaymentGatewayClient.CreatePaymentAsync(payment); return(await ordersRepository.AddOrderAsync(order)); }
public async Task <IActionResult> PostOrderAsync([FromBody] OrderParams orderParams) { orderParams.BaseUrl = Request.Headers["Origin"]; orderParams.BuyerId = int.Parse(User.Identity.Name); var order = await orderService.CreateOrderAsync(orderParams); if (order == null) { return(BadRequest()); } return(Ok(order)); }
public async Task <PagedList <Orders> > GetOrders(OrderParams orderParams) { var orders = _context.Orders.FromSqlRaw($"SELECT * FROM getOrders()").Include(e => e.Employee).AsQueryable(); // var orders = _context.Orders.Include(e => e.Employee).AsQueryable(); if (!orderParams.EmployeeId.Equals(0)) { orders = orders.Where(o => o.EmployeeId == orderParams.EmployeeId); } return(await PagedList <Orders> .CreateAsync(orders, orderParams.PageNumber, orderParams.PageSize)); }
public async Task <OrderModel> CreateOrderAsync(OrderParams orderParams) { if (orderParams.PaymentMethod == PaymentContants.PayPal) { var order = OrderModel.FromParams(orderParams); order.Seller = await usersRepository.GetUserPrivateAsync(order.SellerId); order.PaymentReceiver = order.Seller.PayPalEmail; order.Currency = order.Seller.PayPalCurrency; order.Status = PaymentContants.PendingStatus; foreach (var itemParams in orderParams.Items) { var item = OrderItemModel.FromParams(itemParams); item.Product = await productsRepository.GetProductAsync(item.ProductId, order.BuyerId); if (item.Product == null) { return(null); } if (order.SellerId != item.Product.SellerId) { return(null); } if (item.Product.Customer != null) { return(null); } item.ProductName = item.Product.Name; item.Price = item.Product.Price; order.TotalPrice += item.Price; order.Items.Add(item); } order = await ordersRepository.AddOrderAsync(order); payPalService.PayPalPayment(order, orderParams.BaseUrl); await ordersRepository.UpdateOrderPaymentUrlAsync(order); return(order); } return(null); }
/// <summary> /// /// </summary> /// <param name="args"></param> protected void OnPositionClosed(PositionClosedEventArgs args) { Position position = args.Position; // Manage a selective Martingale. if (Martingale) { OrderParams op = this.martingale(position); op.Slippage = initialOP.Slippage; this.splitAndExecuteOrder(op); } Print(position.log(this, false)); }
/// <summary> /// /// </summary> protected override void OnStart() { base.OnStart(); double slippage = 2; // maximum slippage in point, if order execution imposes a higher slippage, the order is not executed. _botName = ToString(); _instanceLabel = string.Format("{0}-{1}-{2}-{3}", _botName, _botVersion, Symbol.Code, TimeFrame.ToString()); string positionComment = string.Format("{0}-v{1}", _botName, _botVersion); // order label passed by the bot initialOP = new OrderParams(null, Symbol, InitialVolume, _instanceLabel, StopLoss, TakeProfit, slippage, positionComment, null, new List <double> { 5, 3, 2 }); Positions.Closed += OnPositionClosed; strategies = new List <Strategy>(); if (IsZZKwanActif) { strategies.Add(new ZigZagKwanStrategy(this, MbfxLen, MbfxFilter)); } if (IsWPRActif) { strategies.Add(new WPRSStrategy(this, WprSource, WprPeriod, WprOverbuyCeil, WprOversellCeil, WprMagicNumber, WprMinMaxPeriod, WprExceedMinMax)); } if (IsDCActif) { strategies.Add(new DoubleCandleStrategy(this, DoubleCandleFineness)); } if (IsZZActif) { strategies.Add(new ZigZagStrategy(this, ZzDepth, ZzDeviation, ZzBackStep)); } if (IsTMActif) { strategies.Add(new TrendMagicStrategy(this, TMCciPeriod, TMAtrPeriod)); } }
public Models.OrderResponse PlaceOrder(Models.OrderParams orderParams) { if (_salesService.ValidateCartKey(orderParams.CartKey)) { Models.OrderResponse orderResponse = new Models.OrderResponse(); orderResponse.CartKey = orderParams.CartKey; OrderParams orderParamsModel = Mapper.Map <Models.OrderParams, OrderParams>(orderParams); orderResponse.Order = Mapper.Map <Order, Models.Order>(_salesService.PlaceOrder(orderParamsModel)); return(orderResponse); } else { throw new ApplicationException($"Shopping cart with key: {orderParams.CartKey} is not valid any more."); } }
public async Task RemoveFromCartAsync(OrderParams orderParams, OrderItemParams item) { if (Carts == null) { await ReloadCartAsync(); } orderParams.Items.Remove(item); if (orderParams.Items.Count == 0) { Carts.Remove(orderParams); } await SaveCartAsync(); }
/// <summary> /// submit the order /// </summary> /// <param name="orderParams"></param> /// <returns>ansyc task result for this request</returns> public Task <Tuple <Request, Response> > submitOrder(OrderParams orderParams) { Request request = createRequestMsg(); Order order = new Order(); order.Account = AccountInfo.AccountID; order.EnterBy = AccountInfo.AccountID; order.SubmitUTC = toEpochMilliseconds(DateTime.Now); request.Order = order; order.Params = orderParams; return(send(request)); }
protected override async Task OnParametersSetAsync() { OrderParams = CartService.GetOrderParams(SellerId); if (OrderParams != null) { PaymentMethods = await HttpClient.GetFromJsonAsync <string[]>($"api/payments/{SellerId}"); if (string.IsNullOrEmpty(OrderParams.PaymentMethod)) { await ChangePaymentMethod(PaymentMethods.FirstOrDefault()); } } isLoaded = true; }
public async Task <IActionResult> GetAllOrdersByUser([FromQuery] OrderParams orderParams) { var ordersFromRepo = await _unitOfWork.Orders.GetAllOrdersByUser(orderParams); if (ordersFromRepo == null) { return(NotFound()); } Response.AddPagination( ordersFromRepo.CurrentPage, ordersFromRepo.PageSize, ordersFromRepo.TotalCount, ordersFromRepo.TotalPages); return(Ok(ordersFromRepo)); }
private OrderParams FillParams(OrderRegisterMessage regMsg, OrderParams orderParams) { if (regMsg == null) throw new ArgumentNullException(nameof(regMsg)); if (orderParams == null) throw new ArgumentNullException(nameof(orderParams)); orderParams.Symbol = regMsg.SecurityId.SecurityCode; orderParams.Exchange = regMsg.SecurityId.BoardCode; orderParams.Account = _accounts[regMsg.PortfolioName]; orderParams.BuySellType = regMsg.Side.ToRithmic(); orderParams.UserMsg = regMsg.Comment; orderParams.UserTag = regMsg.UserOrderId; orderParams.Qty = (int)regMsg.Volume; orderParams.Tag = regMsg.TransactionId.To<string>(); orderParams.Duration = regMsg.TimeInForce.ToRithmic(regMsg.ExpiryDate); orderParams.EntryType = Constants.ORDER_ENTRY_TYPE_AUTO; return orderParams; }