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

[r2r] enhanced logging in spv and rpc_client mods #1594

Merged
merged 14 commits into from
Jan 13, 2023

Conversation

borngraced
Copy link
Member

fixes: #1481

Signed-off-by: borngraced samiodev@icloud.com

Signed-off-by: borngraced <samiodev@icloud.com>
@borngraced borngraced self-assigned this Jan 2, 2023
@borngraced borngraced changed the title enhanced logging in spv and rpc_client mods [r2r] enhanced logging in spv and rpc_client mods Jan 2, 2023
Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

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

Awesome! I have only one minor suggestion

@sergeyboyko0791 sergeyboyko0791 linked an issue Jan 2, 2023 that may be closed by this pull request
Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes! Please consider my comments

@@ -518,7 +545,14 @@ async fn update_single_order(
let resp = update_maker_order(ctx, req)
.await
.map_to_mm(OrderProcessingError::OrderUpdateError)?;
info!("Successfully update order for {} - uuid: {}", key_trade_pair, resp.uuid);
let (volume, _) = calculate_volume(ctx, &cfg, Some(&base_balance), &rates.base_price).await?;

Choose a reason for hiding this comment

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

We can reuse the volume returning from prepare_order function:

- let (min_vol, _, calculated_price, is_max, base_balance) = prepare_order(rates, &cfg, &key_trade_pair, ctx).await?;
+ let (min_vol, volume, calculated_price, is_max, base_balance) = prepare_order(rates, &cfg, &key_trade_pair, ctx).await?;

Copy link
Member Author

Choose a reason for hiding this comment

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

yh thanks

Comment on lines 472 to 476
//async fn prepare_order(cfg) {
// let mut is_max = cfg.max.unwrap_or(false);
// let (vol, is_max) = calculate_volume(ctx, cfg, base_balance, price).await?;
// let is_max = cfg.max.unwrap_or_default() | is_max;
//}

Choose a reason for hiding this comment

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

This can be removed

@@ -491,21 +518,21 @@ async fn prepare_order(
None => None,
};

Ok((min_vol, volume, calculated_price, is_max))
Ok((min_vol, volume, calculated_price, is_max, base_balance))

Choose a reason for hiding this comment

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

I believe that after these changes:

- let (min_vol, _, calculated_price, is_max, base_balance) = prepare_order(rates, &cfg, &key_trade_pair, ctx).await?;
+ let (min_vol, volume, calculated_price, is_max, base_balance) = prepare_order(rates, &cfg, &key_trade_pair, ctx).await?;

the base_balance is no longed required to be returned from prepare_order

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Signed-off-by: borngraced <samiodev@icloud.com>
Signed-off-by: borngraced <samiodev@icloud.com>
Signed-off-by: borngraced <samiodev@icloud.com>
sergeyboyko0791
sergeyboyko0791 previously approved these changes Jan 3, 2023
Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@sergeyboyko0791
Copy link

@smk762 could you please check if this extends the logs as you asked at #1481

@smk762
Copy link

smk762 commented Jan 3, 2023

I see

03 15:37:20, simple_market_maker:577] INFO Successfully placed order for LTC-KMD - uuid: 0aa2e82c-0e09-4520-b727-c6b7a021f2bf - rate: (403.5584 LTC-KMD) - volume 0
03 15:37:21, simple_market_maker:577] INFO Successfully placed order for KMD-LTC - uuid: 41a73431-dc82-40dd-bbb6-1a8854a649a0 - rate: (0.0025 KMD-LTC) - volume 0

and in my_orders

"price": "0.002567964983164983164983164983164983164983164983164983164983164983164983164983164983164983164983164983",
"available_amount": "5.00490775"

"price": "403.5584623598505072076882007474639615589962626801922050186865990389749065670048051254671649759743727",
"available_amount": "0.20379761"

Seems volume not calculated, as logs show zero. Can we please extend the logs to 8 decimal places?

Signed-off-by: borngraced <samiodev@icloud.com>
@borngraced
Copy link
Member Author

I see

03 15:37:20, simple_market_maker:577] INFO Successfully placed order for LTC-KMD - uuid: 0aa2e82c-0e09-4520-b727-c6b7a021f2bf - rate: (403.5584 LTC-KMD) - volume 0
03 15:37:21, simple_market_maker:577] INFO Successfully placed order for KMD-LTC - uuid: 41a73431-dc82-40dd-bbb6-1a8854a649a0 - rate: (0.0025 KMD-LTC) - volume 0

and in my_orders

"price": "0.002567964983164983164983164983164983164983164983164983164983164983164983164983164983164983164983164983", "available_amount": "5.00490775"

"price": "403.5584623598505072076882007474639615589962626801922050186865990389749065670048051254671649759743727", "available_amount": "0.20379761"

Seems volume not calculated, as logs show zero. Can we please extend the logs to 8 decimal places?

@smk762 this is ready for another round of test..

@smk762
Copy link

smk762 commented Jan 4, 2023

Thanks, I see extra decimals now

04 06:16:56, simple_market_maker:576] INFO Successfully placed order for LTC-KMD - uuid: a09e210e-f5f9-48de-9a8c-586acc703010 - rate: (414.88914893 LTC-KMD) - volume 0
04 06:16:58, simple_market_maker:576] INFO Successfully placed order for KMD-LTC - uuid: 22210f77-ac77-4d19-ab05-bc4c8c65acaf - rate: (0.00249783 KMD-LTC) - volume 0

Volume still zero tho

@borngraced borngraced changed the title [r2r] enhanced logging in spv and rpc_client mods [wip] enhanced logging in spv and rpc_client mods Jan 5, 2023
Signed-off-by: borngraced <samiodev@icloud.com>
@borngraced borngraced changed the title [wip] enhanced logging in spv and rpc_client mods [r2r] enhanced logging in spv and rpc_client mods Jan 5, 2023
@borngraced
Copy link
Member Author

@smk762, if max: true, we can't print a correct volume as it's calculated later outside of the market bot context, So I guess the behavior is normal in this case as you set max to be true in your config.

PS. I handled this case to print "max volume" instead of volume in the log

@smk762
Copy link

smk762 commented Jan 5, 2023

Cheers, here's latest logs with config change to not be max: true

05 12:37:10, simple_market_maker:591] INFO Successfully placed order for LTC-KMD - uuid: 26647352-fe5a-4bf5-940a-1602f18b02a5 - rate: (407.63481046 LTC-KMD) - volume 0.06666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667
05 12:37:11, simple_market_maker:585] INFO Successfully update order for KMD-LTC - uuid: 05780fcd-e9e7-4f53-8b96-025db434550b - rate: (0.00254228 KMD-LTC) - max volume

Could we please likewise limit the volume to 8 decimal places?

Signed-off-by: borngraced <samiodev@icloud.com>
@borngraced
Copy link
Member Author

Cheers, here's latest logs with config change to not be max: true

05 12:37:10, simple_market_maker:591] INFO Successfully placed order for LTC-KMD - uuid: 26647352-fe5a-4bf5-940a-1602f18b02a5 - rate: (407.63481046 LTC-KMD) - volume 0.06666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667
05 12:37:11, simple_market_maker:585] INFO Successfully update order for KMD-LTC - uuid: 05780fcd-e9e7-4f53-8b96-025db434550b - rate: (0.00254228 KMD-LTC) - max volume

Could we please likewise limit the volume to 8 decimal places?

all done now.. @smk762

@smk762 smk762 self-requested a review January 5, 2023 13:17
smk762
smk762 previously approved these changes Jan 5, 2023
Copy link

@smk762 smk762 left a comment

Choose a reason for hiding this comment

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

Thanks, log output is now nice and clean and informative

05 13:17:13, simple_market_maker:592] INFO Successfully placed order for LTC-KMD - uuid: a69504ed-7ae1-4ea2-9918-0a23c8de6750 - rate: (406.00490928 LTC-KMD) - volume: 0.06689858
05 13:17:15, simple_market_maker:586] INFO Successfully update order for KMD-LTC - uuid: 27997929-260b-4be4-b024-1aa8a39041be - rate: (0.00255249 KMD-LTC) - max volume

Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

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

A few more changes please

Comment on lines 519 to 525
if is_max {
info!(
"Successfully update order for {key_trade_pair} - uuid: {} - rate: ({:.8} {key_trade_pair}) - max volume",
resp.uuid,
calculated_price.to_decimal()
);
} else {

Choose a reason for hiding this comment

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

Could you please refactor this as

let vol_info = if is_max {
    "max volume".to_string()
} else {
    format!("volume: {:.8}", volume.to_decimal())
};
info!("Successfully update order for {key_trade_pair} - uuid: {} - rate: ({:.8} {key_trade_pair}) - {vol_info}", resp.uuid, calculated_price.to_decimal());

Copy link
Member Author

Choose a reason for hiding this comment

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

is this really needed? done anyways

Choose a reason for hiding this comment

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

Do you think the changed version looks more clear and readable?
It also helped to to shorten by 4 lines

Comment on lines 585 to 590
if is_max {
info!(
"Successfully update order for {key_trade_pair} - uuid: {} - rate: ({:.8} {key_trade_pair}) - max volume",
resp.uuid,
calculated_price.to_decimal()
);

Choose a reason for hiding this comment

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

The same here please

mm2src/mm2_main/src/lp_ordermatch/simple_market_maker.rs Outdated Show resolved Hide resolved
mm2src/mm2_main/src/lp_ordermatch/simple_market_maker.rs Outdated Show resolved Hide resolved
mm2src/mm2_main/src/lp_ordermatch/simple_market_maker.rs Outdated Show resolved Hide resolved
Signed-off-by: borngraced <samiodev@icloud.com>
sergeyboyko0791
sergeyboyko0791 previously approved these changes Jan 6, 2023
Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM!

@smk762 smk762 self-requested a review January 6, 2023 16:05
smk762
smk762 previously approved these changes Jan 6, 2023
@sergeyboyko0791
Copy link

@shamardy could you please also take a look?

Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

Only one suggestion :)

mm2src/coins/utxo/rpc_clients.rs Outdated Show resolved Hide resolved
Signed-off-by: borngraced <samiodev@icloud.com>
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

Just a small change!

Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes!

Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

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

Re-approve

@sergeyboyko0791 sergeyboyko0791 merged commit 11194fe into dev Jan 13, 2023
@sergeyboyko0791 sergeyboyko0791 deleted the loggin-enhancements branch January 13, 2023 14:48
@borngraced borngraced mentioned this pull request Feb 17, 2023
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.

[FR] Logging enhancements
4 participants