Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
VladKochetov007 committed Nov 23, 2021
1 parent ec2eac3 commit 4fdefec
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
16 changes: 12 additions & 4 deletions quick_trade/brokers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,16 @@ def order_create(self,
ticker: str = 'None',
quantity: float = 0.0,
counting: bool = True):
utils.logger.info('quantity: %f, side: %s, ticker: %s', quantity, side,
ticker)
quote = ticker.split('/')[1]
base = ticker.split('/')[0]
utils.logger.info('quantity: %f, side: %s, ticker: %s, balance: %f%s (%f%s)',
quantity,
side,
ticker,
self.get_balance(quote),
quote,
self.get_balance(quote)/self.get_ticker_price(ticker),
base)
if quantity != 0:
if quantity < 0:
side = 'Buy' if side == 'Sell' else 'Sell'
Expand All @@ -35,8 +43,8 @@ def order_create(self,
self.__side__ = side
self.ticker = ticker
self.__quantity__ = quantity
self.base = ticker.split('/')[0]
self.quote = ticker.split('/')[1]
self.base = base
self.quote = quote
self.ordered = True
if counting:
self._add_order_count()
Expand Down
12 changes: 6 additions & 6 deletions quick_trade/trading_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ def get_trading_predict(self,
:return: dict with prediction
"""

_moneys_: float
moneys: float
bet: Union[float, int]
close: np.ndarray = self.df["Close"].values
open_new_order: bool
Expand All @@ -773,7 +773,7 @@ def get_trading_predict(self,
conv_cred_lev = utils.convert(self._credit_leverages)

if self._entry_start_trade:
open_new_order = predict != self._prev_predict
open_new_order = predict != self._prev_predict or not np.isnan(conv_cred_lev[-1])
else:
open_new_order = (not np.isnan(self._converted[-1])) or (not np.isnan(conv_cred_lev[-1]))

Expand All @@ -786,14 +786,14 @@ def get_trading_predict(self,
self.__exit_order__ = True

else:
_moneys_ = self.client.get_balance(self.ticker.split('/')[1])
moneys = self.client.get_balance(self.ticker.split('/')[1])
ticker_price = self.client.get_ticker_price(self.ticker)
if bet_for_trading_on_client is not np.inf:
bet = bet_for_trading_on_client
else:
bet = _moneys_
if bet > _moneys_:
bet = _moneys_
bet = moneys
if bet > moneys:
bet = moneys
bet /= ticker_price

self.client.exit_last_order() # exit from previous trade (signal)
Expand Down
2 changes: 1 addition & 1 deletion quick_trade/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
calmar ratio: {}
max drawdown: {}%""" # .format(Trader.losses, Trader.trades, ...)

__version__: str = "7.0.0"
__version__: str = "7.0.1"
__author__: str = 'Vlad Kochetov'
__credits__: List[str] = [
"Hemerson Tacon -- Stack overflow",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
with open('README.md') as file:
long_desc = file.read()

__version__ = "7.0.0"
__version__ = "7.0.1"

setup(
name='quick_trade',
Expand Down

0 comments on commit 4fdefec

Please sign in to comment.