Beispiel #1
0
        for position in algo.account.positions:
            if position.type_ == 'Long':
                algo.account.close_position(position, 1, exit_price)

    if today['close'] > yesterday['close']:
        entry_capital = algo.account.buying_power
        if entry_capital > 0.0001:
            algo.account.enter_position('Long', entry_capital, today['close'])


# Data settings
pair = ['ETH', 'BTC']  # Use ETH pricing data on the BTC market
days_history = 360  # From there collect X days of data
exchange = 'Bitfinex'

# Request data from cryptocompare.com
df = cc.load_dataframe(pair, days_history, exchange)

# Algorithm settings
sim_params = {
    'capital_base': 1000,
    'fee': {
        'Long': 0.0025 + 0.001,  # fee + spread
        'Short': 0.0025 + 0.001,
    }
}
r = Gemini(logic=logic, sim_params=sim_params, analyze=analyze_mpl)

# start backtesting custom logic with 1000 (BTC) intital capital
r.run(df, title='History: {}'.format(days_history), show_trades=True)
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
######

######
# get data from file stored on disk
start_date = '2017-01-04 0:00:00'
end_date = '2017-12-31 23:59:59'
base_currency = 'BTC'
other_currency = 'XRP'
frequency = '1D'

df = get_historical_data_from_file(base_currency, other_currency, frequency, start_date, end_date)


########

# Algorithm settings
sim_params = {
    'capital_base': 10,      # initial capital in BTC
    'fee': {
        'Long': 0.0015,      # fee settings for Long
        'Short': 0.0015,     # fee settings for Short
    },
    'data_frequency': '1D'    # Time frame to use (see /helpers/timeframe_resampler.py for more info
}
gemini = Gemini(logic=logic, sim_params=sim_params, analyze=analyze_bokeh)

# start backtesting custom logic with 10 (BTC) intital capital
gemini.run(df, show_trades=True)

Beispiel #4
0
    elif today['close'] > yesterday['close']:
        risk = 0.03
        entry_price = today['close']
        entry_capital = algo.account.buying_power * risk
        if entry_capital >= 0.00001:
            algo.account.enter_position('Long', entry_capital, entry_price)


# Data settings
pair = "ETH_BTC"  # Use ETH pricing data on the BTC market
period = 1800  # Use 1800 second candles
days_history = 60  # Collect 60 days data

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

# Algorithm settings
sim_params = {
    'capital_base': 10,  # initial capital in BTC
    'fee': {
        'Long': 0.0015,  # fee settings for Long
        'Short': 0.0015,  # fee settings for Short
    },
    'data_frequency':
    '4H'  # Time frame to use (see /helpers/timeframe_resampler.py for more info
}
gemini = Gemini(logic=logic, sim_params=sim_params, analyze=analyze_bokeh)

# start backtesting custom logic with 10 (BTC) intital capital
gemini.run(df, show_trades=False)
Beispiel #5
0
        'long': long[-1],
    })


# Data settings
pair = "ETH_BTC"  # Use ETH pricing data on the BTC market
period = 1800  # Use 1800 second candles
days_history = 300  # From there collect 60 days of data

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

# Algorithm settings
sim_params = {
    'capital_base': 10,
    'fee': {
        'Long': 0.0025,
        'Short': 0.0025,
    },
    'data_frequency': '30T'
}
gemini = Gemini(initialize=initialize,
                logic=logic,
                sim_params=sim_params,
                analyze=analyze_bokeh)

# start backtesting custom logic with 10 (BTC) intital capital
gemini.run(df,
           title='SMA Cross {}: {}'.format(pair, days_history),
           show_trades=True)
Beispiel #6
0
    algo.records.append({
        'date': algo.account.date,
        'price': current_price,
        'sma20': short[-1],
        'sma100': long[-1],
    })


pair = ['BTC', 'USD']  # Use ETH pricing data on the BTC market
days_history = 300  # From there collect X days of data
exchange = 'Bitstamp'

# Request data from cryptocompare.com
df = cc.load_dataframe(pair, days_history, exchange)

# Algorithm settings
sim_params = {
    'capital_base': 10000,
    'fee': {
        'Long': 0.0025 + 0.001,  # fee + spread
        'Short': 0.0025 + 0.001,
    }
}
gemini = Gemini(logic=logic, sim_params=sim_params, analyze=analyze_bokeh)

# start backtesting custom logic with 1000 (BTC) intital capital
gemini.run(df,
           title='SMA 5x30 History: {}'.format(days_history),
           show_trades=True)
        'price': current_price,
        'short': short[-1],
        'long': long[-1],
    })


# Data settings
pair = "BCH_BTC"  # Use ETH pricing data on the BTC market
period = 1800  # Use 1800 second candles
days_history = 200  # From there collect 60 days of data

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

# Algorithm settings
sim_params = {
    'capital_base': 10,
    'fee': {
        'Long': 0.0015,
        'Short': 0.0015,
    },
    'data_frequency': '2H'
}
gemini = Gemini(initialize=initialize,
                logic=logic,
                sim_params=sim_params,
                analyze=analyze_bokeh)
gemini.run(df,
           title='EMA 5x30 {}: {}'.format(pair, days_history),
           show_trades=True)