Machine learning in trading: theory, models, practice and algo-trading - page 3301

 
mytarmailS #:

like that?

and can it really handle a million conditions?

I'm a bit lost with this switch and C++ stuff.

The first two functions are R implementation, the last one is switch in C++.

Unit: microseconds
                              expr    min     lq      mean median     uq       max neval
     rule(n = sample(1:200, 1), x) 40.482 44.473  57.18044 46.754 51.886  2688.931  1000
    rule2(n = sample(1:200, 1), x) 29.079 35.351 567.03671 38.202 43.904 86712.314  1000
 rule_cpp(n = sample(1:200, 1), x) 31.360 34.781  53.26793 36.491 40.482  4924.005  1000

In fact, there is no gain at all, how can this be?...
 
mytarmailS #:

I'm a bit lost with this switch and C++ thing.

the first two functions are R implementation, the last one is switch in C++.

In fact, there is no gain at all, how can it be...?

Can you show me the code?

Probably you are wasting a function when the answer has already been received...

 
Aleksey Vyazmikin #:

Can you show me the code?

Probably you are running the function in vain, when the answer is already received...

The code is the same as the one I posted, except I made the rules 300 instead of 5.

What's the point of posting the code?
I've already decided on the architecture
 
mytarmailS #:
The code is the same as you posted, except I made the rules 300 instead of 5

What's the point of posting the R code?
I've already decided on the architecture

The question is in the code of the function call.

 
Aleksey Vyazmikin #:

The question is in the function call code.

I don't get it
 
mytarmailS #:

Basically no gain at all, how can that be...

There's a lot of things that could be. The script is attached, below is the function part.

bool Rule0( const vector<double> &x ) { return(x[3] > x[4]); }
bool Rule1( const vector<double> &x ) { return(x[0] < x[4]); }
bool Rule2( const vector<double> &x ) { return(x[1] >= x[0]); }
bool Rule3( const vector<double> &x ) { return(x[3] == x[4]); }
bool Rule4( const vector<double> &x ) { return(x[0] != x[4]); }
bool Rule5( const vector<double> &x ) { return(x[1] >= x[0]); }
bool Rule6( const vector<double> &x ) { return(x[3] <= x[4]); }
bool Rule7( const vector<double> &x ) { return(x[0] < x[4]); }
bool Rule8( const vector<double> &x ) { return(x[1] >= x[0]); }
bool Rule9( const vector<double> &x ) { return(x[3] <= x[4]); }

bool rule3( const int n, const vector<double> &x )
{
  typedef bool (*RULE)( const vector<double>& );
  static const RULE Rules[] = {Rule0, Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, Rule7, Rule8, Rule9,
                               Rule0, Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, Rule7, Rule8, Rule9,
                               Rule0, Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, Rule7, Rule8, Rule9,
                               Rule0, Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, Rule7, Rule8, Rule9,
                               Rule0, Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, Rule7, Rule8, Rule9,
                               Rule0, Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, Rule7, Rule8, Rule9,
                               Rule0, Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, Rule7, Rule8, Rule9,
                               Rule0, Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, Rule7, Rule8, Rule9,
                               Rule0, Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, Rule7, Rule8, Rule9,
                               Rule0, Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, Rule7, Rule8, Rule9};

  return(Rules[n](x));
}

#define  BENCH(A)                                                              \
  StartTime = GetMicrosecondCount();                                          \
  A;                                                                          \
  Print(#A + " - " + (string)(GetMicrosecondCount() - StartTime) + " mcs");

void OnStart()
{
  const vector<double> x = {1, 2, 3, 4, 5};
  int Tmp = 0;

  ulong StartTime;

  BENCH(for (uint i = 1 e8; (bool)i--;) Tmp += rule(i % 100, x));
  BENCH(for (uint i = 1 e8; (bool)i--;) Tmp += rule2(i % 100, x));
  BENCH(for (uint i = 1 e8; (bool)i--;) Tmp += rule3(i % 100, x));
//  BENCH(for (uint i = 1e8; (bool)i--;) Tmp += rule(i % 100, x));  // Если добавить эту строку, то выше rule замедлится.
//  BENCH(for (uint i = 1e8; (bool)i--;) Tmp += rule2(i % 100, x)); // Если добавить эту строку, то выше rule2 замедлится.
//  BENCH(for (uint i = 1e8; (bool)i--;) Tmp += rule3(i % 100, x)); // Если добавить эту строку, то выше rule3 замедлится.

  Print(Tmp);
}


Result.

for (uint i = 1 e8; (bool)i--;) Tmp += rule(i % 100, x) - 505436 mcs
for (uint i = 1 e8; (bool)i--;) Tmp += rule2(i % 100, x) - 261261 mcs
for (uint i = 1 e8; (bool)i--;) Tmp += rule3(i % 100, x) - 709846 mcs


It is not clear what is measured here - see the highlighted comments. Allegedly much faster than rule2.

Files:
 
fxsaber #:

Interestingly, in terms of having a quantity of data (quotes), the human brain (as a neural network) compared to MO is like an infusoria compared to a human.

However, so primitive humans have proven that they can create pretty good working TCs. It turns out that it does not require such a huge amount of data to create a working TC.

It is a mystery to me how, for example, man got to the point of working scalper models. It was done almost entirely without number crunchers.


The scenario for this was apparently something like this:

  1. I often see some kind of flattening (I've been stupidly grinding on the screen for a few days).
  2. I will try to make money on it with a primitive TS.
  3. It does not drain much. I should refine the TS a bit. I looked at the trading history - it looks like something can be improved.
  4. It started to plus a little. Repeat point 3.
No number cruncher. I just looked at point 1 and started doing it. The probability of this approach seems to be about zero, but somehow it works. Some kind of working mad poke method.


Apparently, on some subconscious human brain is still able to find "patterns" on extremely small amount of data. You can't call it luck. It's a mystery.

Imho, the whole secret is in the transfer of experience, everything new is built on the achievements of the previous generation. Take modern processors. For people from the 19th century it will be magic. For the 20th century, it will be a very complex technology that will not have the right tools to reverse-engineer. Only through knowledge transfer and gradual development can we reach the modern level of technology. That is why they say that if there is World War 3, they will fight with stones in World War 4. There are legends about trading, that earlier markets were much easier, and zenith traders made fortunes with the help of moving averages, now it will not be possible to do so.

 
fxsaber #:

It is quite unclear what is being measured here - see the highlighted comments. Allegedly much faster than rule2.

Here this function and its different implementations (equivalents), including those in C++, were measured.

Well, I have already decided on the architecture for now, I will sit on pure R-ke for now, I have found a way to speed up 25 times + there are still pluses/strong reasons not to add C++ to my code.

 

You can have a challenge with my AMO.

"Solve the TS."


You give me a small piece of data that you use.

You describe what operators, functions and variables you use in the code.

And you give me your eqity or signals of the algorithm.


I create a search grammar, and I pick up the code as a cipher and solve your TS.

 
🤦
Reason: