INNER CODE UNIT · Python
close_positions
liamhartley/cryptotradingbot · trading_strategies/poloniex_cmo_trading_strategy/app/app.py:8
def close_positions(poloniex_wrapper, pair, rate, amount):
'''
:param currency_pair: A string that defines the market, "USDT_BTC" for example.
:param rate: The price. Units are market quote currency. Eg USDT_BTC market, the value of this field would be around 10,000. Naturally this will be dated quickly but should give the idea.
:param amount: The total amount offered in this buy order.
:return:
'''
print('closing position')
print(f'entry_amount: {amount}')
print(f'rate: {rate}')
print(f'ticker: {pair}')
# base_currency = LOGICAL_PARAMS['PAIR'].split('_')[0]
quote_currency = LOGICAL_PARAMS['PAIR'].split('_')[1]
# if we have any of our quote_currency
if float(poloniex_wrapper.private_query(command='returnBalances')[quote_currency]) > 0 and LOGICAL_PARAMS["DRY_RUN"] is False: