Specifiche
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())
Con risposta
1
Valutazioni
Progetti
215
57%
Arbitraggio
8
25%
/
25%
In ritardo
7
3%
In elaborazione
2
Valutazioni
Progetti
431
27%
Arbitraggio
123
21%
/
55%
In ritardo
96
22%
In elaborazione
3
Valutazioni
Progetti
398
38%
Arbitraggio
82
41%
/
20%
In ritardo
69
17%
Occupato
Ordini simili
"I'm looking for a talented developer to help implement my custom NT8 strategy. Your expertise is key to the project's success. Are you interested in teaming up for a productive partnership? Let's discuss the details together. Thank you!"
I Want to code personalized custom Ninjatrder 8 strategy using the NinjaTrader 8 platform."
200+ USD
"I'm on the lookout for a proficient developer to help actualize my tailored NT8 strategy. Your mastery in this field is pivotal for the project's success. Would you be open to partnering for a mutually beneficial collaboration? Let's explore the details together. Thank you for considering!"
"I'm in search of a skilled developer to bring my customized NT8 strategy to life. Your expertise is crucial for the success of this project. Would you be interested in joining forces for a fruitful collaboration? Let's connect to delve into the specifics together. Much appreciated!"
i want close on reserve signal, auto lots, time fiter , TP SL TS ETC. I GET PAID ON THE 12TH, SO I WOULD LIKE A DEMO UNTIL 12/05/24 TO TEST IM WILL TOO PAY 60 USD FOR THE LONG WAIT
MT5 Broker Research
50 - 100 USD
Looking For Someone With Good knowledge of Available MT5 Brokers to help with MT5 Demo Account research. The Objective of the research is to gather data on trading environment in each MT5 demo account by downloading the demo and accessing such factors as. 1 ) Number Of Trading Sectors Covered, example , Forex, Futures, Commodities, Stocks and Global Region Of Stocks etc 2) Total Number Of Symbols In Market Watch 3)
Crpyto Indicators
75 - 100 USD
2 Indicators: One for BTC/USD and one for ETH/USD Create indicators which plot the MVRV of Bitcoin and Ethereum as a line, standardized by a Z Score Essentially Zscore = ( MC - MCRealized ) / STD ( MC(number of bars ) Indicators should work on the daily timeframe at a minimum, and smaller ones if possible. Indicators should be able to work with future data as well, meaning it can download what's necessary to then
Blue Angel Shark
30 - 120 USD
I would like a coded indicator that is able to combine Smart money concept, Pure price Action and Pine script so as to spot trade entries by giving Take profits and Stop loss should also be compatible with all timeframes in trading and also work with all forex markets and Derived synthetic indices. I will upload a picture below. Kindly
I need smart, professional, and fast programmer for doing this project quickly, that have experience in EA with minimum 500 projects finish, and have good review and reputation from their client Share your link review, if you not qualified, dont apply! I will bidding the programmer from experience, review, reputation, price, and days working My EA using Moving Average, Average True Range, and using consecutives
The future of the traders be a good traders and patient and humble person faithful loyalty to your job and last be a professional traders and helping a dream of us how to trade and etc,,,,,,,,,,,,,,,,,🤑
I need smart, professional, and fast programmer for doing this project quickly, that have experience in EA with minimum 500 projects finish, and have good review and reputation from their client Share your link review, if you not qualified, dont apply! I will bidding the programmer from experience, review, reputation, price, and days working My EA using Moving Average, Average True Range, and using consecutives
Informazioni sul progetto
Budget
30 - 50 USD
Scadenze
da 1 a 14 giorno(i)
Cliente
Ordini effettuati1
Numero di arbitraggi0