public bool Execute(OrderExecuteEventArgs e) { var error = this.InnerExecute(e); Trace.WriteLine(string.Format("Execute result , error code = {0}", error)); return(error == TransactionError.OK ? true : false); }
private void Execute(Transaction tran) { Logger.InfoFormat("in auto fill, tranId = {0}", tran.Id); List <OrderPriceInfo> infoList = tran.CreateOrderPriceInfo(); var executeContext = new ExecuteContext(tran.Owner.Id, tran.Id, ExecuteStatus.Filled, infoList); var executeRequest = new OrderExecuteEventArgs(executeContext); Logger.InfoFormat("Engine ready to execute transaction, tranId = {0}", tran.Id); iExchangeEngine.Default.Execute(executeRequest); }
private TransactionError InnerExecute(OrderExecuteEventArgs e) { TransactionError error = TransactionError.OK; try { var account = TradingSetting.Default.GetAccount(e.AccountId); var tran = account.GetTran(e.TranId); if (e.TranId == null) { return(TransactionError.TransactionNotExists); } if (e.ExecutingLot != null) { this.PartialExecute(e.ExecutingLot.Value, tran); } if (!tran.CanExecute) { if (tran.IsExecuted) { return(TransactionError.OK); } else { return(TransactionError.TransactionCannotBeExecuted); } } _executeStrategy.Execute(e); //if (!SettingFacade.Default.SettingManager.SystemParameter.NeedsFillCheck(e.Transaction.OrderType)) //{ // Trace.WriteLine("ready to book"); // error = this.Book(e); //} //else //{ // Trace.WriteLine("executeStrategy.Execute"); // _executeStrategy.Execute(e); //} } catch (TransactionException tranEx) { error = tranEx.ErrorCode; Logger.Warn(tranEx.Message); Trace.WriteLine(tranEx.Message); } catch (Exception ex) { error = TransactionError.RuntimeError; Logger.Error(ex); Trace.WriteLine(ex.ToString()); } return(error); }
private void TryHitPriceAndExecute(Order order) { var status = this.TryHitPrice(order); if (status == OrderHitStatus.ToAutoFill) { Price buy, sell; order.GetBuyAndSellPrice(out buy, out sell); var executeRequest = new OrderExecuteEventArgs(new ExecuteContext(order.Owner.Owner.Id, order.Owner.Id, order.Id, ExecuteStatus.Filled, new List <OrderPriceInfo> { new OrderPriceInfo(order.Id, buy, sell) })); iExchangeEngine.Default.Execute(executeRequest); } }
internal void ExecuteOrders(List <DeferredAutoFillInfo> items) { foreach (var eachItem in items) { List <OrderPriceInfo> orderInfos; if (eachItem.Transaction.OrderType == OrderType.BinaryOption) { orderInfos = this.GetPricesForBO(eachItem); } else { orderInfos = this.GetBuySellPrice(eachItem); } var executeRequest = new OrderExecuteEventArgs(new ExecuteContext(eachItem.Account.Id, eachItem.Transaction.Id, ExecuteStatus.Filled, orderInfos)); iExchangeEngine.Default.Execute(executeRequest); } }
private void TradingEngine_Executed(object sender, OrderExecuteEventArgs e) { try { if (e.Context.Status == ExecuteStatus.Filled) { this.ProcessForTranExecuted(e.Context); } else { e.Context.Account.CancelExecute(e.Context, CancelReason.OtherReason); } TransactionExpireChecker.Default.Remove(e.Context.TranId); } catch (Exception ex) { Logger.Error(ex); } }
public bool Execute(OrderExecuteEventArgs e) { _executeStrategy.Execute(e); return(true); }
protected override void ExecuteTransaction(Transaction tran, OrderExecuteEventArgs e) { PhysicalExecutor.Default.Execute(tran, e, _tradingEngine); base.ExecuteTransaction(tran, e); }
public void Execute(OrderExecuteEventArgs e) { ActionBlock <OrderExecuteEventArgs> block = this.GetBlock(e.Context.AccountId); block.Post(e); }