def test_load_dataframe():
    df = poloniex.load_dataframe('ETH_BTC', 1800, days_history=30)
    assert len(df) > 0
    assert df.index[0] < df.index[-1]

    for val in ['close', 'high', 'low', 'open']:
        assert val in df.columns.values
        assert df.dtypes[val] == np.dtype('float64')
Beispiel #2
0
        'date': today['date'],
        'price': current_price,
        'rsi': rsi[-1],
    })


# Data settings
pair = "ETC_BTC"  # Use ETH pricing data on the BTC market
period = 300  # Use 1800 second candles
days_history = 30  # From there collect 60 days of data
RSI_OPEN = 55
RSI_DEVIATION = 10
RSI_PERIOD = 14

# Request data from Poloniex
df = px.load_dataframe(pair, period, days_history)

# Algorithm settings
sim_params = {
    'capital_base': 1,
    'data_frequency': '30T',
    'fee': {
        'Long': 0.0025,
        'Short': 0.0025,
    }
}

gemini = Gemini(logic=logic, sim_params=sim_params, analyze=None)

gemini.run(df)
Beispiel #3
0
def cmo_trading_strategy(gemini, data):
    if len(data) >= CMO_PERIOD:
        cmo = cmo_logic(data)
        assert -100 <= cmo <= 100

        if cmo < OVERSOLD_VALUE:
            gemini.account.close_position(position=gemini.account.positions[0],
                                          percent=1,
                                          price=data.iloc[-1]['low'])
        elif cmo > OVERBOUGHT_VALUE:
            gemini.account.enter_position(
                type_="Long",
                entry_capital=params['capital_base'] * 0.1,
                entry_price=data.iloc[-1]['high'])
        else:
            raise Exception


if __name__ == '__main__':
    data_df = poloniex.load_dataframe(pair=PAIR,
                                      period=PERIOD,
                                      days_history=DAYS_HISTORY)

    backtesting_engine = Gemini(logic=cmo_trading_strategy,
                                sim_params=params,
                                analyze=analyze.analyze_bokeh)
    backtesting_engine.run(data=data_df)

    print(data_df)