使用Python从报文通道获取信号并将其放置在MT4中。

问题描述 投票:0回答:1

我想从Telegram频道读取消息(这是基本的外汇信号)并在MT4窗口应用程序中下单。目前,我已经制作了一个python脚本,它可以监听频道并将消息存储在数据库中。我也可以对消息进行解析,获取必要的值,如TP,SL等。现在,我已经有了这些信号,我如何放置它们呢?

我在其他答案中读到了关于ZeroMQ和Python绑定的内容,但我不需要做任何分析或策略构建,我只想下单。我看到一个视频,他在MQL4Files文件夹里放了一个csv文件,订单就下了,但是我不知道这个csv是怎么格式化的。

这是我用于读取telegram消息的python代码,如果有人需要的话。先谢谢你

import configparser
import json

from telethon import TelegramClient, events
from telethon.errors import SessionPasswordNeededError
from telethon.tl.functions.channels import GetParticipantsRequest
from telethon.tl.types import ChannelParticipantsSearch
from telethon.tl.types import PeerChannel
from telethon.tl.functions.messages import (GetHistoryRequest)


my_channel = "<channel_url>"



# Reading Configs
config = configparser.ConfigParser()
config.read("config.ini")

# Setting configuration values
api_id = config['Telegram']['api_id']
api_hash = config['Telegram']['api_hash']

api_hash = str(api_hash)

phone = config['Telegram']['phone']
username = config['Telegram']['username']

client = TelegramClient(username, api_id, api_hash)


# async def main():
#     me = await client.get_me()
#     print(me.stringify())
#     async for message in client.iter_messages('Hanil02'):
#         print(message.id, message.text)

# with client:
#     client.loop.run_until_complete(main())

@client.on(events.NewMessage)
async def my_event_handler(event):
    chat = await event.get_chat()
    sender = await event.get_sender()
    chat_id = event.chat_id
    sender_id = event.sender.id
    text = event.raw_text
    # print(sender.id)
    if sender_id == 1386059246:
        print(event.raw_text)
client.start()
client.run_until_disconnected()
python telegram trading metatrader4 mt4
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.