You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have one suggestion to improve it a bit. It would be nice to use decimal instead of the float builtin type to avoid rounding and precision errors or at least provide additional methods to provide BTC and fiat values as Decimal. I implemented a hackish decimal conversion in a helper class for a custom strategy but having it directly in goxapi would be nicer.
The text was updated successfully, but these errors were encountered:
classFormatterMixin(object):
""" Mixin to format BTC and fiat currency values and timestamps. """defbase_to_decimal(self, value):
""" Convert an int BTC value to a Decimal BTC value. """returnDecimal(value) /Decimal(self.gox.mult_base)
defdecimal_to_base(self, value):
""" Convert a Decimal BTC value to an int BTC value. """returnint(value*Decimal(self.gox.mult_base))
defquote_to_decimal(self, value):
""" Convert an int fiat value to a Decimal fiat value. """returnDecimal(value) /Decimal(self.gox.mult_quote)
defdecimal_to_quote(self, value):
""" Convert a Decimal fiat value to an int fiat value. """returnint(value*Decimal(self.gox.mult_quote))
defformat_base(self, value):
""" Format a base (BTC) value. """return"{0:0.8f} BTC".format(self.base_to_decimal(value))
defformat_quote(self, value):
""" Format a value in quote (fiat) currency. """return"{0:0.5f} {1}".format(
self.quote_to_decimal(value),
self.gox.currency)
defformat_time(self, tvalue):
""" Format an integer time value. """returntime.strftime(
"%Y-%m-%d %H:%M:%S", time.localtime(tvalue))
A class using this mixin needs a goxapi instance in self.gox.
Hello, first thanks a lot for goxtool.
I have one suggestion to improve it a bit. It would be nice to use decimal instead of the float builtin type to avoid rounding and precision errors or at least provide additional methods to provide BTC and fiat values as Decimal. I implemented a hackish decimal conversion in a helper class for a custom strategy but having it directly in goxapi would be nicer.
The text was updated successfully, but these errors were encountered: