File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -195,5 +195,30 @@ public decimal GetPriceToSell(decimal amount)
195
195
196
196
return sellPrice ;
197
197
}
198
+
199
+ /// <summary>
200
+ /// Updates this order book with a partial order book update. items with a price-level
201
+ /// of 0 are removed from the orderbook, all others are inserted/updated with the supplied value
202
+ /// </summary>
203
+ /// <param name="partialUpdate">Set of changes to make</param>
204
+ public void ApplyUpdates ( ExchangeOrderBook partialUpdate )
205
+ {
206
+ MergeOrderBookDelta ( partialUpdate . Asks , this . Asks ) ;
207
+ MergeOrderBookDelta ( partialUpdate . Bids , this . Bids ) ;
208
+
209
+ static void MergeOrderBookDelta (
210
+ SortedDictionary < decimal , ExchangeOrderPrice > newData ,
211
+ SortedDictionary < decimal , ExchangeOrderPrice > bookData )
212
+ {
213
+ newData . ToList ( ) . ForEach ( x =>
214
+ {
215
+ if ( x . Value . Amount == 0m )
216
+ bookData . Remove ( x . Key ) ;
217
+ else
218
+ bookData [ x . Key ] = x . Value ;
219
+ } ) ;
220
+ }
221
+
222
+ }
198
223
}
199
224
}
You can’t perform that action at this time.
0 commit comments