public override void BuySellStock(Quote ltp) { bool shouldPlaceOrder = false; OrderMode orderMode = OrderMode.BUY; var lastPrice = ltp.LastPrice; if (lastPrice <= StockActionPrice[OrderMode.BUY]) { //Place Buy Order shouldPlaceOrder = true; orderMode = OrderMode.BUY; } else if (lastPrice >= StockActionPrice[OrderMode.SELL]) { //Place Sell Order shouldPlaceOrder = true; orderMode = OrderMode.SELL; } if (shouldPlaceOrder) { var price = lastPrice.GetNextValidPrice(orderMode == OrderMode.BUY ? false : true); this.PlaceOrder(orderMode.ToString(), StocksBuySellQuantityStart, price); CurrentPrice = lastPrice; SaveData(orderMode, StocksBuySellQuantityStart, price); } }
public override void BuySellStock(Quote ltp) { bool shouldPlaceOrder = false; OrderMode orderMode = OrderMode.BUY; var lastPrice = ltp.LastPrice; if (lastPrice <= StockActionPrice[OrderMode.BUY]) { //Place Buy Order shouldPlaceOrder = true; orderMode = OrderMode.BUY; } else if (lastPrice >= StockActionPrice[OrderMode.SELL]) { //Place Sell Order shouldPlaceOrder = true; orderMode = OrderMode.SELL; } if (shouldPlaceOrder) { int quantity = (OpenPositionsCount != 0 && LastOrderMode != orderMode) ? StocksCountToBuyOrCell() : StocksBuySellQuantityStart; var price = lastPrice.GetNextValidPrice(orderMode == OrderMode.BUY ? false : true); this.PlaceOrder(orderMode.ToString(), quantity, price); CurrentPrice = lastPrice; OpenPositionsCount = (OpenPositionsCount != 0 && LastOrderMode != orderMode) ? (OpenPositionsCount - quantity) : (OpenPositionsCount + quantity); SaveData(orderMode, quantity, price); } LastOrderMode = orderMode; }
// GET: ChatList public ActionResult Index(int page = 0, int limit = 10, string sort = "Id", OrderMode order = OrderMode.Asc, int school = 0, int type = 0, int way = 0, string description = "") { if (Request.IsAjaxRequest()) { var querylist = PredicateBuilder.True <CommunicationRecord>(); if (type != 0) { querylist = querylist.And(m => m.ConsultingTypeId == type); } if (way != 0) { querylist = querylist.And(m => m.ConsultingWayId == way); } if (!string.IsNullOrEmpty(description)) { querylist = querylist.And(m => m.StudentName.Contains(description)); } int offset = (page - 1) * limit; var query = work.CommunicationRecord.GetPageEntitys(querylist, limit, offset, sort, order); var list = from s in query select new { s.ChatWay, s.CommunicationContent, s.IntentionDegree.Leavl, s.ConType, s.Shcool.Name, s.Id, stuName = s.Student.Name, s.CommunicationDate }; return(Json(new { code = 0, count = work.CommunicationRecord.GetCount(), data = list }, JsonRequestBehavior.AllowGet)); } ViewBag.Shcool = work.School.Where(m => 1 == 1).ToList(); ViewBag.Type = work.ConsultingType.Where(PredicateBuilder.True <ConsultingType>()); ViewBag.Way = work.ConsultingWay.Where(m => 1 == 1); return(View()); }
public Euler(float x, float y, float z, OrderMode order = DefaultOrder) { this.x = x; this.y = y; this.z = z; this.order = order; }
private void PlaceOrder(OrderMode orderMode, decimal price) { int quantity = _config.LotSize; if (_oldOrderMode.HasValue && _oldOrderMode.Value == orderMode) { return; } var reversal = _reversalMultiplier.Where(s => s.Key <= _countOfContiniousExecutionInOneDirection).OrderByDescending(s => s.Key).FirstOrDefault(); if (reversal.Value != 0) { quantity = (_config.LotSize * reversal.Value) + Math.Abs(_currentOpenPosition); } else { quantity = _config.LotSize; } _countOfContiniousExecutionInOneDirection++; _oldOrderMode = orderMode; try { var orderResponse = _kite.PlaceOrder(_config.Exchange, _config.Symbol, orderMode.ToString(), quantity, Product: "MIS", OrderType: "MARKET"); Events.RaiseStatusChangedEvent(_config.Exchange, _config.Symbol, orderMode + " order executed"); } catch (Exception ex) { } }
public string[] SuggestProducts(int personId, OrderMode mode) { try { ECDBEntities entity = new ECDBEntities(); var purchasedProducts = from purchase in entity.PurchaseTbls where purchase.Cid == personId select purchase.ProductName; string[] relatives = FindAllRelatives(purchasedProducts.ToArray(), mode); var nowAds = from ad in entity.AdsTbls select ad.ProductName; var result = relatives.Intersect(nowAds); return(result.ToArray()); } catch (Exception ex) { MySoapFault fault = new MySoapFault(); fault.Operation = "SuggestProducts"; fault.Reason = "Error in suggesting products or finding relatives ."; fault.Details = ex.Message; fault.MoreDetails = ex.StackTrace; throw new FaultException <MySoapFault>(fault); } }
public void SaveData(JobbingStockBase stockBase, OrderMode orderMode, int quantity, decimal price, DateTime dtTime) { if (!Directory.Exists(stockBase.SaveDirectoryName)) { Directory.CreateDirectory(stockBase.SaveDirectoryName); } var dateDir = string.Format("{0}_{1}_{2}", dtTime.Year, dtTime.Month, dtTime.Day); string dirPath = stockBase.SaveDirectoryName + "\\" + dateDir; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } string fileName = string.Format("{0}_{1}", stockBase.Exchange, stockBase.Symbol); string dataToSave = string.Format("{0}${1}${2}${3}\r\n", orderMode, quantity, price, dtTime.ToString()); string filePath = dirPath + "\\" + fileName; if (File.Exists(filePath)) { using (var writer = File.AppendText(filePath)) { writer.Write(dataToSave); } } else { File.WriteAllText(filePath, dataToSave); } //string format = "{0}:{1}$ }
private bool PlaceOrder(RangeBreakOutStockConfig stock, OrderMode mode) { var quantity = stock.GetQuantity(); try { if (stock.OrderType == OrderType.CoverOrder) { return(PlaceCoverOrder(stock, mode, quantity)); } else if (stock.OrderType == OrderType.BracketOrder) { return(PlaceCoverOrder(stock, mode, quantity)); } else if (stock.OrderType == OrderType.CoverAndBracketOrder) { Task task1 = Task.Factory.StartNew(() => PlaceCoverOrder(stock, mode, quantity)); Task task2 = Task.Factory.StartNew(() => PlaceBracketOrder(stock, mode, quantity)); Task.WaitAll(task1, task2); return(true); } return(false); } catch (Exception ex) { return(false); } }
private bool PlaceBracketOrder(RangeBreakOutStockConfig stock, OrderMode mode, int quantity) { var stopLoss = Math.Abs(stock.SellBreakOutPrice - stock.BuyBreakOutPrice); Dictionary <string, dynamic> orderResponse = new Dictionary <string, dynamic>(); var triggerPrice = mode == OrderMode.BUY ? stock.BuyBreakOutPrice : stock.SellBreakOutPrice; var targetPrice = mode == OrderMode.BUY ? Math.Round((stock.BuyBreakOutPrice + (stock.BuyBreakOutPrice * (stock.ProfitMargin / 100.0m))), 2).GetNextValidPrice(true) : Math.Round((stock.SellBreakOutPrice - (stock.SellBreakOutPrice * (stock.ProfitMargin / 100.0m))), 2).GetNextValidPrice(true); var targetPoint = mode == OrderMode.BUY ? (targetPrice - stock.BuyBreakOutPrice) : (stock.SellBreakOutPrice - targetPrice); orderResponse = _kite.PlaceOrder(stock.Exchange, stock.Symbol, mode.ToString(), quantity, Product: Constants.PRODUCT_MIS, OrderType: Constants.ORDER_TYPE_LIMIT, Price: triggerPrice, Variety: Constants.VARIETY_BO, Validity: Constants.VALIDITY_DAY, SquareOffValue: targetPoint, StoplossValue: stopLoss); if (orderResponse.Any(s => s.Key.ToLower() == "status" && s.Value.ToLower() == "success")) { string orderId = GetOrderId(orderResponse); stock.AllOrderStatus[OrderType.BracketOrder] = new KeyValuePair <string, OrderStatus>(orderId, OrderStatus.Ordered); stock.AllOrderTargetPrice[OrderType.BracketOrder] = new KeyValuePair <OrderMode, decimal>(mode, targetPrice); Events.RaiseAskForOrderSubscriptionEvent(orderId, true); return(true); } else { return(false); } }
public Field(string name, bool searchable = false, OrderMode order = OrderMode.NONE, string expression = null) { Name = name; Searchable = searchable; Order = order; Expression = expression; }
private void printPortfolio(String instrumentName, OrderMode o) { Portfolio p = Portfolio.getInstance(); Side side = Side.Side_BUY; if (o == (OrderMode.OrderMode_BUY)) { side = Side.Side_BUY; } else if (o == (OrderMode.OrderMode_SELL)) { side = Side.Side_SELL; } try{ logInfo("fetching First Leg Position"); Position posFirstLeg = p.getNetPositions().getPosition( Context.getInstance().getInstrument(instrumentName), side ); printPosition(posFirstLeg); } catch (Exception e) { logInfo(e.Message.ToString()); } }
public KuduScanEnumerator( ILogger logger, KuduClient client, KuduTable table, List <ColumnSchemaPB> projectedColumnsPb, KuduSchema projectionSchema, OrderMode orderMode, ReadMode readMode, ReplicaSelection replicaSelection, bool isFaultTolerant, Dictionary <string, KuduPredicate> predicates, long limit, bool cacheBlocks, byte[] startPrimaryKey, byte[] endPrimaryKey, long startTimestamp, long htTimestamp, int batchSizeBytes, PartitionPruner partitionPruner, CancellationToken cancellationToken) { _logger = logger; _client = client; _table = table; _partitionPruner = partitionPruner; _orderMode = orderMode; _readMode = readMode; _columns = projectedColumnsPb; _schema = projectionSchema; _predicates = predicates; _replicaSelection = replicaSelection; _isFaultTolerant = isFaultTolerant; _limit = limit; _cacheBlocks = cacheBlocks; _startPrimaryKey = startPrimaryKey ?? Array.Empty <byte>(); _endPrimaryKey = endPrimaryKey ?? Array.Empty <byte>(); _startTimestamp = startTimestamp; SnapshotTimestamp = htTimestamp; _batchSizeBytes = batchSizeBytes; _scannerId = ByteString.Empty; _lastPrimaryKey = ByteString.Empty; _cancellationToken = cancellationToken; ResourceMetrics = new ResourceMetrics(); // If the partition pruner has pruned all partitions, then the scan can be // short circuited without contacting any tablet servers. if (!_partitionPruner.HasMorePartitionKeyRanges) { _closed = true; } // For READ_YOUR_WRITES scan mode, get the latest observed timestamp // and store it. Always use this one as the propagated timestamp for // the duration of the scan to avoid unnecessary wait. if (readMode == ReadMode.ReadYourWrites) { _lowerBoundPropagationTimestamp = client.LastPropagatedTimestamp; } }
public void SetMode(OrderMode mode) { _mode = mode; if (mode != OrderMode.None) { _areaHover.gameObject.SetActive(true); } }
internal static Euler From(Quaternion q, OrderMode order = DefaultOrder) { // q is assumed to be normalized // http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m var sqx = q.x * q.x; var sqy = q.y * q.y; var sqz = q.z * q.z; var sqw = q.w * q.w; float x, y, z; switch (order) { case OrderMode.XYZ: x = Mathf.Atan2(2 * (q.x * q.w - q.y * q.z), (sqw - sqx - sqy + sqz)); y = Mathf.Asin(Mathf.Clamp(2 * (q.x * q.z + q.y * q.w), -1, 1)); z = Mathf.Atan2(2 * (q.z * q.w - q.x * q.y), (sqw + sqx - sqy - sqz)); break; case OrderMode.YXZ: x = Mathf.Asin(Mathf.Clamp(2 * (q.x * q.w - q.y * q.z), -1, 1)); y = Mathf.Atan2(2 * (q.x * q.z + q.y * q.w), (sqw - sqx - sqy + sqz)); z = Mathf.Atan2(2 * (q.x * q.y + q.z * q.w), (sqw - sqx + sqy - sqz)); break; case OrderMode.ZXY: x = Mathf.Asin(Mathf.Clamp(2 * (q.x * q.w + q.y * q.z), -1, 1)); y = Mathf.Atan2(2 * (q.y * q.w - q.z * q.x), (sqw - sqx - sqy + sqz)); z = Mathf.Atan2(2 * (q.z * q.w - q.x * q.y), (sqw - sqx + sqy - sqz)); break; case OrderMode.ZYX: x = Mathf.Atan2(2 * (q.x * q.w + q.z * q.y), (sqw - sqx - sqy + sqz)); y = Mathf.Asin(Mathf.Clamp(2 * (q.y * q.w - q.x * q.z), -1, 1)); z = Mathf.Atan2(2 * (q.x * q.y + q.z * q.w), (sqw + sqx - sqy - sqz)); break; case OrderMode.YZX: x = Mathf.Atan2(2 * (q.x * q.w - q.z * q.y), (sqw - sqx + sqy - sqz)); y = Mathf.Atan2(2 * (q.y * q.w - q.x * q.z), (sqw + sqx - sqy - sqz)); z = Mathf.Asin(Mathf.Clamp(2 * (q.x * q.y + q.z * q.w), -1, 1)); break; case OrderMode.XZY: x = Mathf.Atan2(2 * (q.x * q.w + q.y * q.z), (sqw - sqx + sqy - sqz)); y = Mathf.Atan2(2 * (q.x * q.z + q.y * q.w), (sqw + sqx - sqy - sqz)); z = Mathf.Asin(Mathf.Clamp(2 * (q.z * q.w - q.x * q.y), -1, 1)); break; default: throw new NotSupportedException(string.Format("Given unsupported order: {0}.", order)); } return(new Euler(x, y, z, order)); }
// GET: ClassList public ActionResult Index(int page = 0, int limit = 10, string sort = "Id", OrderMode order = OrderMode.Asc, int school = 0, string description = "") { if (Request.IsAjaxRequest()) { var query = PredicateBuilder.True <Team>(); var list = from s in work.Team.GetPageEntitys() select new { s.CreateDate, s.TName, a = s.Specialty.Name, s.Remarks, s.Id }; return(Json(new { count = work.Team.GetCount(), code = 0, msg = "", })); } return(View()); }
/// <summary> /// 修改排序模式 /// </summary> /// <param name="mode"></param> private void ReversePostPreviewInfoList(OrderMode mode) { if (mode == this.postOrderMode) { return; } if (this.postPreviewInfoList == null) { return; } postPreviewInfoList.Reverse(); }
public string GetString(OrderMode order) { switch (order) { case OrderMode.Asc: return("ASC"); case OrderMode.Desc: return("DESC"); default: throw new ArgumentOutOfRangeException("order", order, null); } }
/// <summary> /// 查询日志记录 /// </summary> /// <param name="Author">用户</param> /// <param name="BeginDate">开始时间</param> /// <param name="EndDate">结束时间</param> /// <param name="Page">什么页面</param> /// <param name="from">开始记录</param> /// <param name="count">查询条数</param> /// <param name="fields">查询字段</param> /// <param name="orderKey">排序关键字</param> /// <param name="up"></param> /// <returns></returns> public List <Log> QueryLogsByAll(string Author, DateTime BeginDate, DateTime EndDate, string Page, int from, int count, string[] fields, string orderKey, bool up) { Criteria c = CreateCriteriaByAll(Author, BeginDate, EndDate, Page); OrderMode mode = OrderMode.Asc; if (!up) { mode = OrderMode.Desc; } Order[] orders = new Order[] { new Order(orderKey, mode) }; return(Assistant.List <Log>(c, orders, from, count, fields)); }
private void UpdateOrderModeDisplay(OrderMode mode) { if (mode.Code == CAPLib.StatusType.Actual) { this.lblOrderMode.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(45)))), ((int)(((byte)(45))))); } else if (mode.Code == CAPLib.StatusType.Exercise) { this.lblOrderMode.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(227)))), ((int)(((byte)(203)))), ((int)(((byte)(3))))); } else { this.lblOrderMode.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(89)))), ((int)(((byte)(149)))), ((int)(((byte)(30))))); } this.lblOrderMode.Text = mode.Name + "모드"; }
/// <summary> /// 발령 모드 콤보박스 설정. /// </summary> private void InitializeOrderModeCmbbox() { this.cmbboxOrderMode.Enabled = false; this.cmbboxOrderMode.Items.Clear(); this.cmbboxOrderMode.Enabled = true; this.cmbboxOrderMode.Items.Add("전체"); foreach (OrderMode mode in BasisData.OrderModeInfo.Values) { OrderMode copy = new OrderMode(); copy.DeepCopyFrom(mode); this.cmbboxOrderMode.Items.Add(copy); } this.cmbboxOrderMode.SelectedIndex = 0; }
public TilePicker() { InitializeComponent(); m_autoUpdate = false; m_watchers = new Dictionary<TileSheet, FileSystemWatcher>(); m_selectedTileIndex = -1; m_orderMode = OrderMode.Indexed; m_selectionBrush = new SolidBrush(Color.FromArgb(128, Color.SkyBlue)); m_visibleSize = new Size(); m_requiredSize = new Size(); m_indexToMru = new List<int>(); UpdateInternalDimensions(); }
public void PositionModeOrder(float coefficient, OrderMode order_mode) { PositionModeSet(); switch (order_mode) { case OrderMode.ORDER_MODE_HORIZONTAL: OrherModeHorizontal(coefficient); break; case OrderMode.ORDER_MODE_VERTICAL: OrherModeVertical(coefficient); break; default: break; } }
/// <summary> /// Returns true if it reaches max loss and max profit /// </summary> /// <param name="position"></param> /// <returns></returns> public bool CheckMaxProfitLossAndClosePosition(int quantity, decimal PNL) { try { _config.NetQuantity = quantity; _config.UpdateMax(); if ((PNL >= _config.MaxProfit && _config.MaxProfit != 0) || (PNL <= -(_config.MaxLoss) && _config.MaxLoss != 0)) { OrderMode mode = OrderMode.BUY; if (quantity > 0) { mode = OrderMode.SELL; } else { mode = OrderMode.BUY; } var status = _kite.PlaceOrder(_config.Exchange, _config.Symbol, mode.ToString(), Convert.ToInt32(Math.Abs(quantity)), Product: "MIS", OrderType: "MARKET"); var orderPlacedSuccessfully = status.Any(s => s.Key.ToLower() == "status" && s.Value.ToLower() == "success"); if (orderPlacedSuccessfully) { if (PNL > _config.MaxProfit) { Events.RaiseStatusChangedEvent(_config.Exchange, _config.Symbol, StrategyStockStatus.MaxProfitReached.ToString()); } else { Events.RaiseStatusChangedEvent(_config.Exchange, _config.Symbol, StrategyStockStatus.MaxLossReached.ToString()); } fileWather.Changed -= FileWather_Changed; fileWather.EnableRaisingEvents = false; return(true); } return(false); } return(false); } catch (Exception) { return(false); } }
/// <summary> /// [발령 모드] 선택 변경. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbboxOrderMode_SelectedIndexChanged(object sender, EventArgs e) { if (!this.cmbboxOrderMode.Focused) { return; } this.orderInquiryCondition.OrderMode = null; if (this.cmbboxOrderMode.SelectedIndex == 0 && this.cmbboxOrderMode.SelectedText == "전체") { return; } OrderMode selectedMode = this.cmbboxOrderMode.SelectedItem as OrderMode; if (selectedMode == null) { return; } this.orderInquiryCondition.OrderMode = selectedMode; }
// GET: StudentList public ActionResult Index(int page = 0, int limit = 10, string sort = "Id", OrderMode order = OrderMode.Asc, int school = 0, int state = 1, string description = "") { if (Request.IsAjaxRequest()) { var where = PredicateBuilder.True <Student>(); if (school != 0) { where = where.And(s => s.ShcoolId == school); } if (state != 0) { where = where.And(s => s.CustomerStateId == state); } if (description != "") { where = where.And(s => s.Name.Contains(description) || s.ParentsPhone.Contains(description)); } int offset = (page - 1) * limit; var stus = work.Student.GetPageEntitys(where, limit, offset, sort, order); var list = from s in stus select new { s.Name, Birthday = (DateTime.Now.Year - s.Birthday.Year) + "岁", s.ParentsPhone, s.IntentionDegree.Leavl, s.CustomerSource.Sourece, s.CustomerState.StatusStr, s.OperatorAdminUser.RealName, ConsultationDate = s.ConsultationDate.ToString(), Specialty = (work.ConsultMajor.GetCount(c => c.StudentId == s.Id) == 0 ? "无" : work.ConsultMajor.Where(c => c.StudentId == s.Id).ToList()[0].Specialty.Name), s.Id, comCount = work.CommunicationRecord.GetCount(c => c.Student.Id == s.Id), bm = (work.SignUp.Where(c => c.Student.Id == s.Id).Count() == 0?"": work.SignUp.Where(c => c.Student.Id == s.Id).ToArray()[0].Team.TName), Comnundate = work.CommunicationRecord.GetCount(c => c.Student.Id == s.Id) == 0 ? "无" : GetDate(work.CommunicationRecord.GetAll(c => c.Student.Id == s.Id).OrderByDescending(z => z.CommunicationDate).FirstOrDefault().CommunicationDate) }; return(Json(new { code = 0, count = work.Student.GetCount(), data = list }, JsonRequestBehavior.AllowGet)); } ViewBag.Shcool = work.School.GetAll(); ViewBag.CustomerState = work.CustomerState.GetAll(s => s.Status); return(View()); }
void orderModeForm_OnNotifyOrderModeChanged(object sender, OrderModeEventArgs e) { if (this.currentOrderInfo.Mode == null) { this.currentOrderInfo.Mode = new OrderMode(); } OrderMode modeInfo = BasisData.FindOrderModeInfoByCode(e.Mode); if (modeInfo != null) { this.currentOrderInfo.Mode.DeepCopyFrom(modeInfo); } else { this.currentOrderInfo.Mode.Code = e.Mode; this.currentOrderInfo.Mode.Name = "실제"; } UpdateOrderModeDisplay(this.currentOrderInfo.Mode); }
public string[] FindAllRelatives(string[] productNames, OrderMode mode) { try { string query = "SELECT DISTINCT ?RelativeProducts WHERE {{ <http://www.myproducts.com/" + productNames[0] + "> <http://www.myproducts.com/InCategoryOf> ?CategoryId . ?RelativeProducts <http://www.myproducts.com/InCategoryOf> ?CategoryId } "; string filters = "FILTER ((?RelativeProducts!=<http://www.myproducts.com/" + productNames[0] + ">) "; for (int i = 1; i < productNames.Length; i++) { query += "UNION { <http://www.myproducts.com/" + productNames[i] + "> <http://www.myproducts.com/InCategoryOf> ?CategoryId . ?RelativeProducts <http://www.myproducts.com/InCategoryOf> ?CategoryId } "; filters += "&& (?RelativeProducts!=<http://www.myproducts.com/" + productNames[i] + ">)"; } query += filters + ")} "; if (mode == OrderMode.ProductName) { query += "ORDER BY ?RelativeProducts"; } return (linkedDataProxy.ExceuteQuery(query).items.Select(queryResult => queryResult.result.Substring(46)). ToArray()); } catch (Exception ex) { MySoapFault fault = new MySoapFault(); fault.Operation = "FindAllRelatives"; fault.Reason = "Error in finding all relatives in ECommerceService ."; fault.Details = ex.Message; fault.MoreDetails = ex.StackTrace; throw new FaultException <MySoapFault>(fault); } }
private bool PlaceCoverOrder(RangeBreakOutStockConfig stock, OrderMode mode, int quantity) { stock.StopLoss = mode == OrderMode.BUY ? stock.SellBreakOutPrice : stock.BuyBreakOutPrice; Dictionary <string, dynamic> orderResponse = new Dictionary <string, dynamic>(); orderResponse = _kite.PlaceOrder(stock.Exchange, stock.Symbol, mode.ToString(), quantity, Product: Constants.PRODUCT_MIS, OrderType: Constants.ORDER_TYPE_MARKET, TriggerPrice: stock.StopLoss, Variety: stock.Variety, Validity: Constants.VALIDITY_DAY); if (orderResponse.Any(s => s.Key.ToLower() == "status" && s.Value.ToLower() == "success")) { stock.TargetPrice = null; string orderId = GetOrderId(orderResponse); Events.RaiseAskForOrderSubscriptionEvent(orderId, true); stock.ParentOrderId = orderId; stock.LastOrderedQuantity = quantity; stock.ReversalNumber++; stock.OrderedQuantity = quantity; return(true); } else { return(true); } }
/// <summary> /// Writes performance results in formated layout to the given stream. /// </summary> /// <param name="stream"></param> /// <param name="orderMode"></param> /// <param name="vector"></param> public static void ExportPerformanceResults(StreamWriter stream, OrderMode orderMode, OrderVector vector) { var comparator = new PerfInfoComparator(orderMode); PerfInfo[] dataSet; dataSet = vector == OrderVector.Ascending ? SharedResults.Values.Select(i => i).OrderBy(i => i, comparator).ToArray() : SharedResults.Values.Select(i => i).OrderByDescending(i => i, comparator).ToArray(); stream.WriteLine(@"| EventName | EventCount | TotalTicks | AverageTicks | Average Time (ms) |"); foreach (PerfInfo perfInfo in dataSet) { stream.WriteLine(@"| " + string.Join(@" | ", new[] { perfInfo.Name, perfInfo.Events.ToString(@"D"), perfInfo.TotalTicks.ToString(@"D"), (perfInfo.TotalTicks / perfInfo.Events).ToString(@"D"), ((decimal)perfInfo.TotalTicks / perfInfo.Events / TimeSpan.TicksPerMillisecond) .ToString(@"F4") }) + @" |"); } }
public static Order CreateOrderFromOrderMode(OrderMode orderMode, Uri orderId, Guid?proposalVersionId, ProposalStatus?proposalStatus) { switch (orderMode) { case OrderMode.Booking: return(new Order()); case OrderMode.Lease: return(new OrderQuote()); case OrderMode.Proposal: var o = new OrderProposal(); o.OrderProposalVersion = new Uri($"{orderId}/versions/{proposalVersionId.ToString()}"); o.OrderProposalStatus = proposalStatus == ProposalStatus.AwaitingSellerConfirmation ? OrderProposalStatus.AwaitingSellerConfirmation : proposalStatus == ProposalStatus.CustomerRejected ? OrderProposalStatus.CustomerRejected : proposalStatus == ProposalStatus.SellerAccepted ? OrderProposalStatus.SellerAccepted : proposalStatus == ProposalStatus.SellerRejected ? OrderProposalStatus.SellerRejected : (OrderProposalStatus?)null; return(o); default: throw new ArgumentOutOfRangeException(nameof(orderMode)); } }
public void setOrderMode(OrderMode orderMode) { ContextModulePINVOKE.ExecutionReport_setOrderMode(swigCPtr, (int)orderMode); }
private void OnOrderMru(object sender, EventArgs eventArgs) { m_orderMode = OrderMode.MRU; UpdateOrderButtons(); m_horizontalScrollBar.Visible = m_verticalScrollBar.Visible = false; m_horizontalScrollBar.Value = m_verticalScrollBar.Value = 0; UpdateInternalDimensions(); m_tilePanel.Invalidate(); SelectedTileIndex = SelectedTileIndex; }
/// <summary> /// 按指定字段名称排序 /// </summary> /// <typeparam name="T"><peparam> /// <param name="query"></param> /// <param name="sort"></param> /// <param name="order"></param> /// <returns></returns> public static IQueryable <T> SetQueryableOrder <T>(this IQueryable <T> query, string sort = "Id", OrderMode order = OrderMode.Asc) { PropertyInfo sortProperty = typeof(T).GetProperty(sort, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase); if (sortProperty == null) { throw new Exception("查询对象中不存在排序字段" + sort + "!"); } ParameterExpression param = Expression.Parameter(typeof(T), "t"); Expression body = param; if (Nullable.GetUnderlyingType(body.Type) != null) { body = Expression.Property(body, "Value"); } body = Expression.MakeMemberAccess(body, sortProperty); LambdaExpression keySelectorLambda = Expression.Lambda(body, param); string queryMethod = order == OrderMode.Desc ? "OrderByDescending" : "OrderBy"; query = query.Provider.CreateQuery <T>(Expression.Call(typeof(Queryable), queryMethod, new Type[] { typeof(T), body.Type }, query.Expression, Expression.Quote(keySelectorLambda))); return(query); }