本文整理汇总了C#中IOrder.getQuoteForUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# IOrder.getQuoteForUpdate方法的具体用法?C# IOrder.getQuoteForUpdate怎么用?C# IOrder.getQuoteForUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOrder
的用法示例。
在下文中一共展示了IOrder.getQuoteForUpdate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessAndCompleteOrder
public void ProcessAndCompleteOrder(OrderDataModel order)
{
try
{
dalOrder = Trade.DALFactory.Order.Create(Settings.DAL);
dalOrder.Open(Settings.TRADEDB_SQL_CONN_STRING);
decimal total = 0;
int holdingid = -1;
QuoteDataModel quote = dalOrder.getQuoteForUpdate(order.symbol);
//Get the latest trading price--this is the money going into (or out of) the users account.
order.price = quote.price;
//Calculate order total, and create/update the Holding. Whole holding
//sells delete the holding, partials sells update the holding with new amount
//(and potentially the order too), and buys create a new holding.
if (order.orderType == StockTraderUtility.ORDER_TYPE_BUY)
{
holdingid = dalOrder.createHolding(order);
total = Convert.ToDecimal(order.quantity) * order.price + order.orderFee;
}
else
if (order.orderType == StockTraderUtility.ORDER_TYPE_SELL)
{
holdingid = sellHolding(order);
//We will assume here, since the holding cannot be found, it has already been sold,
//perhaps in another browser session.
if (holdingid == -1 )
return;
total = -1 * Convert.ToDecimal(order.quantity) * order.price + order.orderFee;
}
//Debit/Credit User Account. Note, if we did not want to allow unlimited margin
//trading, we would change the ordering a bit and add the biz logic here to make
//sure the user has enough money to actually buy the shares they asked for!
//Now Update Account Balance.
dalOrder.updateAccountBalance(order.accountID, total);
//Update the stock trading volume and price in the quote table
dalOrder.updateStockPriceVolume(order.quantity, quote);
//Now perform our ACID tx test, if requested based on order type and acid stock symbols
if (order.symbol.Equals(StockTraderUtility.ACID_TEST_BUY) && order.orderType == StockTraderUtility.ORDER_TYPE_BUY)
throw new Exception(StockTraderUtility.EXCEPTION_MESSAGE_ACID_BUY);
else
if (order.symbol.Equals(StockTraderUtility.ACID_TEST_SELL) && order.orderType == StockTraderUtility.ORDER_TYPE_SELL)
throw new Exception(StockTraderUtility.EXCEPTION_MESSAGE_ACID_SELL);
//Finally, close the order
order.orderStatus = StockTraderUtility.ORDER_STATUS_CLOSED;
order.completionDate = DateTime.Now;
order.holdingID = holdingid;
dalOrder.closeOrder(order);
//Done!
return;
}
catch
{
throw;
}
finally
{
dalOrder.Close();
}
}