This file contains hidden or 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
| object E1 { | |
| // Encoding a 1:1 command to event example | |
| sealed trait Event | |
| case class E1(i: Int) extends Event | |
| case class E2() extends Event | |
| sealed trait Intent[Z <: Event] { | |
| type Out = Z | |
| } | |
| case class C1(id: Int) extends Intent[E1] | |
| case class C2(id: Int) extends Intent[E1] |
This file contains hidden or 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
| [michael@dca-infra01 ansible]$ cat /home/michael/ntoggle/ansible/roles/ntoggle.helix-service/tasks/required_vars.yml - name: check required variables are defined | |
| fail: msg="Variable '{{ item }}' is undefined" | |
| when: item is not defined | |
| with_items: | |
| - foo | |
| - bar | |
| - fail: msg="foo" | |
| when: foo is not defined | |
This file contains hidden or 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 Usd | |
| trait Eur | |
| trait ProfitCalculator[T] { | |
| def calculateProfit(executionPrice: BigDecimal @@ T, requestedPrice: BigDecimal @@ T): BigDecimal @@ T = | |
| tag(executionPrice - requestedPrice) | |
| } |
This file contains hidden or 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
| case class UsdPrice(value: BigDecimal) { | |
| def +(p: UsdPrice) = UsdPrice(value + p.value) | |
| def -(p: UsdPrice) = UsdPrice(value - p.value) | |
| } | |
| case class EurPrice(value: BigDecimal) { | |
| def +(p: EurPrice) = EurPrice(value + p.value) |
This file contains hidden or 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 ExtensibleTradeExecutionProcessor extends TradeExecutionProcessor { | |
| val requestedTradeRepository: RequestedTradeRepository | |
| val priceMutators: Set[(RequestedTrade, BigDecimal) => BigDecimal] | |
| def process(requestId: String, executionPrice: BigDecimal): Option[ExecutedTrade] = | |
| for { | |
| requestedTrade <- requestedTradeRepository.findById(requestId) | |
| reportedPrice <- priceMutators.foldLeft(executionPrice)((price, mutator) => mutator(requestedTrade, price)).some | |
| } yield |
This file contains hidden or 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) |
This file contains hidden or 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 MonadicStyleNewOrderResolver extends NewOrderResolutionErrors { | |
| val symbolDao: SymbolDao | |
| val marketTakerDao: MarketTakerDao | |
| val marketMakerDao: MarketMakerDao | |
| def resolve(order: NewOrder): Validation[String, ResolvedNewOrder] = | |
| for { | |
| symbol <- symbolDao.findByName(order.symbolName) | |
| .toSuccess(UnknownSymbol) |
This file contains hidden or 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 JavaStyleNewOrderResolver extends NewOrderResolutionErrors { | |
| val symbolDao: SymbolDao | |
| val marketTakerDao: MarketTakerDao | |
| val marketMakerDao: MarketMakerDao | |
| def resolve(order: NewOrder): Either[String, ResolvedNewOrder] = { | |
| val symbol = symbolDao.findByName(order.symbolName) | |
| if (symbol.isEmpty) { | |
| return Left(UnknownSymbol) |