void getEntryInfo( MamdaOrderBookEntry entry, MamaMsg entMsg, MamdaOrderBookPriceLevel level) { entry.setAction((MamdaOrderBookEntry.Actions)entMsg.getChar( MamdaOrderBookFields.ENTRY_ACTION, 'D')); entry.setId(entMsg.getString(MamdaOrderBookFields.ENTRY_ID)); entry.setSize((long)entMsg.getF64(MamdaOrderBookFields.ENTRY_SIZE, 0)); entry.setTime(entMsg.getDateTime(MamdaOrderBookFields.ENTRY_TIME, level.getTime())); }
/// <summary> /// Mark everything in this price level as deleted, including /// entries. /// </summary> public void markAllDeleted() { setSizeChange(-getSize()); setSize(0); setNumEntries(0); setAction(Actions.Delete); for (int i = 0; i < mEntries.Count; i++) { MamdaOrderBookEntry entry = (MamdaOrderBookEntry)mEntries[i]; entry.setSize(0); entry.setAction(MamdaOrderBookEntry.Actions.Delete); } }
void getEntryInfo( MamdaOrderBookEntry entry, MamaMsg entMsg, MamdaOrderBookPriceLevel level) { entry.setAction((MamdaOrderBookEntry.Actions)entMsg.getChar( MamdaOrderBookFields.ENTRY_ACTION, 'D')); entry.setId(entMsg.getString(MamdaOrderBookFields.ENTRY_ID)); entry.setSize((long)entMsg.getF64(MamdaOrderBookFields.ENTRY_SIZE, 0)); entry.setTime(entMsg.getDateTime(MamdaOrderBookFields.ENTRY_TIME, level.getTime())); }
/// <summary> /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> public void setAsDifference( MamdaOrderBookPriceLevel lhs, MamdaOrderBookPriceLevel rhs) { int lhsBookSize = lhs.mEntries.Count; int rhsBookSize = rhs.mEntries.Count; int lhsIndex = 0; int rhsIndex = 0; while ((lhsIndex < lhsBookSize) && (rhsIndex < rhsBookSize)) { string lhsId = null; string rhsId = null; long lhsSize = 0; long rhsSize = 0; MamdaOrderBookEntry lhsEntry = null; MamdaOrderBookEntry rhsEntry = null; if (lhsIndex < lhsBookSize) { lhsEntry = (MamdaOrderBookEntry)lhs.mEntries[lhsIndex]; lhsId = lhsEntry.getId(); lhsSize = lhsEntry.getSize(); } if (rhsIndex < rhsBookSize) { rhsEntry = (MamdaOrderBookEntry)rhs.mEntries[rhsIndex]; rhsId = rhsEntry.getId(); rhsSize = rhsEntry.getSize(); } if ((lhsId != null) && (rhsId != null)) { if (lhsId == rhsId) { // Same ID, maybe different size. if (lhsSize != rhsSize) { MamdaOrderBookEntry updateEntry = new MamdaOrderBookEntry(rhsEntry); updateEntry.setAction(MamdaOrderBookEntry.Actions.Update); addEntry(updateEntry); } lhsIndex++; rhsIndex++; continue; } else { // Different ID (either something exists on the LHS // and not on RHS or vice versa). int rhsFound = findEntryAfter(rhs.mEntries, rhsIndex, lhsId); if (rhsFound != rhsSize) { // The ID from the LHS was found on the RHS, so // there must have been additional entries on the // RHS, which we now need to add. do { addEntry((MamdaOrderBookEntry)rhs.mEntries[rhsIndex]); rhsIndex++; } while (rhsIndex < rhsFound); } else { // The ID from the LHS was not present on the RHS, // so add the LHS entry. Note: it would probably // be faster to iterate over the LHS side rather // than begin the loop again. addEntry((MamdaOrderBookEntry)lhs.mEntries[lhsIndex]); lhsIndex++; } } } } if (mPrice != null && rhs.getPrice() != null) { mPrice.destroy(); } mPrice = rhs.getPrice(); setSizeChange(rhs.getSize() - lhs.getSize()); setSize(rhs.getSize()); setNumEntries(rhs.getNumEntries()); setAction(Actions.Update); mTime = rhs.getTime(); setSide(rhs.getSide()); }
/// <summary> /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> public void setAsDifference( MamdaOrderBookPriceLevel lhs, MamdaOrderBookPriceLevel rhs) { int lhsBookSize = lhs.mEntries.Count; int rhsBookSize = rhs.mEntries.Count; int lhsIndex = 0; int rhsIndex = 0; while ((lhsIndex < lhsBookSize) && (rhsIndex < rhsBookSize)) { string lhsId = null; string rhsId = null; long lhsSize = 0; long rhsSize = 0; MamdaOrderBookEntry lhsEntry = null; MamdaOrderBookEntry rhsEntry = null; if (lhsIndex < lhsBookSize) { lhsEntry = (MamdaOrderBookEntry)lhs.mEntries[lhsIndex]; lhsId = lhsEntry.getId(); lhsSize = lhsEntry.getSize(); } if (rhsIndex < rhsBookSize) { rhsEntry = (MamdaOrderBookEntry)rhs.mEntries[rhsIndex]; rhsId = rhsEntry.getId(); rhsSize = rhsEntry.getSize(); } if ((lhsId != null) && (rhsId != null)) { if (lhsId == rhsId) { // Same ID, maybe different size. if (lhsSize != rhsSize) { MamdaOrderBookEntry updateEntry = new MamdaOrderBookEntry(rhsEntry); updateEntry.setAction(MamdaOrderBookEntry.Actions.Update); addEntry(updateEntry); } lhsIndex++; rhsIndex++; continue; } else { // Different ID (either something exists on the LHS // and not on RHS or vice versa). int rhsFound = findEntryAfter(rhs.mEntries, rhsIndex, lhsId); if (rhsFound != rhsSize) { // The ID from the LHS was found on the RHS, so // there must have been additional entries on the // RHS, which we now need to add. do { addEntry((MamdaOrderBookEntry)rhs.mEntries[rhsIndex]); rhsIndex++; }while (rhsIndex < rhsFound); } else { // The ID from the LHS was not present on the RHS, // so add the LHS entry. Note: it would probably // be faster to iterate over the LHS side rather // than begin the loop again. addEntry((MamdaOrderBookEntry)lhs.mEntries[lhsIndex]); lhsIndex++; } } } } if (mPrice != null && rhs.getPrice() != null) { mPrice.destroy(); } mPrice = rhs.getPrice(); setSizeChange(rhs.getSize() - lhs.getSize()); setSize(rhs.getSize()); setNumEntries(rhs.getNumEntries()); setAction(Actions.Update); mTime = rhs.getTime(); setSide(rhs.getSide()); }