Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more then 2 entries #662

Open
rafalsza opened this issue Oct 29, 2023 · 1 comment
Open

more then 2 entries #662

rafalsza opened this issue Oct 29, 2023 · 1 comment

Comments

@rafalsza
Copy link

is it possible to pass more then 2 entries? when Im running this script I have timeout

import pandas as pd
import vectorbt as vbt
from vectorbt.portfolio.enums import SizeType
import numpy as np


def wavetrend(high, low, close, n1, n2, os, ob):
    ap = (high + low + close) / 3.0  # HLC3
    ap = pd.DataFrame(ap)
    esa = ap.ewm(span=n1, adjust=False).mean()  # EMA
    d = (abs(ap - esa)).ewm(span=n1, adjust=False).mean()
    ci = (ap - esa) / (0.015 * d)
    wt1 = ci.ewm(span=n2, adjust=False).mean()
    wt2 = wt1.rolling(4).mean()
    trend = np.where(wt1 < os, -1, 0)
    trend = np.where(wt1 > ob, 1, trend)
    return wt1, wt2, trend


Wavetrend = vbt.IndicatorFactory(
    class_name="Wavetrend",
    short_name="wt",
    input_names=["high", "low", "close"],
    param_names=["n1", "n2", "os", "ob"],
    output_names=["wt1", "wt2", "trend"],
).from_apply_func(wavetrend)

symbol = "BTCUSDT"
interval = "1h"
start = "1 month ago UTC"
# start = '2021-05-10'
df = vbt.BinanceData.download(symbol, start=start, interval=interval).get()


high = df["High"]
low = df["Low"]
close = df["Close"]

n1 = np.arange(10, 40, 1)
n2 = np.arange(10, 40, 1)
os = -75
ob = 60

wt = Wavetrend.run(high, low, close, n1, n2, os, ob, param_product=True)

cmo = vbt.pandas_ta("cmo").run(close, lenght=14, talib=False)
rsi = vbt.pandas_ta("rsi").run(close, 14)
macd = vbt.MACD.run(close)
ema_200 = vbt.pandas_ta("ema").run(close, 200)


entries = wt.trend_below(0).vbt & ema_200.ema_above(close).vbt & macd.macd_below(0).vbt
@rafalsza
Copy link
Author

can someone help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant