Tarea técnica
NESESITO QUE ME HAGAN UN BOT CON ESTA INFORMACION EN PYTON
mport ccxt
import pandas as pd
import numpy as np
import ta
# Configuración de la API
exchange = ccxt.binance() # Cambia a tu exchange preferido
symbol = 'BTC/USDT' # Activo a operar
timeframe = '1h' # Marco temporal
risk_percentage = 0.02 # Riesgo por operación
stop_loss_percentage = 0.02 # 2% stop loss
take_profit_percentage = 0.04 # 4% take profit
# Función para obtener datos históricos
def get_historical_data(symbol, timeframe):
bars = exchange.fetch_ohlcv(symbol, timeframe)
df = pd.DataFrame(bars, columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
return df
# Función para calcular indicadores
def calculate_indicators(df):
df['RSI'] = ta.momentum.RSIIndicator(df['close']).rsi()
df['MACD'] = ta.trend.MACD(df['close']).macd()
df['Signal'] = ta.trend.MACD(df['close']).macd_signal()
df['OBV'] = ta.volume.OnBalanceVolumeIndicator(df['close'], df['volume']).on_balance_volume()
df['Stochastic'] = ta.momentum.StochasticOscillator(df['high'], df['low'], df['close']).stoch()
return df
# Estrategia de Trading
def strategy(df):
last_row = df.iloc[-1]
# Condiciones de compra
if (last_row['RSI'] < 30) and (last_row['MACD'] > last_row['Signal']):
return 'buy'
# Condiciones de venta
elif (last_row['RSI'] > 70) and (last_row['MACD'] < last_row['Signal']):
return 'sell'
return 'hold'
# Función de gestión de riesgo
def calculate_position_size(balance, risk_percentage):
return balance * risk_percentage
# Función para ejecutar ordenes con stop loss y take profit
def execute_order(signal, position_size):
market_price = exchange.fetch_ticker(symbol)['last']
if signal == 'buy':
# Ejecutar orden de compra
order = exchange.create_market_order(symbol, 'buy', position_size)
# Calcular niveles de stop loss y take profit
stop_loss_price = market_price * (1 - stop_loss_percentage)
take_profit_price = market_price * (1 + take_profit_percentage)
# Establecer stop loss
exchange.create_order(symbol, 'stop_market', 'sell', position_size, stop_loss_price)
# Establecer take profit
exchange.create_limit_order(symbol, 'sell', position_size, take_profit_price)
elif signal == 'sell':
# Ejecutar orden de venta
order = exchange.create_market_order(symbol, 'sell', position_size)
# Calcular niveles de stop loss y take profit
stop_loss_price = market_price * (1 + stop_loss_percentage)
take_profit_price = market_price * (1 - take_profit_percentage)
# Establecer stop loss
exchange.create_order(symbol, 'stop_market', 'buy', position_size, stop_loss_price)
# Establecer take profit
exchange.create_limit_order(symbol, 'buy', position_size, take_profit_price)
# Loop principal del bot
def run_bot():
balance = exchange.fetch_balance()['total']['USDT'] # Ajusta según tu activo
df = get_historical_data(symbol, timeframe)
df = calculate_indicators(df)
signal = strategy(df)
if signal in ['buy', 'sell']:
position_size = calculate_position_size(balance, risk_percentage)
execute_order(signal, position_size)
# Ejecutar el bot
if _name_ == "_main_":
run_bot()
Han respondido
1
Evaluación
Proyectos
317
24%
Arbitraje
23
35%
/
13%
Caducado
24
8%
Libre
Ha publicado: 3 ejemplos
2
Evaluación
Proyectos
1
0%
Arbitraje
1
0%
/
0%
Caducado
0
Libre
Solicitudes similares
Ofrezco un sistema de trading automatizado que conecta señales de MetaTrader 4 con ejecución automática de operaciones en Polymarket. El sistema ya está desarrollado y funcionando correctamente. Este bot permite copiar señales generadas por un indicador personalizado en MT4 y ejecutar operaciones automáticamente en mercados de predicción de criptomonedas. Cómo funciona el sistema Un indicador personalizado en MT4
busco programador para gestionar una modificación de un EA y la integración de una IA a través de Python, y poder agregarles API al mismo, de la mejor manera posible, también estoy abierto opiniones del desarrollador. I’m looking for a programmer to manage a modification of an Expert Advisor (EA) and the integration of an AI through Python, as well as to add APIs to it in the most optimal way possible. I’m also open
Información sobre el proyecto
Presupuesto
30+ USD