// protected virtual void Dispose(bool isDisposing) { if (!m_IsDisposed) { if (isDisposing) { if (m_Timer != null) { m_Timer.Dispose(); m_Timer = null; } lock (m_EventListLock) { foreach (AlarmEventArgs e in m_EventList.Values) { e.Clear(); } } if (m_AlarmFactory != null) { // Do we want to implement disposible for alarm factory? //m_AlarmFactory.Di m_AlarmFactory = null; } } m_IsDisposed = true; } }
// // /// <summary> /// Given a ttOrder try and create a UV style order attempting to use /// a recycle order each time. /// </summary> /// <param name="ttOrder"></param> /// <param name="orderRecycler"></param> /// <param name="uvOrder"></param> /// <returns></returns> public static bool TryConvert(Order ttOrder, RecycleFactory <UVOrder> orderRecycler, out UVOrder uvOrder) { bool isSuccess = true; try { uvOrder = orderRecycler.Get(); // try and use a recycled order if (ttOrder.BuySell == BuySell.Buy) { uvOrder.OriginalQtyConfirmed = ttOrder.OrderQuantity; uvOrder.ExecutedQty = ttOrder.FillQuantity; uvOrder.Side = UVOrder.BuySide; } else { uvOrder.OriginalQtyConfirmed = ttOrder.OrderQuantity * -1; uvOrder.ExecutedQty = ttOrder.FillQuantity * -1; uvOrder.Side = UVOrder.SellSide; } uvOrder.OrderTIF = ToUVTimeinForce(ttOrder.TimeInForce); uvOrder.IPriceConfirmed = ttOrder.LimitPrice.ToTicks() / ttOrder.InstrumentDetails.SmallestTickIncrement; uvOrder.TickSize = ToUVTickSize(ttOrder.InstrumentDetails); uvOrder.OrderStateConfirmed = ToUVOrderState(ttOrder.TradeState); } catch (Exception) { isSuccess = false; uvOrder = null; } return(isSuccess); }
// ***************************************************************** // **** Constructors **** // ***************************************************************** /// <summary> /// /// </summary> /// <param name="sideOfOrders">Each OrderPage contains either Buy/Sell orders</param> public OrderPage(int sideOfOrders, OrderBook parentBook, RecycleFactory <Order> orderRecycleFactory) { this.OrderSide = sideOfOrders; this.OrderSign = UV.Lib.Utilities.QTMath.MktSideToMktSign(this.OrderSide); this.m_OrderRecycleFactory = orderRecycleFactory; m_ParentOrderBook = parentBook; }
public int SaveBuilding(BuildingSaveModel buildingSaveModel) { try { using (var dbContext = new DiplomaDBContext()) { var locationId = dbContext.Location.Count() + 1; var location = new Location { Id = locationId, Latitude = buildingSaveModel.location.lat, Longitude = buildingSaveModel.location.lng }; dbContext.Location.Add(location); if (buildingSaveModel.type == 0) { var utilityId = dbContext.Utility.Count() + 1; var utility = new Utility { Id = utilityId, Name = buildingSaveModel.name, LocationId = locationId, Ready = buildingSaveModel.ready, UtilityCompanyId = buildingSaveModel.utilityCompany.Value, UtilityOptionsId = 1 }; dbContext.Utility.Add(utility); } else { var factoryId = dbContext.RecycleFactory.Count() + 1; var factory = new RecycleFactory { Id = factoryId, Name = buildingSaveModel.name, LocationId = locationId, Ready = buildingSaveModel.ready }; dbContext.RecycleFactory.Add(factory); } dbContext.SaveChanges(); return(1); } } catch { return(0); } }
private GetCurrentTime m_GetCurrentTime = null; // The function to call to get the time. #endregion // members #region Constructors // ***************************************************************** // **** Constructors **** // ***************************************************************** public Alarm() { m_Timer = new Timer(); m_Timer.AutoReset = false; m_Timer.Elapsed += Timer_Elapsed; m_EventList = new SortedList <DateTime, AlarmEventArgs>(); m_AlarmFactory = new RecycleFactory <AlarmEventArgs>(); this.SetTimeDelegate(GetDefaultTime); }
Dictionary <int, Order> m_OrderWorkspace = new Dictionary <int, Order>(); // clear before each use! #endregion // members #region Constructors // ***************************************************************** // **** Constructors **** // ***************************************************************** public OrderBook(InstrumentName instrument, RecycleFactory <Order> orderRecycleFactory) { // Set Id when order book is connected and initialize by hub. this.m_BookID = System.Threading.Interlocked.Increment(ref OrderBook.m_NextId); this.Instrument = instrument; // Initialize the lists. m_LiveOrders = new OrderPage[NSides]; // a page for each side of mkt. m_DeletedOrders = new OrderPage[NSides]; for (int side = 0; side < NSides; ++side) { m_LiveOrders[side] = new OrderPage(side, this, orderRecycleFactory); m_DeletedOrders[side] = new OrderPage(side, this, orderRecycleFactory); } }
private OrderBook m_DefaultBook; // default order book for uknown orders not owned by a strat(yet) #endregion // members #region Constructors // ***************************************************************** // **** Constructors **** // ***************************************************************** /// <summary> /// Main constructor for Order Instrument. An RecycleFactory<Order> must /// be passed in for the deafult order book to be constructed /// </summary> /// <param name="instrumentName"></param> /// <param name="details"></param> /// <param name="orderRecycleFactory"></param> public OrderInstrument(InstrumentName instrumentName, InstrumentDetails details, RecycleFactory <Order> orderRecycleFactory) { this.Instrument = instrumentName; this.Details = details; m_OrderIDToBookMap = new ConcurrentDictionary <int, int>(); m_DefaultBook = new OrderBook(instrumentName, orderRecycleFactory); // create our default book m_OrderBooks.Add(m_DefaultBook.BookID, m_DefaultBook); // add it to our look up tables m_DefaultBook.IsReady = true; }
// ***************************************************************** // **** Members **** // ***************************************************************** // #endregion// members #region Constructors // ***************************************************************** // **** Constructors **** // ***************************************************************** public OrderBookTT(InstrumentName instrumentName, RecycleFactory <Order> orderRecycleFactory) : base(instrumentName, orderRecycleFactory) { }