Files
mt5-tools/__pycache__/mt5_parser.cpython-314.pyc
T

134 lines
20 KiB
Plaintext
Raw Normal View History

2026-04-12 18:25:46 +10:00
+
%¬âiĆ<ăójRt^RIt^RItRtRtRtRRltRtRt Rt
2026-04-12 18:25:46 +10:00
R t RR
lt R t
R tR
tR#)
mt5_parser.py
=============
Parsers for three MT5 trade report formats:
1. MT5 Real Account HTM export
2. MT5 Backtest HTM report
3. Quant Analyzer CSV export
All normalise to a common DataFrame schema.
NcóLRFpVPV4u# R# K ;i)úutf-16Ú)rzutf-8úlatin-1Úcp1252)Údecode)Ú
file_bytesÚencs& Ú"C:\Users\pc\MT5Tools\mt5_parser.pyÚ_decoder s1Ű7đ Ř×$ SÓ 
řđ Ú úsž#cóŽ\P!RRV4P4PRR4PRR4#)z<[^>]+>rô )ÚreÚsubÚstripÚreplace©Úss&r
Ú_striprs9Ü
2026-04-12 18:25:46 +10:00
Ź6Š6*b  $× ,× 4°V¸RÓ ĐSUÓ có|\\V4PRR4PRR44# R#;i)Ú rÚ,N)ÚfloatÚstrrrs&r
Ú _to_floatr"s8đÜ”S“V—^‘^ C¨Ó,×4°S¸>řđÚús36;có2\P!WRR7#)Úcoerce©ÚformatÚerrors)ÚpdÚ to_datetime)rÚfmts&&r
Ú_to_dtr$)sÜ
2026-04-12 18:25:46 +10:00
Ź>Š>Ô 9rcó¬\P!VR,RR7VR&\P!VR,RR7VR&VR,PPVR&VR,PPVR&VR,PP 4VR&VR,PP
VR&VR,VR,,
PP
4^<, P^4VR &RF|pWP9gK\P!W,P\4PPR
R4PPRR4RR7W&K~ RVP9dqVPR ^4P^4VPR
^4P^4,VPR ^4P^4,VR&VR,^8„VR&VR,PP4PP!4VR&RVP9dRVR&VR,P#\$4VR&VR,PPRRRR7PP'4VR&V#)z*Add derived columns common to all formats.Ú open_timer©r Ú
close_timeÚ open_dateÚ
close_dateÚ day_of_weekÚhourÚ duration_minÚ
commissionÚswapÚprofitrrrÚ
net_profitÚwinÚtypeÚcommentÚstrategyÚsymbolz \.[a-z]+$T)ÚregexÚ symbol_base)ÚvolumeÚ
2026-04-12 18:25:46 +10:00
open_priceÚ close_priceÚslÚtpr.r/r0)r!r"ÚdtÚdateÚday_namer,Ú
total_secondsÚroundÚcolumnsÚ
to_numericÚastyperrÚgetÚfillnaÚlowerrÚapplyÚextract_strategyÚupper)ÚdfÚcols& r
Ú_enrichrN-sDäźš¨¨;­ŔÔJ€B€{źš¨¨<Ő(8ŔÔJ€B€|ŃŘ×0€B€{1€B€|ŃŘ×6€B€}ŃŘ×0€B€v+¨b°­oŐ™2źm™m›o°ő3ß49±E¸!łHđ€~Ńó0ŕ —*‘*Ö Ü—m’mŘśsÓ#×'×°RÓ8×<×DŔSČ"ÓôB2ź:™:Ô ŹF‰F8 × &  ŹF‰F< Ó #× *¨1Ó 
ŹF‰F6 × $  
 đ
 ŐŃ)€B€u•Z—^‘^×/×7€B€vź
Ô9‰
Ř •]×(Ô)9Ó:€B€z ׸rČĐZ€B€}ŃŘ
€Irc ó$a
a \V4p\P!RV\P4p.pRp.ROpVEF p\P!RV\P4o
S
Uu.uF2p\P!RR\ V44P
4NK4 upo
S
'd#S
^,R8Xd\S
4^
dRpK“V'gS
'dD\;QJdV
3RlR4F 'gK RM RM!V
3RlR44'dEM)\S
2026-04-12 18:25:46 +10:00
4^g\P!R S
^,4'gEK!S
2026-04-12 18:25:46 +10:00
Uu.uFqw'gK VP4NK upo \;QJdV 3R
lR4F 'gK RM RM!V 3R
lR44'dE\S
4^
8g%\P!R S
^ ,4'gER \S
^,49dE\\VS
2026-04-12 18:25:46 +10:00
R ,44pVPV4EK V'gR
#\P !V4p RV R&\#V 4#uupiuupi EKQ;i)z1Parse MT5 real account HTML trade history report.ú<tr[^>]*>(.*?)</tr>Fú<t[dh][^>]*>(.*?)</t[dh]>ú\s+rÚTimeTc3ó:<"TFqS^,9xK R#5i)é)Ú.0ÚkwÚcellss& €r
Ú <genexpr>Ú#parse_mt5_report.<locals>.<genexpr>dsřéđOŮ-/u QťxžŰMůsú\d{4}\.\d{2}\.\d{2}c3ó,<"TF qS9xK R#5i)NrV)rWrÚlasts& €r
rZr[jsřéĐTŃ&S 9Ó&SůsÚ/:NéNNÚrealÚsource)r&Úpositionr6r3r4r9r:r<r=r(r;r.r/r0)zTotal Net ProfitÚResultsÚBalanceÚEquity)ÚplacedÚ cancelledÚexpiredÚpartial)r rÚfindallÚDOTALLrrrÚlenÚanyÚmatchrHrÚdictÚzipÚappendr!Ú DataFramerN) rÚtextÚrowsÚtradesÚ in_tradesÚCOLSÚrowÚtraderLrYr^s & @@r
Úparse_mt5_reportr|Pů€ä  €DÜ ŹJŠJĐ-¨t´R·Y±YÓ ?€DŘ€FŘ€Iň ,€DôÜ
2026-04-12 18:25:46 +10:00
ĐĽbżiąiÓHŮAFÓ¸A” ¤V¨AŁYÓŃGç U1•X Ô'¬C°«J¸"Ô,<Ř ßŮ ß —S“SôOŮO—S—S’SôOŮO÷OňOâ ä u‹:Ö ¤§˘Đ)?ŔŔqĹ× JŐ JŮ',Ó2ˇu ”IA—GGIˇuŃ2TŃ&SÓTŹsŹsŠsÔTŃ&SÓT×Ü5z¤b§h˘hĐ/EŔuČQĹx×&PŇ&PÚŘ”c% ť(“mÔđ
ÜśS  u¨SĄzÓ3Ř
$ń/÷6 Ůä ŹŠ€BŘ€B€x 2‹;Đůň=Hůň3řđ
2026-04-12 18:25:46 +10:00
ŰúsÁ,8I?Ĺ# JĹ1JČ-J Ę Jc"ó¤\V4p\P!RV\P4p\ V4^8dR#\P!RV^,\P4pRp.pVEFp\P!RV\P4Uu.uF2p\P
!RR\
2026-04-12 18:25:46 +10:00
V44P4NK4 ppVUu.uFqw'gK VNK ppV'gRV9dR pK•V'dV^,R
8Xd
R V9dK´V'g\ V4^g\P!R V^,4'gVPV4EK
2026-04-12 18:25:46 +10:00
V'gR#.R$Op .p
VF4p\\WR\ V 444p V
PV 4K6 \P!V
4p WĚR,PRR.4,p /p
.pV P4EF|wppVP!RR4P4pVP!RR4P4pV'gKQVR8Xd$V
P#V.4PV4K{VR8XgK„V
P!V.4pV'gK VP%^4pVPRVR
,RVR
,RVRVP!RR4RVR,RVR,RVR,RRR RR\'VP!R^44R\'VP!R^44R\'VP!R^44RVP!RR4R!VP!RR4/4EK V'gR#\P!V4pR"VR#&\)V4#uupiuupi)%zQ
Parse MT5 Strategy Tester HTML report.
Pairs in/out deals into complete trades.
z<table[^>]*>(.*?)</table>NrPFrQrRrÚDealsTrSÚDealr\ÚtimeÚdealr6r3Ú directionr9Úpricer.r/r0r4ÚinÚoutrr&r(r:r;r<r=rcÚbacktestrb)
r€rr6r3rr9rÚorderr.r/r0Úbalancer4)r rrkrlrmrrrrorrrprqr!rsÚisinÚiterrowsrFÚ
setdefaultÚpoprrN)rrtÚtablesruÚin_dealsÚ deal_rowsryrzrYÚ DEAL_COLSÚdealsÚdf_dealsÚ
open_stackrvÚ_rÚsymÚdirnÚstackÚentryrLs& r
Úparse_backtest_reportršs3ô

€DÜ
ŹZŠZĐ4°dĽBżIąIÓ
2026-04-12 18:25:46 +10:00
F€FÜ
6{Q„Ůä
Ź:Š:Đ,¨f°Q­iĽżąÓ C€Dđ€HŘ€IÜäź*š*Đ%AŔ3ĚĎ É ÔTŮR ¤V¨AŁYÓ đTá'™EqŁQ—™EĐŮ Ř  Ř ß  FÔ*¨v¸¬Ů ß ‰8śE›
 ¬BŻHŞHĐ5KČUĐSTÍX×,VÔ,VŘ × Ń  ÷ ŮňY€Iđ
€EŰÜ Y O¤S¨Ł^Đ 4Ó 6Ř
2026-04-12 18:25:46 +10:00
Ź ńôŹ|Š|"€HŘ .×3°T¸5°MÓC€Hđ
€JŘ€Fŕ×$×&‰Źx‰x %×-ŘŹx‰x  RÓ0÷Ů ŕ 4Ś<Ř × ! #  *× 1°$Ö
UŽ]Ř—N‘N 3¨Ó+‰uŘź ™  !› Ř
2026-04-12 18:25:46 +10:00
Ř 5¨Ą=Ř  4¨Ą<Ř  5§9ˇ9¨V°RÓ#8Ř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