MtApi5: expose SymbolInfoMarginRate#304
Open
biohazardxxx wants to merge 5 commits into
Open
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Exposes the MQL5 built-in
SymbolInfoMarginRate()through the MtApi5 connector. The initial and maintenance margin rates for a symbol (which depend on order type and direction) were not reachable from the .NET client; this adds the function end-to-end (C# client → EA handler → recompiled.ex5→ TestClient action).New method on
MtApi5Client:bool SymbolInfoMarginRate(string symbolName, ENUM_ORDER_TYPE orderType, out double initialMarginRate, out double maintenanceMarginRate)Returns the native function's
booland writes the two rates to theoutparameters.Implementation notes
GetSymbols = 306:devdoes not yet contain the calendar ids 307–316 proposed in MtApi5: expose MT5 economic calendar (Calendar* functions) #301, and 380 stays clear of any collision with them.SymbolInfoSessionQuote(id 58) multi-value pattern. Wire format: request params{Symbol: string, OrderType: int}; response{RetVal: bool, Result: {Initial: double, Maintenance: double}}.SendCommand<FuncResult<Dictionary<string, double>>>and readsInitial/MaintenancewithTryGetValue; on a null or malformed response theoutparams are set to 0 and the method returnsfalse(same fallback idiom asSessionQuote'sDateTime.MinValue).ENUM_ORDER_TYPEalready existed inMt5Enums.csand serializes as an int under the default Newtonsoft settings, so no new enums or DTOs were needed.mq5/MtApi5.mq5) — handler readsOrderTypeviaGET_INT_JSON_VALUE, casts it toENUM_ORDER_TYPE, initializes the two doubles to 0.0 before the call, and serializes the result viaJSONNumber(double).SymbolInfoMarginRateonEURUSD/ORDER_TYPE_BUY, next to the existing SessionQuote/SessionTrade buttons.Mt5CommandType.csand theADD_EXECUTORregistration, case-sensitive request-key match on both sides, response envelope exactly matching theFuncResult<Dictionary<string, double>>deserialization) and found no defects.Testing
MtApi5andMtApi5TestClientbuild clean in Release (the TestClient's 332 nullable warnings are pre-existing ondev, none in the added code).MtApi5.mq5compiles via MetaEditor with "Result: 0 errors"; the recompiledmq5/MtApi5.ex5is committed.🤖 Generated with Claude Code