Tarea técnica
import pandas as pd
import numpy as np
def generate_signals(data):
signals = pd.DataFrame(index=data.index)
signals['price'] = data['Close']
# Calculate moving averages
signals['short_ma'] = data['Close'].rolling(window=20, min_periods=1).mean()
signals['long_ma'] = data['Close'].rolling(window=50, min_periods=1).mean()
# Generate buy signals
signals['buy_signal'] = np.where(signals['short_ma'] > signals['long_ma'], 1, 0)
# Generate sell signals
signals['sell_signal'] = np.where(signals['short_ma'] < signals['long_ma'], -1, 0)
return signals
def backtest_strategy(signals, initial_capital=10000):
positions = pd.DataFrame(index=signals.index).fillna(0.0)
positions['asset'] = 1000 * signals['buy_signal'] + -1000 * signals['sell_signal']
# Calculate portfolio value
portfolio = positions.multiply(signals['price'], axis=0)
pos_diff = positions.diff()
portfolio['holdings'] = (positions.multiply(signals['price'], axis=0)).sum(axis=1)
portfolio['cash'] = initial_capital - (pos_diff.multiply(signals['price'], axis=0)).sum(axis=1).cumsum()
portfolio['total'] = portfolio['cash'] + portfolio['holdings']
portfolio['returns'] = portfolio['total'].pct_change()
return portfolio
# Example usage:
# Assuming 'data' is a DataFrame containing historical price data with 'Date' as index and 'Close' as a column
# signals = generate_signals(data)
# portfolio = backtest_strategy(signals)
# print(portfolio.tail())
Han respondido
1
Evaluación
Proyectos
378
72%
Arbitraje
19
32%
/
47%
Caducado
16
4%
Libre
Ha publicado: 15 ejemplos
2
Evaluación
Proyectos
462
26%
Arbitraje
139
20%
/
60%
Caducado
100
22%
Libre
3
Evaluación
Proyectos
478
40%
Arbitraje
105
40%
/
24%
Caducado
82
17%
Trabajando
Ha publicado: 2 ejemplos
Solicitudes similares
i need someone that can make me an EA really easy with the martingala system?, I am looking for something that doesn't exceed 5 trades for the martingale, I think I did it, but it only works for propfirms, So i need to develop it on ninja trader I have identified a very very simple strategy but it only works on propfirms, with only two propfirm accounts, i absolutely need account A and account, And they have to open
Jona copilot v12
30 - 40 USD
Hi, I'm interested in ordering an MT4 trading bot. Before we begin, could you please send me the technical specifications and requirements you'll need? Specifically, I'd like to know: - The trading strategy the bot will use. - The currency pairs or instruments it will trade. - The timeframes it supports. - Risk management features (lot sizing, stop loss, take profit, trailing stop, maximum drawdown). - Whether it
Macd Rsi stochastic vwap Bot. I have code.
150 - 300 USD
Привіт. Шукаю когось, хто б застосував мій код як бота . Я торгую індексом Aus_200 SFE (не XJO). Бот базується на MACD входу/виходу, RSI, стохастиці та vwap. Як тільки роботу приймуть, мені потрібно внести кілька коректив; однак, нічого суттєвого. Дякую
MT4/MT5 HFT EA us30
30 - 3000 USD
Hello everybody, I'm looking for an experienced MQL4/MQL5 developer to optimize a High-Frequency Trading (HFT) Expert Advisor for both MT4 and MT5. The EA performs consistently and profitably on demo accounts, but when it is run on Raw and Standard live accounts under what appear to be the same trading conditions, it begins generating losses. I do not have the original source code (.mq4/.mq5); I only have the
Información sobre el proyecto
Presupuesto
30 - 50 USD
Plazo límite de ejecución
de 1 a 14 día(s)