-
Notifications
You must be signed in to change notification settings - Fork 20
Sourcery refactored master branch #5
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,8 +87,6 @@ def main(): | |
parameter['upper']): | ||
trade.sell() | ||
break | ||
else: | ||
pass | ||
except KeyboardInterrupt: | ||
quit() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,9 +89,6 @@ def compute_profit(params): | |
logger.info('\tPeriod: ' + str(params['period'])) | ||
logger.info('\tLower threshold: ' + str(params['lower'])) | ||
logger.info('\tUpper threshold: ' + str(params['upper'])) | ||
else: | ||
pass | ||
|
||
Comment on lines
-92
to
-94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
data = self.__compute_indicator( | ||
period=params['period'], | ||
lower=params['lower'], | ||
|
@@ -185,10 +182,8 @@ def indicator(self): | |
# refresh candlestick | ||
self.ohlcv = self.__fetch_ohlcv() | ||
|
||
# compute signal with best parameter | ||
data = self.__compute_indicator( | ||
return self.__compute_indicator( | ||
period=self.setting['parameter']['period'], | ||
lower=self.setting['parameter']['lower'], | ||
upper=self.setting['parameter']['upper']) | ||
|
||
return data | ||
upper=self.setting['parameter']['upper'], | ||
) | ||
Comment on lines
-188
to
+189
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ):
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,11 +62,31 @@ def amount(x): | |
price = self.__buy_price | ||
|
||
try: | ||
logger.info('Attempt to buy ' + target + ' @ ' + | ||
'{0:.8f}'.format(price) + ' ' + base) | ||
|
||
self.__notify('Attempt to BUY ' + target + ' @ ' + | ||
'{0:.8f}'.format(price) + ' ' + base) | ||
logger.info( | ||
( | ||
( | ||
( | ||
f'Attempt to buy {target} @ ' | ||
+ '{0:.8f}'.format(price) | ||
) | ||
+ ' ' | ||
) | ||
+ base | ||
) | ||
) | ||
|
||
self.__notify( | ||
( | ||
( | ||
( | ||
f'Attempt to BUY {target} @ ' | ||
+ '{0:.8f}'.format(price) | ||
) | ||
+ ' ' | ||
) | ||
+ base | ||
) | ||
) | ||
Comment on lines
-65
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
left = self.funds | ||
order = auth.create_limit_buy_order(self.pair, | ||
|
@@ -81,7 +101,7 @@ def amount(x): | |
|
||
remaining = order_status['remaining'] | ||
left = abs(left - order_status['cost']) | ||
logger.info('Remaining: ' + str(remaining)) | ||
logger.info(f'Remaining: {str(remaining)}') | ||
|
||
if (remaining != 0.0 or remaining != 0): | ||
logger.info('Buy order was partially filled') | ||
|
@@ -93,22 +113,42 @@ def amount(x): | |
|
||
price = self.__buy_price | ||
|
||
logger.info('Attempt to buy ' + target + ' @ ' + | ||
'{0:.8f}'.format(price) + ' ' + base) | ||
logger.info( | ||
( | ||
( | ||
( | ||
f'Attempt to buy {target} @ ' | ||
+ '{0:.8f}'.format(price) | ||
) | ||
+ ' ' | ||
) | ||
+ base | ||
) | ||
) | ||
|
||
order = auth.create_limit_buy_order( | ||
order_status['symbol'], amount(left), price) | ||
elif (remaining == 0.0 or remaining == 0): | ||
logger.info('Successfully bought ' + target) | ||
self.__notify('Successfully bought ' + target + ' @ ' + | ||
'{0:.8f}'.format(price) + ' ' + base) | ||
elif remaining in [0.0, 0]: | ||
logger.info(f'Successfully bought {target}') | ||
self.__notify( | ||
( | ||
( | ||
( | ||
f'Successfully bought {target} @ ' | ||
+ '{0:.8f}'.format(price) | ||
) | ||
+ ' ' | ||
) | ||
+ base | ||
) | ||
) | ||
break | ||
|
||
sleep(self.refreshrate) | ||
except (ccxt.InvalidOrder, ccxt.InsufficientFunds): | ||
logger.info('Invalid order or quantity') | ||
logger.info('Funds: ' + str(self.funds)) | ||
logger.info('Amount: ' + str(amount(self.funds))) | ||
logger.info(f'Funds: {str(self.funds)}') | ||
logger.info(f'Amount: {str(amount(self.funds))}') | ||
except Exception as e: | ||
logger.exception(e) | ||
|
||
|
@@ -132,11 +172,31 @@ def balance(): | |
price = self.__sell_price | ||
|
||
try: | ||
logger.info('Attempt to sell ' + target + ' @ ' + | ||
'{0:.8f}'.format(price) + ' ' + base) | ||
|
||
self.__notify('Attempt to SELL ' + target + ' @ ' + | ||
'{0:.8f}'.format(price) + ' ' + base) | ||
logger.info( | ||
( | ||
( | ||
( | ||
f'Attempt to sell {target} @ ' | ||
+ '{0:.8f}'.format(price) | ||
) | ||
+ ' ' | ||
) | ||
+ base | ||
) | ||
) | ||
|
||
self.__notify( | ||
( | ||
( | ||
( | ||
f'Attempt to SELL {target} @ ' | ||
+ '{0:.8f}'.format(price) | ||
) | ||
+ ' ' | ||
) | ||
+ base | ||
) | ||
) | ||
Comment on lines
-135
to
+199
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
order = auth.create_limit_sell_order(self.pair, balance(), | ||
price) | ||
|
@@ -150,7 +210,7 @@ def balance(): | |
id=order_id, symbol=self.pair) | ||
|
||
remaining = order_status['remaining'] | ||
logger.info('Remaining: ' + str(remaining)) | ||
logger.info(f'Remaining: {str(remaining)}') | ||
|
||
if remaining != 0.0 or remaining != 0: | ||
logger.info('Sell order was partially filled') | ||
|
@@ -159,20 +219,40 @@ def balance(): | |
|
||
price = self.__sell_price | ||
|
||
logger.info('Attempt to sell ' + target + ' @ ' + | ||
'{0:.8f}'.format(price) + ' ' + base) | ||
logger.info( | ||
( | ||
( | ||
( | ||
f'Attempt to sell {target} @ ' | ||
+ '{0:.8f}'.format(price) | ||
) | ||
+ ' ' | ||
) | ||
+ base | ||
) | ||
) | ||
|
||
order = auth.create_limit_sell_order( | ||
self.pair, balance(), price) | ||
elif remaining == 0.0 or remaining == 0: | ||
logger.info('Successfully sold ' + target) | ||
self.__notify('Successfully sold ' + target + ' @ ' + | ||
'{0:.8f}'.format(price) + ' ' + base) | ||
elif remaining in [0.0, 0]: | ||
logger.info(f'Successfully sold {target}') | ||
self.__notify( | ||
( | ||
( | ||
( | ||
f'Successfully sold {target} @ ' | ||
+ '{0:.8f}'.format(price) | ||
) | ||
+ ' ' | ||
) | ||
+ base | ||
) | ||
) | ||
break | ||
|
||
sleep(self.refreshrate) | ||
except (ccxt.InvalidOrder, ccxt.InsufficientFunds): | ||
logger.info('Invalid order or quantity') | ||
logger.info('Balance: ' + str(balance())) | ||
logger.info(f'Balance: {str(balance())}') | ||
except Exception as e: | ||
logger.exception(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
main
refactored with the following changes:remove-redundant-pass
)