Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LWDEV-10476 Pre-trade control: configurable max value and calculated max volume #266

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

barsukovskii
Copy link
Contributor

No description provided.

# Conflicts:
#	src/main/kotlin/com/lykke/matching/engine/matching/MatchingEngine.kt
#	src/main/kotlin/com/lykke/matching/engine/services/AssetOrderBook.kt
#	src/test/kotlin/com/lykke/matching/engine/services/validator/business/LimitOrderBusinessValidatorTest.kt
@@ -11,7 +11,6 @@
private int accuracy;
private Double minVolume;
private Double minInvertedVolume;
private Double maxVolume;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there option to configure max volume on back office ? if yes - we should create a ticket to remove it. Also, maybe we should perform dictionary table cleanup - remove unused max volume column?

@@ -27,5 +29,20 @@ class OrderValidationUtils {
throw OrderValidationException(OrderStatus.Cancelled, "expired")
}
}

fun validateMaxVolume(order: Order,
assetPair: AssetPair,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format

}
}

fun calculateMaxVolume(assetPair: AssetPair, orderBook: AssetOrderBook): MaxOrderVolumeInfo? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we have to pass order book and asset pair? mid price and max value enough

}

private fun performInputValidation(orderContext: LimitOrderExecutionContext): OrderValidationResult {
private fun performInputValidation(orderContext: LimitOrderExecutionContext,
assetPair: AssetPair?): OrderValidationResult {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why asset pair is moved to the parameter ?

@@ -47,6 +48,13 @@ open class AssetOrderBook(assetId: String) : AbstractAssetOrderBook(assetId) {
fun getAskPrice() = askOrderBook.peek()?.price ?: BigDecimal.ZERO
fun getBidPrice() = bidOrderBook.peek()?.price ?: BigDecimal.ZERO

fun getMidPrice(): BigDecimal? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test for this method

assetPair: AssetPair,
orderBook: AssetOrderBook) {
val maxVolumeInfo = calculateMaxVolume(assetPair, orderBook) ?: return
if (order.getAbsVolume() > maxVolumeInfo.maxVolume) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not >=

@olpapchenko
Copy link
Contributor

Not sure on limit orders - what if

  1. Input limit order (A) passes validation - set to order book
  2. Mid Price is changing
  3. Limit order(A) is in the order book and has invalid - too big volume according to the current mid price

# Conflicts:
#	src/main/kotlin/com/lykke/matching/engine/order/process/StopLimitOrderProcessor.kt
#	src/main/kotlin/com/lykke/matching/engine/services/validators/business/StopOrderBusinessValidator.kt
#	src/main/kotlin/com/lykke/matching/engine/services/validators/business/impl/LimitOrderBusinessValidatorImpl.kt
#	src/main/kotlin/com/lykke/matching/engine/services/validators/business/impl/StopOrderBusinessValidatorImpl.kt
#	src/main/kotlin/com/lykke/matching/engine/services/validators/common/OrderValidationUtils.kt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants