I'll accumulate in this issue, all the good tips from Leandro.
Since there's MANY waterfall PRs and approved with nits and comments, I'll make this issue so I merge all and then address the suggested comments :)
1. Use var for price:
Nit: I would put the prices into their own variables and simplify the string building to something like:
price = format_price(
calculate_price(
numerator=boughtVolume,
denominator=soldVolume,
decimals_numerator=buyTokenDecimals,
decimals_denominator=sellTokenDecimals
),
currency=buyTokenLabel
)
priceStr1 = f'{click.style(f' Avg. Traded Price {sellTokenLabel}/{buyTokenLabel}', fg=labelColor)}: {price1}'
...
tradePriceText = f'{priceStr1}\n{priceStr2}\n'
#32 (comment)
2. Max sell volume, max receiving amount
Would it be too much to also add the order size? Meaning, max buy/sell amounts, not just the matched amounts.
#32 (comment)
3. Use f strings for formatting numbers
def format_integer(number):
return str(number) # TODO: Format better the numbers
return '{:,d}'.format(number)
Also in:
return f'{{:,.{decimals}f}}'.format(rounded_value).rstrip('0').rstrip('.')
Also in:
return format_amount(percentage, decimals=2) + '%'
#34 (comment)
4. Unreachable code in calculate_price
#32 (comment)
5 Simplify expression
6. Improve sorting
7. Use snake case for vars
Not comment from leandro, but I saw it now :)
isUnlimitedAmount
8. Improve for comprehension
Python magic 🌟
I'll accumulate in this issue, all the good tips from Leandro.
Since there's MANY waterfall PRs and approved with nits and comments, I'll make this issue so I merge all and then address the suggested comments :)
1. Use var for price:
Nit: I would put the prices into their own variables and simplify the string building to something like:
#32 (comment)
2. Max sell volume, max receiving amount
Would it be too much to also add the order size? Meaning, max buy/sell amounts, not just the matched amounts.
#32 (comment)
3. Use f strings for formatting numbers
def format_integer(number):
return str(number) # TODO: Format better the numbers
return '{:,d}'.format(number)
Also in:
Also in:
return format_amount(percentage, decimals=2) + '%'#34 (comment)
4. Unreachable code in
calculate_price#32 (comment)
5 Simplify expression
Orders command #32 (comment)
6. Improve sorting
Can you enforce the option only accepts asc or desc?
What happens if something else is input?
Improve sorting #33 (comment)
7. Use snake case for vars
Not comment from leandro, but I saw it now :)
isUnlimitedAmount8. Improve for comprehension
Python magic 🌟
Done? This:
Generate automatically the filter expression #37 (comment)
Done? And this:
Generate automatically the filter expression #37 (comment)