84 lines
3.3 KiB
MQL5
84 lines
3.3 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| AccountInfo.mqh |
|
|
//| Copyright 2026, Niquel Mendoza. |
|
|
//| https://www.mql5.com/ |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2026, Niquel Mendoza."
|
|
#property link "https://www.mql5.com/"
|
|
#property strict
|
|
|
|
#ifndef LLMAGENTSBASICTOOLS_SRC_UTILS_ACCOUNT_INFO_MQH
|
|
#define LLMAGENTSBASICTOOLS_SRC_UTILS_ACCOUNT_INFO_MQH
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
#include "..\\Def.mqh"
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
namespace TSN
|
|
{
|
|
//+------------------------------------------------------------------+
|
|
//| name: account_info |
|
|
//| desc: Returns an AccountInfoDouble/Integer/String property |
|
|
//| params: |
|
|
//| mode integer 0=double, 1=integer, 2=string. Default 0 |
|
|
//| property string Name of the ENUM_ACCOUNT_INFO_* property |
|
|
//| matching the selected mode |
|
|
//+------------------------------------------------------------------+
|
|
class CLlmBToolAccountInfo : public CLLmTool
|
|
{
|
|
public:
|
|
CLlmBToolAccountInfo(void) : CLLmTool("account_info") {}
|
|
~CLlmBToolAccountInfo(void) {}
|
|
|
|
void Run(CJsonNode& param, CJsonBuilderStr* &out) override final
|
|
{
|
|
out = m_shared_builder;
|
|
const int mode = int(param["mode"].ToInt(LLMAGENT_BTOOLS_MODE_DOUBLE));
|
|
|
|
//---
|
|
m_shared_builder.PutChar('"');
|
|
m_shared_builder.Obj();
|
|
switch(mode)
|
|
{
|
|
//--- DOUBLE
|
|
case LLMAGENT_BTOOLS_MODE_DOUBLE:
|
|
{
|
|
m_shared_builder.KeyWV("ok").Val(true);
|
|
m_shared_builder.KeyWV("result").Val(AccountInfoDouble(CEnumRegBasis::GetValNoRef<ENUM_ACCOUNT_INFO_DOUBLE>(param["property"].ToString(""), WRONG_VALUE)));
|
|
break;
|
|
}
|
|
|
|
//--- INTEGER
|
|
case LLMAGENT_BTOOLS_MODE_INTEGER:
|
|
{
|
|
m_shared_builder.KeyWV("ok").Val(true);
|
|
m_shared_builder.KeyWV("result").Val(AccountInfoInteger(CEnumRegBasis::GetValNoRef<ENUM_ACCOUNT_INFO_INTEGER>(param["property"].ToString(""), WRONG_VALUE)));
|
|
break;
|
|
}
|
|
|
|
//--- STRING
|
|
case LLMAGENT_BTOOLS_MODE_STRING:
|
|
{
|
|
m_shared_builder.KeyWV("ok").Val(true);
|
|
m_shared_builder.KeyWV("result").ValS(AccountInfoString(CEnumRegBasis::GetValNoRef<ENUM_ACCOUNT_INFO_STRING>(param["property"].ToString(""), WRONG_VALUE)));
|
|
break;
|
|
}
|
|
|
|
default:
|
|
{
|
|
m_shared_builder.KeyWV("ok").Val(false);
|
|
m_shared_builder.KeyWV("error").ValS(StringFormat("Invalid mode = %d", mode));
|
|
break;
|
|
}
|
|
}
|
|
m_shared_builder.EndObj();
|
|
m_shared_builder.PutChar('"');
|
|
}
|
|
};
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
#endif // LLMAGENTSBASICTOOLS_SRC_UTILS_ACCOUNT_INFO_MQH
|