Forums  > Trading  > how to take advantage of PyTorch  
Page 1 of 1
Display using:  


Total Posts: 9
Joined: Feb 2019
Posted: 2019-02-16 04:05
i'm in process of learning/building my first neural network to try to predict intraday swing highs/lows for a set of highly correlated securities. i've seen and used a prediction software that was built on top of a neural network integrating hurst, and it had pretty good performance (10-20% edge). Sadly, i no longer have access to the software (the creator went off and is using it to manage money themselves). However, with the recent developments in machine learning (tensorflow and pytorch) perhaps i'll be able to a learning experiment, thats my goal.

I'm not an expert programmer....very far from it...but i understand the basics (variables, objects, if/else/then, loops, input/output, ect..)

(i worked as a visual basic programmer a number of years back...nothing sexy, but lots of basic data entry, storage, retrieval, etc...).

I took intro cal in college (don't remember much)...i understand the basic concept of statistics (1/36 = 6*6 chance of rolling snake eyes at the craps table tru odds should pay 35:1... but really only pays 30:1 so the house has a 1/7th advantage which seems crazy high at 14%) and i recall some basic linear algrebra (forgot most of it)

Ok, so now i watched some youtube videos on tensorflow and pytorch, and i'm thinking "lets do this" and then i watch a more detailed video...and it just goes "zing" right over my head...i keep falling asleep trying to learn how to assemble the python code.

help me...please.

First, i need to understand, should i go down the road of tensorflow, or pytorch. The basic jist of the model is that markets go thru periods of compression (tight coils) and extension (relatively fast trends that end in a pop, and then retreat). Which neural network framework / model should i be trying to implement, which software should i be using, etc...

the inputs are 5 second bars (open, high, low, close, volume)

what should i try first?


Total Posts: 39
Joined: Apr 2018
Posted: 2019-02-17 16:39
If you know exactly the patterns that you're looking for (compression and extension as you call it), why use neural networks? Just look at the data and test your hypothesis.

If you want to get your feet wet with neural networks, just pick a popular dataset like MNIST. TensorFlow (with Keras) and PyTorch are equally easy for standard off-the-shelf models. I think PyTorch is easier to tinker with the internals.

I don't know if NN is a good tool for predicting the market. I'm not an expert and I hope someone who has more experience will chime in here. But my biggest reservations are: 1) it's a black box so you don't know why it works or when it stops working, 2) it's hard to measure its statistical significance -- you could do cross validation, but if you try 1000 different hyperparameter combinations, then your validation set is no longer out of sample.

Related to 1, there's a story of a neural network trained to detect tanks in pictures. It turns out that the pictures with tanks in the training set were taken on cloudy days. So the neural network learned to distinguish the color of the sky instead of detecting tanks. As an analogue in trading, if you train a neural network to predict the market during a bull market, it will just tell you to go long.

The appeal of NN is that it automatically discovers complicated structures in your data. It works well when there is a clear but hard-to-describe pattern in the data, like image recognition. In trading we have the opposite problem because the clear patterns are already priced in so they are not very predictive.


Total Posts: 9
Joined: Feb 2019
Posted: 2019-02-17 17:37
is there a good way to visualize the solution that a neural network creates?

i'm a much more visual person, so the math equations don't have significant meaning in my brain without a graphical representation.


Total Posts: 1093
Joined: Jun 2007
Posted: 2019-02-17 19:20
"tensorflow, or pytorch"

If you are a beginner, I would recommend keras.
look here for keras

Keras is an API that can be used to access different deep learning frameworks. I would recommend to use the combination keras and tensorflow => you will use keras, keras will cal tensorflow under th hood. After the installation you won't recognize you are using tensorflow.

Just follow the instructions. On a linux machine it should be easy to set up Keras + Tensor flow.

There are also AWS ec2 deep-learning instances available, with keras/tensorflow pre-installed.

But if you actually get bored by these videos I am not sure if that whole quant thingy is for you?

And like everybody here will tell you, if you have a clear idea what pattern you are looking for, stay away from deep nets.

Ich kam hierher und sah dich und deine Leute lächeln, und sagte mir: Maggette, scheiss auf den small talk, lass lieber deine Fäuste sprechen...


Total Posts: 9
Joined: Feb 2019
Posted: 2019-02-18 18:42
so, i don't know "exactly" the patterns that i'm looking for....however i am looking for something that will attempt to identify significant swing high/swing low points that results in at least x ticks during a markets regular trading hours. i'm working on code that will first identify those swing high/low points to feed into the NN as "supervised training" (i hope i'm using that term correctly). i see certan patterns on the charts, but they are not i'm hoping a NN will be able to help sort out some of what appears random to me.


Total Posts: 9
Joined: Nov 2018
Posted: 2019-02-24 15:56
I think you should take a general machine learning course first and figure out what each model does before diving into parameter tuning/model calibration. There are different types of nonlinear models and NN is only one of them. Even simple linear models can produce fruitful results if you provide right features.
Previous Thread :: Next Thread 
Page 1 of 1