Hello,
I am trying to run locally my personnal data (I have every forex pairs in daily, hourly and on a minute basis). But I do not know what to do, my script is always crashing …
QUANTCONNECT COMMUNITY
Hello,
I am trying to run locally my personnal data (I have every forex pairs in daily, hourly and on a minute basis). But I do not know what to do, my script is always crashing …
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Mia Alissi
To help you run your personal forex data locally on QuantConnect, follow these steps:
Verify Data Format: Ensure your data is in a CSV format with headers like date, open, high, low, close, and volume.
Create a Custom Data Class: Define a custom data class by extending the
PythonData
class. This class will handle the parsing and loading of your data.Implement
GetSource
andReader
Methods:GetSource
: Specify the data source. For local data, you can use a local file path.Reader
: Parse each line of your data file into a format that QuantConnect can understand.Here's a basic example:
Add Custom Data to Algorithm: In your algorithm's
Initialize
method, useAddData
to include your custom data class.Check Data Path: Ensure the file path to your data is correct and accessible.
Debugging: Use logging to identify issues. Check for common errors like file not found or parsing errors.
Test with Sample Data: Start with a small sample to ensure everything is set up correctly.
By following these steps, you should be able to run your personal forex data locally on QuantConnect. If you encounter specific errors, let me know, and I can help troubleshoot further.
Sources: Custom Data - QuantConnect.com, CSV Format Example - QuantConnect.com, Key Concepts - QuantConnect.com, Custom Data - QuantConnect.com, Key Concepts - QuantConnect.com
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Adrien Aubourg
Here is the code I use to test:
from AlgorithmImports import *
class HourlyForexStrategy(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2022, 1, 1)
self.SetEndDate(2023, 1, 1)
self.SetCash(100000)
# Ajouter les paires Forex EURUSD et AUDCAD en résolution horaire
self.eurusd = self.AddForex("EURUSD", Resolution.Hour).Symbol
self.audcad = self.AddForex("AUDCAD", Resolution.Hour).Symbol
# Initialiser les indicateurs de moyennes mobiles
self.sma_fast_eurusd = self.SMA(self.eurusd, 50, Resolution.Hour)
self.sma_slow_eurusd = self.SMA(self.eurusd, 200, Resolution.Hour)
self.sma_fast_audcad = self.SMA(self.audcad, 50, Resolution.Hour)
self.sma_slow_audcad = self.SMA(self.audcad, 200, Resolution.Hour)
def OnData(self, data):
# EURUSD: Achat si la SMA rapide croise au-dessus de la SMA lente
if self.sma_fast_eurusd.Current.Value > self.sma_slow_eurusd.Current.Value and not self.Portfolio[self.eurusd].Invested:
self.SetHoldings(self.eurusd, 0.5)
elif self.sma_fast_eurusd.Current.Value < self.sma_slow_eurusd.Current.Value and self.Portfolio[self.eurusd].Invested:
self.Liquidate(self.eurusd)
# AUDCAD: Achat si la SMA rapide croise au-dessus de la SMA lente
if self.sma_fast_audcad.Current.Value > self.sma_slow_audcad.Current.Value and not self.Portfolio[self.audcad].Invested:
self.SetHoldings(self.audcad, 0.5)
elif self.sma_fast_audcad.Current.Value < self.sma_slow_audcad.Current.Value and self.Portfolio[self.audcad].Invested:
self.Liquidate(self.audcad)
How can I update it to use my own personnal data files?
Louis Szeto
Hi Adrien
For custom-imported data, please follow here for instructions. I believe Mia's example is a valid one if you adapt and modify it for your case. Have you tried that?
Best
Louis
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Adrien Aubourg
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!