Created
June 7, 2012 23:52
-
-
Save michaeldiamant/2892477 to your computer and use it in GitHub Desktop.
Complecting trade execution processor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ComplectingTradeExecutionProcessor extends TradeExecutionProcessor with MarkupApplicator { | |
val requestedTradeRepository: RequestedTradeRepository | |
val markingUpSymbol: String | |
val symbolMarkup: BigDecimal | |
val markupVolumeThreshold: Long | |
val volumeMarkup: BigDecimal | |
def process(requestId: String, executionPrice: BigDecimal): Option[ExecutedTrade] = | |
requestedTradeRepository.findById(requestId) | |
.map(requestedTrade => { | |
val markedUpSymbolExecutionPrice = (requestedTrade.symbol == markingUpSymbol) | |
.option(addMarkup(requestedTrade.side, executionPrice, symbolMarkup)) | |
.getOrElse(executionPrice) | |
val markedUpVolumeExecutionPrice = (requestedTrade.volume <= markupVolumeThreshold) | |
.option(addMarkup(requestedTrade.side, markedUpSymbolExecutionPrice, volumeMarkup)) | |
.getOrElse(markedUpSymbolExecutionPrice) | |
ExecutedTrade( | |
requestId = requestedTrade.id, | |
executedPrice = executionPrice, | |
reportedPrice = markedUpVolumeExecutionPrice | |
) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment