Liquidación de fondo???? - página 8

 
Алексей Тарабанов #:
También le planteo a mi nieta un problema: Hay una relación entre Z e Y e Y y X. Dibuja una gráfica de la dependencia de Z con respecto a X. Gráficamente. Lo dibuja.

Gracias, ya veo.

 
prostotrader #:

De todos modos, miré 500 registros, no puedo estar 100% seguro sin el original

Pero te faltan comillas, es posible que en MT5 también (pero mucho menos)

Voy a tratar de traducir su tiempo en "digerible" y extraer BID y ASK por separado en MT5,

Pero ya ves que hay demasiadas discrepancias.

Sí, hay discrepancias. La tabla y los tipos agregados proporcionados por la bolsa no son 100% fiables. Así lo indica la propia bolsa.
Los datos 100% fiables, de nuevo según la bolsa, sólo están en la tabla orders_log, pero cuesta dinero extra suscribirse a ella.
De qué flujos y tablas toma MT5 los datos, y cómo los toma, no puedo afirmarlo al 100%, sólo puedo especular.
Por lo tanto, utilizo mi propio software para mis fines, porque veo cómo y de dónde se toman los datos.
Estoy satisfecho con los resultados obtenidos hasta ahora.

 
Vladimir Mikhailov #:

Sí, hay discrepancias. La tabla común y los bombos agregados transmitidos por la bolsa no son 100% fiables. Así lo indica la propia bolsa.
Los datos 100% fiables, siempre según la bolsa, sólo están en la tabla orders_log, pero su suscripción cuesta algo de dinero.
De qué flujos y tablas toma MT5 los datos, y cómo los toma, no puedo afirmarlo al 100%, sólo puedo especular.
Por lo tanto, utilizo mi propio software para mis fines, porque veo cómo y de dónde se toman los datos.
Estoy satisfecho con los resultados obtenidos hasta ahora.

MT5 toma los datos del mismo lugar del que los obtuviste, PlazaII.

He convertido tu tiempo, hay demasiadas diferencias, las citas son las mismas pero el tiempo es diferente.

Ha omitido las comillas en rojo.

Convertidor de tiempo

//+------------------------------------------------------------------+
//|                                                    Convertor.mq5 |
//|                                     Copyright 2021, prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, prostotrader"
#property link      "https://www.mql5.com"
#property version   "1.00"
#define  STR_POS 8
ulong base_time_ns;
ulong add_time; //добивка до Московского времи

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
string GetTime(const string b_str)
{
  ulong cur_time = ulong(StringToInteger(b_str));
  if(cur_time > 0)
  {
    ulong full_time = (cur_time + add_time);
    ulong diff_time = full_time - base_time_ns;
    if(diff_time > 0)
    {
      ulong sec_time = ulong(double(full_time)/1000000000);
      ulong ms_time = ulong(double((full_time - sec_time*1000000000))/1000000); 
      ulong mcs_time = ulong(double( full_time - (sec_time*1000000000 + ms_time*1000000))/1000);
      ulong ns_time = full_time - (sec_time*1000000000 + ms_time*1000000 + mcs_time*1000);
      return(TimeToString(datetime(sec_time), TIME_SECONDS) + "." + StringFormat("%03i", ms_time) +
             "." + StringFormat("%03i", mcs_time) + "." + StringFormat("%03i", ns_time));
    }
    else return("Time out of range!"); 
  }
  return("");
}
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
bool GetParams(const string a_str, string &a_1, string &a_2, string &a_3,
                     string &a_4, string &a_5, string &a_6, string &a_7,
                     string &a_8,string &a_9)
{
  if(base_time_ns > 0)
  {
    string tmp_str = a_str;
    int cnt = 0;
    while(cnt<STR_POS)
    {
      int a_pos = StringFind(tmp_str, ";");
      if(a_pos > 0)
      {
        switch(cnt)
        {
          case 0:
            a_1 = StringSubstr(tmp_str, 0, a_pos);
          break;
          case 1:
            a_2 = StringSubstr(tmp_str, 0, a_pos);
          break;
          case 2:
            a_3 = StringSubstr(tmp_str, 0, a_pos);
          break;
          case 3:
            a_4 = StringSubstr(tmp_str, 0, a_pos);
          break;
          case 4:
            a_5 = StringSubstr(tmp_str, 0, a_pos);
          break;
          case 5:
            a_6 = StringSubstr(tmp_str, 0, a_pos);
          break;
          case 6:
            a_7 = StringSubstr(tmp_str, 0, a_pos);
          break;
          case 7:
            a_8 = GetTime(StringSubstr(tmp_str, 0, a_pos));
            a_9 = GetTime(StringSubstr(tmp_str, a_pos + 1));
          break;
        }
      }
      tmp_str = StringSubstr(tmp_str, a_pos + 1);
      cnt++;
    }
    return(true);
  }
  return(false);
}
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
  int str_cnt = 0;
  base_time_ns = ulong(D'20.10.2021 07:00:00') * 1000 * 1000 * 1000;
  add_time = (3*3600);
  add_time = add_time*1000000000;
  string in_str, par_1, par_2, par_3, par_4, par_5, par_6, par_7, par_8, par_9;
  int in_handle=FileOpen("gazp-20-10-2021.csv",FILE_READ|FILE_ANSI|FILE_CSV); 
  if(in_handle!=INVALID_HANDLE)
  {
    int out_handle=FileOpen("gazp-20-10-2021_new.csv",FILE_WRITE|FILE_CSV); 
    if(out_handle!=INVALID_HANDLE)
    {
      while(!FileIsEnding(in_handle))
      {
        if(str_cnt == 0)
        {
          in_str = FileReadString(in_handle);
          FileWrite(out_handle, "id", "best_buy", "xamount_buy", "best_sell", "xamount_sell", "price", "xamount", "deal_time_ns", "mod_time_ns");
        }
        else
        {
          in_str = FileReadString(in_handle);
          if(StringLen(in_str) > 0)
          {
            if(GetParams(in_str, par_1, par_2, par_3, par_4, par_5, par_6, par_7, par_8, par_9) == true)
              FileWrite(out_handle, par_1, par_2, par_3, par_4, par_5, par_6, par_7, par_8, par_9);
          }
        }
        str_cnt++;
      } 
      FileClose(out_handle);
    }
    FileClose(in_handle);
  }   
//---
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+

No busqué más en el archivo

Archivos adjuntos:
 

¡Vladimir!

Por supuesto, puede haber fallos puntuales, pero te faltan muchas comillas, y MT-5 tiene un problema con el tiempo

(por lo que tengo entendido, sólo se copia la hora de la tabla sin hacer nada con ella),

parece que lo "guardan" ellos mismos (el tiempo).

Compruebe su código (por si hay omisiones)

¿Estás usando "0" aquí?

result = cg_conn_process(conn, 0, NULL);
Archivos adjuntos:
 
prostotrader #:

¡Vladimir!

Por supuesto, puede haber fallos puntuales, pero te faltan muchas comillas, y MT-5 tiene un problema con el tiempo

(por lo que tengo entendido, sólo se copia la hora de la tabla sin hacer nada con ella),

parece que lo "guardan" ellos mismos (el tiempo).

Compruebe su código (por si hay omisiones)

¿Estás usando "0" aquí?

Sí, el tiempo se toma de la mesa.
En conn_process se utiliza 0.

No hay saltos.

Aquí está el código de la función colback:

CG_RESULT MessageCallbackQuote(cg_conn_t* conn, cg_listener_t* listener, struct cg_msg_t* msg, void* data)
{
        static size_t offset_isin_id = 0;
        static size_t offset_best_buy = 0;
        static size_t offset_xamount_buy = 0; //i8
        static size_t offset_best_sell = 0;
        static size_t offset_xamount_sell = 0; //i8
        static size_t offset_price = 0; //d16.5
        static size_t offset_xamount = 0; //i8
        static size_t offset_deal_time_ns = 0; //u8
        static size_t offset_replAct = 0; //i8
        static size_t offset_mod_time_ns = 0; //u8

        switch (msg->type)
        {
        case CG_MSG_STREAM_DATA:
        {
                int64_t price_int = 0;
                int8_t price_scale = 0;
                long long xamount_buy = 0;
                long long xamount_sell = 0;
                double price;
                long long xamount = 0;
                unsigned long long deal_time_ns = 0;
                unsigned long long mod_time_ns = 0;
                double best_buy = 0;
                double best_sell = 0;

                cg_msg_streamdata_t* replmsg = (cg_msg_streamdata_t*)msg;
                char* data = (char*)replmsg->data;
                if (*(int64_t*)(data + offset_replAct) == 0 && fut_isin_id == *((int32_t*)(data + offset_isin_id)))
                {
                        cg_bcd_get(((char*)(data + offset_best_buy)), &price_int, &price_scale);
                        best_buy = ((double)price_int) / (pow(10.0, price_scale));

                        cg_bcd_get(((char*)(data + offset_best_sell)), &price_int, &price_scale);
                        best_sell = ((double)price_int) / (pow(10.0, price_scale));

                        cg_bcd_get(((char*)(data + offset_price)), &price_int, &price_scale);
                        price = ((double)price_int) / (pow(10.0, price_scale));

                        xamount_buy = *((int64_t*)(data + offset_xamount_buy));
                        xamount_sell = *((int64_t*)(data + offset_xamount_sell));
                        xamount = *((int64_t*)(data + offset_xamount));

                        mod_time_ns = *((uint64_t*)(data + offset_mod_time_ns));
                        deal_time_ns = *((uint64_t*)(data + offset_deal_time_ns));

                        size_t s = quote.size();
                        if (s == 0)
                        {
                                quote.push_back(SQuote(best_buy, xamount_buy, best_sell, xamount_sell, price, xamount, deal_time_ns, mod_time_ns));
                        }
                        else
                        {
                                if (quote[s - 1].best_buy != fut_bid || quote[s - 1].best_sell != fut_ask ||
                                        quote[s - 1].xamount_buy != xamount_buy || quote[s - 1].xamount_sell != xamount_sell ||
                                        quote[s - 1].price != price || quote[s - 1].xamount != xamount ||
                                        quote[s - 1].deal_time_ns != deal_time_ns)
                                {
                                        quote.push_back(SQuote(best_buy, xamount_buy, best_sell, xamount_sell, price, xamount, deal_time_ns, mod_time_ns));
                                }
                        }
                        
                        return(0);
                }
        }
        break;
        case CG_MSG_OPEN:
        {
                struct cg_scheme_desc_t* schemedesc = 0;
                cg_lsn_getscheme(listener, &schemedesc);

                size_t msgidx = 0;
                for (cg_message_desc_t* msgdesc = schemedesc->messages; msgdesc; msgdesc = msgdesc->next, msgidx++)
                {
                        size_t fieldindex = 0;
                        if (strcmp(msgdesc->name, "common") == 0)
                        {
                                for (cg_field_desc_t* fielddesc = msgdesc->fields; fielddesc; fielddesc = fielddesc->next, fieldindex++)
                                {
                                        if (strcmp(fielddesc->name, "replAct") == 0 && strcmp(fielddesc->type, "i8") == 0)
                                        {
                                                offset_replAct = fielddesc->offset;
                                        }
                                        else if (strcmp(fielddesc->name, "isin_id") == 0 && strcmp(fielddesc->type, "i4") == 0)
                                        {
                                                offset_isin_id = fielddesc->offset;
                                        }
                                        else if (strcmp(fielddesc->name, "best_buy") == 0 && strcmp(fielddesc->type, "d16.5") == 0)
                                        {
                                                offset_best_buy = fielddesc->offset;
                                        }
                                        else if (strcmp(fielddesc->name, "best_sell") == 0 && strcmp(fielddesc->type, "d16.5") == 0)
                                        {
                                                offset_best_sell = fielddesc->offset;
                                        }
                                        else if (strcmp(fielddesc->name, "mod_time_ns") == 0 && strcmp(fielddesc->type, "u8") == 0)
                                        {
                                                offset_mod_time_ns = fielddesc->offset;
                                        }
                                        else if (strcmp(fielddesc->name, "deal_time_ns") == 0 && strcmp(fielddesc->type, "u8") == 0)
                                        {
                                                offset_deal_time_ns = fielddesc->offset;
                                        }
                                        else if (strcmp(fielddesc->name, "price") == 0 && strcmp(fielddesc->type, "d16.5") == 0)
                                        {
                                                offset_price = fielddesc->offset;
                                        }
                                        else if (strcmp(fielddesc->name, "xamount_buy") == 0 && strcmp(fielddesc->type, "i8") == 0)
                                        {
                                                offset_xamount_buy = fielddesc->offset;
                                        }
                                        else if (strcmp(fielddesc->name, "xamount_sell") == 0 && strcmp(fielddesc->type, "i8") == 0)
                                        {
                                                offset_xamount_sell = fielddesc->offset;
                                        }
                                        else if (strcmp(fielddesc->name, "xamount") == 0 && strcmp(fielddesc->type, "i8") == 0)
                                        {
                                                offset_xamount = fielddesc->offset;
                                        }
                                }
                        }
                }
        }
        break;
        case CG_MSG_P2REPL_ONLINE:
        {
                printf("%s: Futures qoute online!\n", cserver_time);
                fut_is_ready = true;
        }
        break;
        case CG_MSG_CLOSE:
        {
                printf("%s: Futures qoute offline!\n", cserver_time);
                fut_is_ready = false;
        }
        break;
        }
        return 0;
};
 
Vladimir Mikhailov #:

No hay omisiones.


Explica, por favor....

 
prostotrader #:

Explique, por favor....

Esta construcción significa que cada registro que tiene cambios se guarda.

size_t s = quote.size();
if (s == 0)
{
        quote.push_back(SQuote(best_buy, xamount_buy, best_sell, xamount_sell, price, xamount, deal_time_ns, mod_time_ns));
}
else
{
        if (quote[s - 1].best_buy != fut_bid || quote[s - 1].best_sell != fut_ask ||
                quote[s - 1].xamount_buy != xamount_buy || quote[s - 1].xamount_sell != xamount_sell ||
                quote[s - 1].price != price || quote[s - 1].xamount != xamount ||
                quote[s - 1].deal_time_ns != deal_time_ns)
        {
                quote.push_back(SQuote(best_buy, xamount_buy, best_sell, xamount_sell, price, xamount, deal_time_ns, mod_time_ns));
        }
}
 
Vladimir Mikhailov #:

Esta construcción significa que cada registro que tiene cambios se guarda.

No me refería al código, sino a la tabla comparativa, que muestra que MT5 tiene una cotización y tú no.

 
prostotrader #:

No me refería al código, sino a la tabla comparativa, que muestra que MT5 tiene una cotización y tú no.

Lo más probable es que en MT5 los datos se tomen de orders_log o FAST.

 
Vladimir Mikhailov #:

Esta construcción significa que cada registro que tiene cambios se guarda.

¿Y desde dónde se llama? ¿Del Asesor Experto? Si es del Experto, habrá omisiones.

Razón de la queja: