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

 
mytarmailS:

I'm not dividing any twos there.

here's the code in normal language :Z

I throw out of the dataset all the clocks except for the right ones. There's no way to go wrong here.

Next, I just take the 5 minutes of each hour and make columns of them, sequentially

# leave only n hours in the dataset
    prices = prices.drop(prices.index[~prices.index.hour.isin([first_hour,first_hour+1])])

# get the df datetime indexes objects
    minute = prices.index.minute
    hour = prices.index.hour

# filter df to combine hourly patterns into rows by minute and hour
  grouped_prices = pd.DataFrame()
    for h in range(first_hour,first_hour+2):
       for i in range(0,60,5):
          grouped_prices[str(i) + " " + str(h)] = prices.iloc[(minute==i) & (hour==h)].reset_index()['close']
 
Maxim Dmitrievsky:

here's the code in normal language :Z

Some scribbles, ugh, it's hard to understand.

 
mytarmailS:

I don't understand any of the scribbles, yuck, it's not clear.

In short, the point is that if you do it right, there will be omissions because of missed quotes. They can not not be

you have to fix them with reindex

 
Maxim Dmitrievsky:

In short, the point is that if you do it right, there will be skips due to missed quotes. They can not not be

you have to fix them via reindex

I don't see them.

 
mytarmailS:

I don't see them.

and you don't drop hours, you take quotes sequentially... so your gaps are filled with values of other hours/minutes (following the gaps)

 
Maxim Dmitrievsky:
and you don't drop hours, but take quotes sequentially... so your gaps are filled with values of other hours/minutes (following the gaps)

No, I divide simply and beautifully


1) I find the beginning of the 5th hour in 5 minutes

if(hrs[i] == 5 & hrs[i-1] == 4)

those - 444445555 this place I get the index i


2) then I take from this index + 23 values

ii <- i:(i+23)


and that's it, and I get my 2 o'clock 5 and 6, the total is 24 values

If there were some gaps, there would be other values instead of the 6th hour, because the indexes are in order

 
mytarmailS:

No, I divide simply and beautifully

"code - ifit's hour 5then takethe indexes from that placeand add 24 hours, those take the full two hours,and output the result"

you add by index. If the next index contains not the 5th hour but 5000006489, then you just copy it. That is, there was a skip in the right hour, and you copied the next to this skip. Although you were supposed to copy the 5-minute symbols of the needed hour, but you did not know about it.

 
mytarmailS:

If there were any omissions, then instead of the 6th hour there would be other ones, because my indexes are in order

The indexes are in order, but the hours are missing. How much to explain )

 
Maxim Dmitrievsky:

the indices are in order, but the hours are missing. How many times do I have to explain)

But I don't print the indices, but the hours by these indices, you see????

and I get the right cut

[1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 [1] 5 5 5 5 5 5 5 5 5 5 5 5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 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6
 
mytarmailS:

but I don't print the indices, but the hours according to these indices, you see????

and I get the right cut.

and the days can be different for these hours, no?

I had the same thing, that's why there were inconsistencies in the charts, and you don't have them for some reason

Reason: