最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

期貨量化交易軟件:如何在 MQL5 中使用 ONNX 模型

2023-09-04 16:57 作者:bili_45793681098  | 我要投稿

1. 構(gòu)建模型

Python 提供了一組專(zhuān)門(mén)的函數(shù)庫(kù),因此它提供了處理機(jī)器學(xué)習(xí)模型的廣泛功能。 函數(shù)庫(kù)極大地方便了數(shù)據(jù)的準(zhǔn)備和處理。 我們建議使用 GPU 資源來(lái)最大限度地提高機(jī)器學(xué)習(xí)項(xiàng)目的效率。 許多 Windows 用戶(hù)在嘗試安裝當(dāng)前的 TensorFlow 版本時(shí)遇到了問(wèn)題(請(qǐng)參閱視頻指南,及其文本版本的注釋?zhuān)?故此,我們已經(jīng)測(cè)試了TensorFlow 2.10.0,并建議使用此版本。 GPU 計(jì)算是在 NVIDIA GeForce RTX 2080 Ti 圖形卡上使用 CUDA 11.2 和 CUDNN 8.1.0.7 函數(shù)庫(kù)進(jìn)行的。

1.1. 安裝 Python 和函數(shù)庫(kù)如果您還沒(méi)有 Python,請(qǐng)您先安裝它。 我們使用的是 3.9.16 版。 另外,還要安裝函數(shù)庫(kù)(如果您使用的是 Conda/Anaconda,請(qǐng)?jiān)?Anaconda 提示符下運(yùn)行以下命令): python.exe -m pip install --upgrade pip pip install --upgrade pandas pip install --upgrade scikit-learn pip install --upgrade matplotlib pip install --upgrade tqdm pip install --upgrade metatrader5 pip install --upgrade onnx==1.12 pip install --upgrade tf2onnx pip install --upgrade tensorflow==2.10.0 1.2. 檢查 TensorFlow 版本和 GPU下面的代碼檢查已安裝的 TensorFlow 版本,并驗(yàn)證是否可以使用 GPU 來(lái)計(jì)算模型: #check tensorflow version print(tf.__version__) #check GPU support print(len(tf.config.list_physical_devices('GPU'))>0) ? 如果正確安裝了所需的版本,您將看到以下結(jié)果: 2.10.0 True 我們使用 Python 腳本來(lái)構(gòu)建和訓(xùn)練模型。 下面簡(jiǎn)要介紹此過(guò)程的步驟。1.3. 構(gòu)建和訓(xùn)練模型該腳本首先導(dǎo)入將在模型中使用的 Python 函數(shù)庫(kù)。 #Python libraries import matplotlib.pyplot as plt import MetaTrader5 as mt5 import tensorflow as tf import numpy as np import pandas as pd import tf2onnx from sklearn.model_selection import train_test_split from sys import argv 檢查 TensorFlow 版本和 GPU 可用性: #check tensorflow version print(tf.__version__) 2.10.0 #check GPU support print(len(tf.config.list_physical_devices('GPU'))>0) True 初始化赫茲量化 以執(zhí)行來(lái)自 Python 的操作: #initialize 赫茲量化 for history data if not mt5.initialize(): ? ? print("initialize() failed, error code =",mt5.last_error()) ? ? quit() 有關(guān) 赫茲量化 終端的信息: #show terminal info terminal_info=mt5.terminal_info() print(terminal_info) ? TerminalInfo(community_account=True, community_connection=True, connected=True, dlls_allowed=False, trade_allowed=False, tradeapi_disabled=False, email_enabled=False, ftp_enabled=False, notifications_enabled=False, mqid=False, build=3640, maxbars=100000, codepage=0, ping_last=58768, community_balance=1.0, retransmission=0.015296317559440137, company='MetaQuotes Software Corp.', name='MetaTrader 5', language='English', path='C:\\Program Files\\MetaTrader 5', data_path='C:\\Users\\user\\AppData\\Roaming\\MetaQuotes\\Terminal\\D0E8209F77C8CF37AD8BF550E51FF075', commondata_path='C:\\Users\\user\\AppData\\Roaming\\MetaQuotes\\Terminal\\Common') #show file path file_path=terminal_info.data_path+"\\MQL5\\Files\\" print(file_path) C:\Users\user\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Files\ 打印模型(在此示例中,腳本在 Jupyter 筆記本中運(yùn)行)的保存路徑: #data path to save the model data_path=argv[0] last_index=data_path.rfind("\\")+1 data_path=data_path[0:last_index] print("data path to save onnx model",data_path) data path to save onnx model C:\Users\user\AppData\Roaming\Python\Python39\site-packages\ 準(zhǔn)備請(qǐng)求歷史數(shù)據(jù)的日期。 在我們的示例中,我們請(qǐng)求從當(dāng)前日期開(kāi)始 120 根 EURUSD H1 的柱線(xiàn): #set start and end dates for history data from datetime import timedelta,datetime end_date = datetime.now() start_date = end_date - timedelta(days=120) ?#print start and end dates print("data start date=",start_date) print("data end date=",end_date) data start date= 2022-11-28 12:28:39.870685 data end date= 2023-03-28 12:28:39.870685 請(qǐng)求 EURUSD 歷史數(shù)據(jù): #get EURUSD rates (H1) from start_date to end_date eurusd_rates = mt5.copy_rates_range("EURUSD", mt5.TIMEFRAME_H1, start_date, end_date) ? 輸出下載的數(shù)據(jù): #check print(eurusd_rates)

#create dataframe df = pd.DataFrame(eurusd_rates) 顯示數(shù)據(jù)幀的開(kāi)始和結(jié)束: #show dataframe head df.head()

#show dataframe tail df.tail()

#show dataframe shape (the number of rows and columns in the data set) df.shape


期貨量化交易軟件:如何在 MQL5 中使用 ONNX 模型的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
罗源县| 德格县| 大化| 临朐县| 板桥市| 油尖旺区| 桂平市| 乌兰察布市| 武宣县| 七台河市| 六盘水市| 偃师市| 开远市| 兴隆县| 江山市| 湟源县| 海盐县| 辉县市| 甘孜| 广丰县| 嘉兴市| 内黄县| 乌兰察布市| 孟村| 安多县| 南华县| 浦东新区| 巴林右旗| 炎陵县| 安丘市| 兴化市| 历史| 拜城县| 平江县| 获嘉县| 台江县| 东乡县| 河北省| 平远县| 九台市| 弥渡县|