MetaTrader 5 Python User Group - как использовать Python в Метатрейдере - страница 64
Вы упускаете торговые возможности:
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Регистрация
Вход
Вы принимаете политику сайта и условия использования
Если у вас нет учетной записи, зарегистрируйтесь
Hi All,
I hope you don't mind an English man here. Looking for some guidance after spending lots of time searching the web without success.
I am using the MetaTrader5 Python library after some inspiration from Maxiums articles. I have noticed a problem with memory handling.
When I make a Dataframe using mt5 lib the resultant dataframe works as expected. I have done this within a function that collects the ticks and then performs various analysis before outputting the manipulated df.
However, if I rerun the function that creates the DataFrame I have noticed that the memory just keeping accumulating from the previous instance.
I get the same problem using mt5.copy_ticks_range () and mt5.copy_rates_range (). I have to reset the kernel in order to clear out the memory.
I get the same problem even after removing all code except the line creating the dataframe. For instance:
def vel (symbol, lookback, lookforward, start_date, end_date, quantile_size):
ticks = pd.DataFrame (mt5.copy_ticks_range (symbol, datetime (start_date.year, start_date.month, start_date.day), datetime (end_date.year, end_date.month, end_date.day), mt5.COPY_TICKS_ALL), columns = [ 'time', 'bid', 'ask', 'last', 'volume', 'time_msc', 'flags', 'volume_real'])
If I run this several times the memory usage goes up 27MiB each time:
Line # Mem usage Increment Line Contents =========================================== ======= 126.3 MiB 126.3 MiB def vel (symbol, lookback, lookforward, start_date, end_date, quantile_size): 153.3 MiB 26.9 MiB ticks = pd.DataFrame (mt5.copy_ticks_range (symbol, datetime (start_date.year, start_date .month, start_date.day), ...
Line # Mem usage Increment Line Contents
If you want help debugging then you'll have to give a full MVCE. This snippet is not enough.
Hi All,
I hope you don't mind an English man here. Looking for some guidance after spending lots of time searching the web without success.
I am using the MetaTrader5 Python library after some inspiration from Maxiums articles. I have noticed a problem with memory handling.
When I make a Dataframe using mt5 lib the resultant dataframe works as expected. I have done this within a function that collects the ticks and then performs various analysis before outputting the manipulated df.
However, if I rerun the function that creates the DataFrame I have noticed that the memory just keeping accumulating from the previous instance.
I get the same problem using mt5.copy_ticks_range () and mt5.copy_rates_range (). I have to reset the kernel in order to clear out the memory.
I get the same problem even after removing all code except the line creating the dataframe. For instance:
def vel (symbol, lookback, lookforward, start_date, end_date, quantile_size):
ticks = pd.DataFrame (mt5.copy_ticks_range (symbol, datetime (start_date.year, start_date.month, start_date.day), datetime (end_date.year, end_date.month, end_date.day), mt5.COPY_TICKS_ALL), columns = [ 'time', 'bid', 'ask', 'last', 'volume', 'time_msc', 'flags', 'volume_real'])
If I run this several times the memory usage goes up 27MiB each time:
Line # Mem usage Increment Line Contents ================================================== 126.3 MiB 126.3 MiB def vel (symbol, lookback, lookforward, start_date, end_date, quantile_size): 153.3 MiB 26.9 MiB ticks = pd.DataFrame (mt5.copy_ticks_range (symbol, datetime (start_date.year, start_date.month, start_date.day), ...
Line # Mem usage Increment Line Contents
maybe you try to use https://docs.python.org/3/library/gc.html
https://stackabuse.com/basics-of-memory-management-in-python/
Всем привет.
Начала появляться такая ошибка при попытка выставить ордер через MetaTrader5.Buy() / Sell():
order_open = mt5.Buy(symbol, volume)
File "C:\Python3.7.4\lib\site-packages\MetaTrader5\__init__.py", line 313, in Buy
if r.retcode != TRADE_RETCODE_REQUOTE and r.retcode != TRADE_RETCODE_PRICE_OFF:
AttributeError: 'NoneType' object has no attribute 'retcode'
Можете подсказать как исправить?
Hello everyone.
Such an error began to appear when trying to place an order through MetaTrader5.Buy () / Sell () :
order_open = mt5.Buy(symbol, volume)
File "C:\Python3.7.4\lib\site-packages\MetaTrader5\__init__.py", line 313, in Buy
if r.retcode != TRADE_RETCODE_REQUOTE and r.retcode != TRADE_RETCODE_PRICE_OFF:
AttributeError: 'NoneType' object has no attribute 'retcode'
Can you tell me how to fix it?
Каким билдом терминала вы пользуетесь?
Обновлялись на бета-версии?
Каким билдом терминала вы пользуетесь?
Обновлялись на бета-версии?
Обновился до последней - MetaTrader5 package version: 5.0.31
Такая ошибка возникает как при использовании функций mt5.Buy(), mt5.Sell(), так и при mt5.order_send(requests).
Также пишет что нет атрибута "retcode".
Обновился до последней - MetaTrader5 package version: 5.0.31
Такая ошибка возникает как при использовании функций mt5.Buy(), mt5.Sell(), так и при mt5.order_send(requests).
Также пишет что нет атрибута "retcode".
Вопрос был про версию терминала.
Вопрос был про версию терминала.
МТ5 version: 5.00 build 2361 08 mar 2020
МТ5 version: 5.00 build 2361 08 mar 2020
Upgrade to the beta version, please.
New functions available in beta versions only.
Upgrade to the beta version, please.
New functions available in beta versions only.
Обновил до версии 2432.
Но ошибка всё равно остаётся..
Уже перепробовал на разных брокерах даже..