$TUT
importar tiempo
importar pandas como pd
importar ta
de binance.client importar Client
# 1. Claves de API
api_key = "TUMHARA_API_KEY"
api_secret = "TUMHARA_API_SECRET"
client = Client(api_key, api_secret)
symbol = "TUTUSDT"
quantity = 10 # ¿Cuántos TUT comprar?
def get_rsi():
klines = client.get_klines(symbol=symbol, interval=Client.KLINE_INTERVAL_5MINUTE, limit=50)
df = pd.DataFrame(klines, columns=['time','open','high','low','close','vol','c1','c2','c3','c4','c5','c6'])
df['close'] = df['close'].astype(float)
rsi = ta.momentum.RSIIndicator(df['close']).rsi().iloc[-1]
price = df['close'].iloc[-1]
return float(price), float(rsi)
while True:
price, rsi = get_rsi()
print(f"Precio: {price} USDT | RSI: {rsi}")
# 2. Lógica: RSI < 30 = Sobrevendido = Comprar | RSI > 70 = Sobrecomprado = Vender
if rsi < 30:
print("Señal de compra")
# order = client.order_market_buy(symbol=symbol, quantity=quantity)
elif rsi > 70:
print("Señal de venta")
# order = client.order_market_sell(symbol=symbol, quantity=quantity)
time.sleep(300) # Comprobar cada 5 min
importar tiempo
importar pandas como pd
importar ta
de binance.client importar Client
# 1. Claves de API
api_key = "TUMHARA_API_KEY"
api_secret = "TUMHARA_API_SECRET"
client = Client(api_key, api_secret)
symbol = "TUTUSDT"
quantity = 10 # ¿Cuántos TUT comprar?
def get_rsi():
klines = client.get_klines(symbol=symbol, interval=Client.KLINE_INTERVAL_5MINUTE, limit=50)
df = pd.DataFrame(klines, columns=['time','open','high','low','close','vol','c1','c2','c3','c4','c5','c6'])
df['close'] = df['close'].astype(float)
rsi = ta.momentum.RSIIndicator(df['close']).rsi().iloc[-1]
price = df['close'].iloc[-1]
return float(price), float(rsi)
while True:
price, rsi = get_rsi()
print(f"Precio: {price} USDT | RSI: {rsi}")
# 2. Lógica: RSI < 30 = Sobrevendido = Comprar | RSI > 70 = Sobrecomprado = Vender
if rsi < 30:
print("Señal de compra")
# order = client.order_market_buy(symbol=symbol, quantity=quantity)
elif rsi > 70:
print("Señal de venta")
# order = client.order_market_sell(symbol=symbol, quantity=quantity)
time.sleep(300) # Comprobar cada 5 min