MetaTrader 5 Python User Group - メタトレーダーでPythonを使用する方法 - ページ 56

 
Дмитрий Прокопьев:

試してみたが、全ては動作するハードウェアに依存する。

1つのインスタンスが約45-50MBのRAMと2,5-4%のCPUを消費します。(そう、CPUの%はCPUの種類に依存し、私の場合はIntel Xeon L5640 @ 2.27GHz)。

同じ、pythonのインスタンスを1つ。

pythonがhistoryで動作する場合、+200-300Mb RAM。CPUはほとんど使いません。

まあ、なぜかというと、ToRやアイデア次第なんです。

了解しました。情報提供ありがとうございました。

 
開発者の方、API関数copy_buffer() を作ってください。インジケーターデータをアナログで 受信する。
Документация по MQL5: Доступ к таймсериям и индикаторам / CopyBuffer
Документация по MQL5: Доступ к таймсериям и индикаторам / CopyBuffer
  • www.mql5.com
Отсчет элементов копируемых данных (индикаторный буфер с индексом buffer_num) от стартовой позиции ведется от настоящего к прошлому, то есть стартовая позиция, равная 0, означает текущий бар (значение индикатора для текущего бара). При копировании заранее неизвестного количества данных в качестве массива-приемника buffer[] желательно...
 
Denis Kirichenko:
開発者の方、API-functioncopy_buffer() を作ってください。アナログで インジケーターデータを取得する。

Pythonにインジケーターパッケージはないのでしょうか?それとも何か特別な指標でもあるのでしょうか。これは使えるようです https://github.com/twopirllc/pandas-ta

twopirllc/pandas-ta
twopirllc/pandas-ta
  • twopirllc
  • github.com
Technical Analysis (TA) is an easy to use library that is built upon Python's Pandas library with more than 80 Indicators. These indicators are comminly used for financial time series datasets with columns or labels similar to: datetime, open, high, low, close, volume, et al. Many commonly used indicators are included, such as: Moving Average...
 
Vladimir Perervenko:

Pythonにインジケーターパッケージはないのでしょうか?それとも何か特別な指標でもあるのでしょうか。これは使えるようです https://github.com/twopirllc/pandas-ta

copy_buffer() は、計算の ためのデータの配列を取得することを意味します。
そして、copy_buffer()は、両方の方法で動作する必要があります。
足りないのは、双方向のアレイ転送です。

 
Roman:

symbols_total と symbol_name関数が ありません
このようなシンボルの一覧を取得することができます。

5.0.29 で追加された symbols_total(), symbols_get([group="EURUSD, "USDGBP", *RU*"]) が動作するには、最新のベータ版ターミナルが必要です。

また、すべての関数 orders_get(),positions_get(), history_orders_get(), history_deals_get() にグループによるフィルタリングの可能性を追加しました - group="EURUSD, "USDGBP", *RU*".
order_check(), order_send() メソッドは、request フィールドに最初の実行要求を返します。

 
Roman:

copy_buffer() は、それ自身の 計算のためにデータの配列を取得することを意味する。
また、copy_buffer() は両方向に動作する必要があります。
足りないのは、配列の双方向の受け渡しです。

githubにたくさんあるし、b/bpのlibも有料のパッケージもあるし...。

MQL5での作業モデルをpythonに移し替えないでください。それぞれ違うし、目的も違う。

 
Almaz:

5.0.29 で symbols_total(), symbols_get([group="EURUSD, "USDGBP", *RU*"]) を追加、動作には最新のベータ版ターミナルが必要です。

また、すべての関数 orders_get(), positions_get(), history_orders_get(), history_deals_get() において、グループによるフィルタリング機能を追加しました - group="EURUSD, "USDGBP", *RU*" です。
order_check(), order_send() メソッドは、request フィールドに最初の実行要求を返します。

また、_todict()のリストはまだ返すことができないのでしょうか?

 
Дмитрий Прокопьев:

まだ_todict()のリストを返せないの?

はい、できます、例をご覧ください。

import MetaTrader5 as mt5
# выведем данные о пакете MetaTrader5
print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)

# установим подключение к терминалу MetaTrader 5
if not mt5.initialize():
    print("initialize() failed")
    mt5.shutdown()

# подключимся к торговому счету с указанием пароля и сервера
authorized=mt5.login(25115284, password="gqsdfgtdm",server="MetaQuotes-Demo")
if(authorized):
    # выведем данные о торговом счете
    print(mt5.account_info())
else:
    print("failed to connect to trade account 25115284 with password=gqz0lbdm")

account_info_dict=mt5.account_info(). _asdict()
for prop in account_info_dict:
    print("{}={}".format(prop,account_info_dict[prop]))

mt5.shutdown()

結果

AccountInfo(login=25115284, trade_mode=0, leverage=100, limit_orders=200, margin_so_mode=0, trade_allowed=True, trade_expert=True, margin_mode=2, currency_digits=2, fifo_close=False, balance=99511.4, credit=0.0, profit=9.04, equity=99520.44, margin=98.18, margin_free=99422.26, margin_level=101365.28824607862, margin_so_call=50.0, margin_so_so=30.0, margin_initial=0.0, margin_maintenance=0.0, assets=0.0, liabilities=0.0, commission_blocked=0.0, name='MetaQuotes Dev Demo', server='MetaQuotes-Demo', currency='USD', company='MetaQuotes Software Corp.')
login=25115284
trade_mode=0
leverage=100
limit_orders=200
margin_so_mode=0
trade_allowed=True
trade_expert=True
margin_mode=2
currency_digits=2
fifo_close=False
balance=99511.4
credit=0.0
profit=9.04
equity=99520.44
margin=98.18
margin_free=99422.26
margin_level=101365.28824607862
margin_so_call=50.0
margin_so_so=30.0
margin_initial=0.0
margin_maintenance=0.0
assets=0.0
liabilities=0.0
commission_blocked=0.0
name=MetaQuotes Dev Demo
server=MetaQuotes-Demo
currency=USD
company=MetaQuotes Software Corp.
 
Rashid Umarov:

結果

ありがとうございます。この例を見て、うまくいきました。

私の質問は少し違います。

    if mt5.initialize('c:\\Works\\MT5 - terminals\\RoboForex - MT5\\terminal64.exe',
                            login=500036189, server='RoboForex-MetaTrader 5', password='',  portable=True):
        positions = mt5.positions_get()
        print(positions)
        pList = []
        for elem in positions:
            pList.append(elem._asdict())

positions_get - トレードポジションのリストを返します。原理的にはOKで、pandasに放り込めば問題なく動く。

(TradePosition(ticket=164661016, time=1585075408, time_msc=1585075408163, time_update=1585075408, time_update_msc=1585075408163, type=1, magic=0, identifier=164661016, reason=0, volume=0.01, price_open=120.306, sl=0.0, tp=0.0, price_current=120.279, swap=0.0, profit=0.24, symbol='EURJPY', comment='', external_id=''), 
 TradePosition(ticket=164661051, time=1585075426, time_msc=1585075426062, time_update=1585075426, time_update_msc=1585075426062, type=0, magic=0, identifier=164661051, reason=0, volume=0.01, price_open=1.07798, sl=0.0, tp=0.0, price_current=1.07806, swap=0.0, profit=0.08, symbol='EURUSD', comment='', external_id=''))

でも、パンダに限らず、こういうものが欲しいということであれば

[{'ticket': 164661016, 'time': 1585075408, 'time_msc': 1585075408163, 'time_update': 1585075408, 'time_update_msc': 1585075408163, 'type': 1, 'magic': 0, 'identifier': 164661016, 'reason': 0, 'volume': 0.01, 'price_open': 120.306, 'sl': 0.0, 'tp': 0.0, 'price_current': 120.328, 'swap': 0.0, 'profit': -0.2, 'symbol': 'EURJPY', 'comment': '', 'external_id': ''}, 
{'ticket': 164661051, 'time': 1585075426, 'time_msc': 1585075426062, 'time_update': 1585075426, 'time_update_msc': 1585075426062, 'type': 0, 'magic': 0, 'identifier': 164661051, 'reason': 0, 'volume': 0.01, 'price_open': 1.07798, 'sl': 0.0, 'tp': 0.0, 'price_current': 1.07881, 'swap': 0.0, 'profit': 0.83, 'symbol': 'EURUSD', 'comment': '', 'external_id': ''}]

パンダを使うか、あるいは...。無駄なジェスチャーが多いな。

_asdict()は、開発者がMQL5プログラマーではなく、例えばPythonistである場合、より便利になりました ...またはデータサイエンティストであれば、リスト/ディクトは

list/dictはpythonの主要な要素であり、多くのライブラリはlist/dictを使用してデータ転送を行います。

タプルはよく、たくさん使われますが、その中で動くデータの種類を 厳密に制御したい場合に限ります。

で、不正な使用や代入のためのエラーハンドラを持つ。どこかで ...:)間違っているかもしれません。

 
Дмитрий Прокопьев:

githubにたくさんあるし、b/bpのlibも有料のパッケージもあるし...。

MQL5での作業モデルをpythonに移し替えないでください。両者は異なるものであり、目的も異なる。

どういうことですか?配列を mql5からpyにコピーして 戻す?
話の内容くらい丁寧に読めよ。
自分のことだけを考える必要はないのです。自分が必要なくても、他の人が必要なんです。