def current_direction(mark_price, klines): if HA_current.heikin_ashi(mark_price, klines) == "GREEN" and clear_movement(klines): return "GREEN" elif HA_current.heikin_ashi(mark_price, klines) == "RED" and clear_movement(klines): return "RED" else: return "INDECISIVE"
def lets_make_some_money(i): response = binance_futures_api.position_information(i) mark_price = binance_futures_api.mark_price(i) klines_1min = binance_futures_api.KLINE_INTERVAL_1MINUTE(i) klines_5min = binance_futures_api.KLINE_INTERVAL_5MINUTE(i) klines_1HOUR = binance_futures_api.KLINE_INTERVAL_1HOUR(i) position_info = get_position.get_position_info(i, response) profit_threshold = get_position.profit_threshold() HA_current.output(mark_price, klines_1HOUR) HA_current.output(mark_price, klines_5min) HA_current.output(mark_price, klines_1min) leverage = config.leverage[i] if int(response.get("leverage")) != leverage: binance_futures_api.change_leverage(i, leverage) if response.get('marginType') != "isolated": binance_futures_api.change_margin_to_ISOLATED(i) if not live_trade: backtest.trigger_backtest(i, mark_price, profit_threshold, klines_1min) if position_info == "LONGING": if place_order.EXIT_LONG(i, response, mark_price, profit_threshold, klines_1min): if live_trade: binance_futures_api.close_position(i, "LONG") print("ACTION : 💰 CLOSE_LONG 💰") else: print(colored("ACTION : HOLDING_LONG", "green")) elif position_info == "SHORTING": if place_order.EXIT_SHORT(i, response, mark_price, profit_threshold, klines_1min): if live_trade: binance_futures_api.close_position(i, "SHORT") print("ACTION : 💰 CLOSE_SHORT 💰") else: print(colored("ACTION : HOLDING_SHORT", "red")) else: if place_order.GO_LONG(mark_price, klines_1min, klines_5min, klines_1HOUR): OPEN_LONG_POSITION(i, mark_price) elif place_order.GO_SHORT(mark_price, klines_1min, klines_5min, klines_1HOUR): OPEN_SHORT_POSITION(i, mark_price) else: DO_NOTHING(i) print("Last action executed @ " + datetime.now().strftime("%H:%M:%S") + "\n")
def clear_movement(klines): return HA_current.candle_size(klines) > 2
import config import direction import HA_current import place_order import binance_futures_api for i in range(len(config.pair)): mark_price = binance_futures_api.mark_price(i) klines_1min = binance_futures_api.KLINE_INTERVAL_1MINUTE(i) klines_5min = binance_futures_api.KLINE_INTERVAL_5MINUTE(i) klines_15min = binance_futures_api.KLINE_INTERVAL_15MINUTE(i) klines_30MIN = binance_futures_api.KLINE_INTERVAL_30MINUTE(i) klines_1HOUR = binance_futures_api.KLINE_INTERVAL_1HOUR(i) klines_6HOUR = binance_futures_api.KLINE_INTERVAL_6HOUR(i) ching_cheng_chong = HA_current.war_formation(mark_price, klines_1min) current_trend = direction.current_direction(mark_price, klines_6HOUR) print("BIG CANDLE : " + str(HA_current.candlebody_bigger_than_previous_candle(klines_1HOUR))) print("SURPASS WICK : " + str(HA_current.candlebody_bigger_than_current_wick(klines_1HOUR))) print("1 HOUR : " + str(HA_current.heikin_ashi(mark_price, klines_1HOUR) == color)) print("5 MINUTE : " + str(HA_current.heikin_ashi(mark_price, klines_5min) == color)) print("1 MINUTE : " + str(HA_current.heikin_ashi(mark_price, klines_1min) == color)) print("WAR FORMATION : " + str(HA_current.war_formation(mark_price, klines_1min)))
def GO_SHORT(mark_price, klines_1min, klines_5min, klines_1HOUR): if HA_current.war_formation(mark_price, klines_1min) and \ HA_current.heikin_ashi(mark_price, klines_1min) == "RED" and \ HA_current.heikin_ashi(mark_price, klines_5min) == "RED" and \ HA_current.heikin_ashi(mark_price, klines_1HOUR) == "RED": return True
def THROTTLE_SHORT(i, response, mark_price, klines_6HOUR): if HA_current.heikin_ashi(mark_price, klines_6HOUR) == "RED" and \ get_position.get_positionSize(response) < (config.quantity[i] * 9) and \ -get_position.unrealizedPnL_Percentage(i, response, mark_price) < -throttle_threshold: return True
def GO_LONG(mark_price, klines_1min, klines_5min, klines_1HOUR): if HA_current.war_formation(mark_price, klines_1min) and \ HA_current.heikin_ashi(mark_price, klines_1min) == "GREEN" and \ HA_current.heikin_ashi(mark_price, klines_5min) == "GREEN" and \ HA_current.heikin_ashi(mark_price, klines_1HOUR) == "GREEN": return True