INNER CODE UNIT · Python

since

hadialaddin/crypto-genie · crypto-genie.py:1254

                            since = unixtime - 60 * interval * pagesize
                            response=session.query_kline(symbol=symbol, interval=str(interval), **{'from':since})['result']
                            df = pd.DataFrame(response)
                            break_direction = '' # Flag direction of break if any indicator was broken (used for executing Market Order Close)
                            limit_close_price_levels = [] # Used to store all price levels found for Limit Close Orders
                            market_close_price_levels = [] # Used to store all price levels found for Market Close Orders
                            for dynamic_level in elem[1].split(','): # Now we fetch the requested Dynamic Levels (indicators) for that interval
                                ordertype = dynamic_level.split('#')[1]
                                indicator = dynamic_level.split('#')[0].split('_')[0]
                                length = int(dynamic_level.split('#')[0].split('_')[1])
                                if indicator == 'ema':
                                    indicator_data = ta.ema(df['close'].astype(float, errors = 'raise'), length=length)
                                    if ordertype == 'Limit':
                                        if side == 'Buy' and 0 < (indicator_data.iloc[-1] - (indicator_data.iloc[-1] * (tp_dynamic_tolerance_ratio/100))) - entry_price < (entry_price * tp_dynamic_maximum_ratio/100):
                                            limit_close_price_levels.append(indicator_data.iloc[-1] - (indicator_data.iloc[-1] * (tp_dynamic_tolerance_ratio/100)))
                                        elif side == 'Sell' and 0 > (indicator_data.iloc[-1] + (indicator_data.iloc[-1] * (tp_dynamic_tolerance_ratio/100))) - entry_price > -1 * (entry_price * tp_dynamic_maximum_ratio/100):
                                            limit_close_price_levels.append(indicator_data.iloc[-1] + (indicator_data.iloc[-1] * (tp_dynamic_tolerance_ratio/100)))
                                    elif ordertype == 'Market':    

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…