Issue
I'm trying to work on a project and I have a code but it's written in python 2.X I'm currently working on Python 3.X and when i try to
X= abs(int(f'fractionfactor:e'.split('e')[-1]))
in Python 2.X the result of .split will send back just the decimal part for exemple int(str(5/2)) will give me in return "2" but in python 3.X i'll get "2.5" for the same code here is the full part i'm currently stuck in
def format_value(valuetoformatx, fractionfactorx):
value= valuetoformatx
fractionfactor= fractionfactorx
Precision= abs(int(f'fractionfactor:e'.split('e')[-1]))
FormattedValue= float(':0.0{}f'.format(value,Precision))
return FormattedValue
def parPriceinfo(ticker,client):
info= client.get_symbol_info(ticker)
minPrice= pd.to_numeric(info['filters'][0]["minPrice"])
return minPrice
def pairQtyinfo(ticker,client):
info= client.get_symbol_info(ticker)
minQty= pd.to_numeric(info['filters'][2]['minQty'])
return minQty
error:
invalid literal for int() with base 10: ''
I hope that i've provided enough information. thanks in advance !
Solution
In an f-string, you need to put {}
around the variable to format and the format expression.
Precision= abs(int(f'fractionfactor:e'.split('e')[-1]))
should be
Precision= abs(int(f'{fractionfactor:e}'.split('e')[-1]))
Answered By - Barmar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.