1
$\begingroup$

I am trying to classify stock images into 4 categories:

  • Category 1: Image patterns which gives more than 10% profit next 3 day.
  • Category 2: Image patterns which gives less than 10% profit but greater than 0% next 3 day.
  • Category 3: Image patterns which gives more than -0.01% but greater than -10% loss next 3 day.
  • Category 4: Image patterns which gives more than -10% loss next 3 day

I have divided these Images in to 4 category, below are the Images from category 1 and category 2.

Image contains 10 day stock movement, and classification category are generate from next 3 day stock data.

Red Bar is volume Traded of that stock.

Pink line is RSI(14) (Relative strength Index)

Yellow line is stock price.

Blue and Green line are moving average 10, 20 respectively.

enter image description here enter image description here

I know by seeing the image it is hard to differentiate between them but this is what I am trying to find out can I classify it using CNN.

My CNN:

  (layer1): Sequential(
    (0): Conv2d(3, 64, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))
    (1): ReLU()
    (2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
  )
  (layer2): Sequential(
    (0): Conv2d(64, 128, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))
    (1): ReLU()
    (2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
  )
  (layer3): Sequential(
    (0): Conv2d(128, 256, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))
    (1): ReLU()
    (2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
  )
  (drop_out): Dropout(p=0.5, inplace=False)
  (fc1): Linear(in_features=65536, out_features=1024, bias=True)
  (fc2): Linear(in_features=1024, out_features=512, bias=True)
  (fc3): Linear(in_features=512, out_features=128, bias=True)
  (fc4): Linear(in_features=128, out_features=4, bias=True)

Optimizer: Adam, Loss: CrossEntropyLoss.

But the problem is CNN ends up classifying same class for each image to obtain 25% accuracy.

Am I working in wrong direction, should I work on imporving data or try other technique like LSTM?

$\endgroup$
2
  • $\begingroup$ just a suggestion. Not every indicator works good for all types of trend know (upward, downside, sidewise market). So, shall we add more info/indicators to the image, instead of only RSI and MA.? $\endgroup$ Dec 19, 2019 at 6:32
  • $\begingroup$ if the model classifies all images in the same class, there is good chance it is simply an implementation error. It would help if share details of your code from start to end, including architecture, the way you feed the data etc... $\endgroup$
    – serali
    Dec 19, 2019 at 11:29

1 Answer 1

1
$\begingroup$

I like this question!

Potential pitfalls:

1. Architecture is just not sophisticated enough to catch all nuances in the time-series image. Take a look at here what they did for earthquake-time-eries-as-images approach or take a look at this paper. You could take some guidelines from there, but you notice right away that the architecture is bigger. Or this one

2. Data, you say its predicting only one class, but what part of the image is it focusing on. Use shap values for images to inspect. I suspect following: it will be some trend that is consistent only for one class, hence you can think about pre-processing steps that can point to properties on images of other classes. Or even add some hand-crafted numeric features. In any case increase your dataset if you havent already, you want to have enough information to catch all nuances.

$\endgroup$
1
  • $\begingroup$ Thank you for suggestions I will look into it. $\endgroup$
    – ooo
    Dec 19, 2019 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.