Closed yglpyn8888 closed 2 years ago
As I explained here, you can override the download_data
method and load your own dataframes. It's a bit more complicated than anytrading. For each symbol, you should load a dataframe and specify its SymbolInfo
. The symbol info is required for precise calculations. Currently, it is filled by retrieving the information from MetaTrader but you can create an instance of this class and fill it manually.
@AminHP Hi Amin, I probably know what to do next, but it's a little different from what I expected. I thought I should rewrite the load_symbols method to load my own df. So what's the difference between the download_data() and load_symbols()?
According to their source code, the load_symbols method is loaded from a filename:str(actually a path), which seems to be more in line with my requirements?
def download_data(
self, symbols: List[str], time_range: Tuple[datetime, datetime], timeframe: Timeframe
) -> None:
from_dt, to_dt = time_range
for symbol in symbols:
si, df = retrieve_data(symbol, from_dt, to_dt, timeframe)
self.symbols_info[symbol] = si
self.symbols_data[symbol] = df
def load_symbols(self, filename: str) -> bool:
if not os.path.exists(filename):
return False
with open(filename, 'rb') as file:
self.symbols_info, self.symbols_data = pickle.load(file)
return True
The load_symbols
method can only load a file which was previously saved by the save_symbols
method. And the save_symbols
should be called after filling the simulator.symbols_info
and simulator.symbols_data
attributes. These attributes are filled in the download_data
. So, in order to make load_symbols
work correctly, the proper data should be provided first in the download_data
method.
oh, that's clear, thanks!
May I ask, How can I fix trading volume or lot size?
thanks in advance for your answer
oh, that's clear, thanks!
please can you share your notebook to upload custom data file
Just like the parameter 'df' of Env in anytrading, how can I load my own dataframe in MtSim . I see in the example that only the .pkl file is loaded