{"id":191306,"date":"2023-06-02T10:28:10","date_gmt":"2023-06-02T14:28:10","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=191306"},"modified":"2023-06-02T17:01:17","modified_gmt":"2023-06-02T21:01:17","slug":"neural-network-in-python-types-structure-and-trading-strategies-part-iii","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/","title":{"rendered":"Neural Network In Python: Types, Structure And Trading Strategies &#8211; Part III"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em>Get a general introduction to a neuron with&nbsp;<a href=\"\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies\/\">Part I<\/a><\/em> <em>and learn how to train a neural network with <a href=\"\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-ii\/\">Part II.<\/a><\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"neural-network-in-trading\">Neural network in trading<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Neural networks help you develop strategies based on your overall investment strategy \u207d<a href=\"https:\/\/economictimes.indiatimes.com\/markets\/stocks\/news\/how-neural-networks-are-used-in-the-investment-world\/articleshow\/94043039.cms\">\u00b9<\/a>\u207e. Whether it is high-risk and growth-focused (short-term trades) or a conservative approach for long-term investment, it all depends on the kind of trading strategy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, you wish to find a few stocks with particular growth performance or an upward price trend over a period of one year. Now, the neural network can figure out such stocks for your portfolio and hence, make your work easy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, you can give a number of such parameters or necessary pointers to the neural network so that you have exactly what you are looking for with less effort and time.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"neural-network-strategy-in-python\">Neural network strategy in Python<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let us now see the strategical representation with neural networks in Python.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First of all we will import libraries.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-1-importing-libraries\">Step 1: Importing Libraries<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We will start by importing a&nbsp;<a href=\"https:\/\/blog.quantinsti.com\/python-trading-library\">few libraries<\/a>, the others will be imported as and when they are used in the program at different stages. For now, we will import the libraries which will help us in importing and preparing the dataset for training and testing the model.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import numpy as np\nimport pandas as pd\nimport talib<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gist.github.com\/quantra-go-algo\/dc1e7dce9e5c9109b07d7b77a28e95b8#file-importing_libraries-py\">Importing_libraries.py&nbsp;<\/a>hosted with \u2764 by&nbsp;<a href=\"https:\/\/github.com\/\">GitHub<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Numpy is a fundamental package for scientific computing, we will be using this library for computations on our dataset. The library is imported using the alias np.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Pandas will help us in using the powerful dataframe object, which will be used throughout the code for building the artificial neural network in Python.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/blog.quantinsti.com\/install-ta-lib-python\/\">Ta-lib<\/a>&nbsp;is a technical analysis library, which will be used to compute the RSI and Williams %R. These will be used as features in order to train our artificial neural network or ANN. We could add more features using this particular library.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-2-fetching-data-from-yahoo-finance\">Step 2: Fetching data from yahoo finance<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Setting the random seed to a fixed number\nimport random\n# Setting the random seed to a fixed number\n\nimport random\nrandom.seed(42)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gist.github.com\/quantra-go-algo\/9d01b229148dd9513a3eb3e83705e337#file-random_seed-py\">Random_seed.py&nbsp;<\/a>hosted with \u2764 by&nbsp;<a href=\"https:\/\/github.com\/\">GitHub<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Random is used to initialise the seed to a fixed number. This is such that every time we run the code we start with the same seed.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Download the price data of Apple from November 2019 to January 2023\n# Set the ticker as 'AAPL' and specify the start and end dates\n\nprice_AAPL= yf.download('AAPL', start='2017-11-06', end='2023-01-03', auto_adjust = True)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gist.github.com\/quantra-go-algo\/d90b91ee5469a089c50d8d9fc5998d34#file-fetch_aapl_data-py\">Fetch_AAPL_data.py&nbsp;<\/a>hosted with \u2764 by&nbsp;<a href=\"https:\/\/github.com\/\">GitHub<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We have taken Apple\u2019s data for the time period 6th November 2017 to 3rd January 2023.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-3-preparing-the-dataset\">Step 3: Preparing the dataset<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We will be building our input features by using only the OHLC values. This dataset will help us to specify the features for training our neural network in the next step.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Preparing the dataset\nprice_AAPL['H-L'] = price_AAPL['High'] - price_AAPL['Low']\nprice_AAPL['O-C'] = price_AAPL['Close'] - price_AAPL['Open']\nprice_AAPL['3day MA'] = price_AAPL['Close'].shift(1).rolling(window = 3).mean()\nprice_AAPL['10day MA'] = price_AAPL['Close'].shift(1).rolling(window = 10).mean()\nprice_AAPL['30day MA'] = price_AAPL['Close'].shift(1).rolling(window = 30).mean()\nprice_AAPL['Std_dev']= price_AAPL['Close'].rolling(5).std()\nprice_AAPL['RSI'] = talib.RSI(price_AAPL['Close'].values, timeperiod = 9)\nprice_AAPL['Williams %R'] = talib.WILLR(dataset['High'].values, price_AAPL['Low'].values, price_AAPL['Close'].values, 7)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gist.github.com\/quantra-go-algo\/9c725acfe6c242cdcc9e5f6f725c4a7b#file-preparing_dataset-py\">Preparing_dataset.py&nbsp;<\/a>hosted with \u2764 by&nbsp;<a href=\"https:\/\/github.com\/\">GitHub<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-4-defining-input-features-from-dataset\">Step 4: Defining input features from dataset<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We then prepare the various input features which will be used by the artificial&nbsp;<a href=\"https:\/\/quantra.quantinsti.com\/course\/neural-networks-deep-learning-trading-ernest-chan\">neural network learning<\/a>&nbsp;for making the predictions. We define the following input features:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>High minus Low price<\/li>\n\n\n\n<li>Close minus Open price<\/li>\n\n\n\n<li>Three day moving average<\/li>\n\n\n\n<li>Ten day moving average<\/li>\n\n\n\n<li>30 day moving average<\/li>\n\n\n\n<li>Standard deviation for a period of 5 days<\/li>\n\n\n\n<li>Relative Strength Index<\/li>\n\n\n\n<li>Williams %R<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">We then define the output value as price rise, which is a binary variable storing 1 when the closing price of tomorrow is greater than the closing price of today.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">price_AAPL['Price_Rise'] = np.where(price_AAPL['Close'].shift(-1) > price_AAPL['Close'], 1, 0)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gist.github.com\/quantra-go-algo\/b35ac33d596fdf78c0ceb67ce337ea5f#file-define_output_value-py\">Define_output_value.py&nbsp;<\/a>hosted with \u2764 by&nbsp;<a href=\"https:\/\/github.com\/\">GitHub<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next, we drop all the rows storing NaN values by using the dropna() function.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">price_AAPL = price_AAPL.dropna()<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gist.github.com\/quantra-go-algo\/c068e9ea8f7b803d54953ec11d7935fd#file-nan-py\">NaN.py&nbsp;<\/a>hosted with \u2764 by&nbsp;<a href=\"https:\/\/github.com\/\">GitHub<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We then create two data frames to store the input and the output variables. The dataframe \u2018x\u2019 stores the input features. The columns start from the fifth column of the dataset and go on to the second last column. The last column will be stored in the dataframe \u2018y\u2019 (prediction value) which is the rise in the prices.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">X = price_AAPL.iloc[:, 4:-1]\ny = price_AAPL.iloc[:, -1]<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gist.github.com\/quantra-go-algo\/ef034b554050aeed406707b8ba83418a#file-two_dataframes-py\">Two_dataframes.py&nbsp;<\/a>hosted with \u2764 by&nbsp;<a href=\"https:\/\/github.com\/\">GitHub<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this part of the code, we will split our input and output variables to create the test and train datasets. This is done by creating a variable called split, which is defined to be the integer value of 0.8 times the length of the dataset.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We then slice the X and y variables into four separate data frames: Xtrain, Xtest, ytrain and ytest. This is an essential part of any&nbsp;<a href=\"https:\/\/blog.quantinsti.com\/introduction-machine-learning-quantiacs\/\">machine learning<\/a>&nbsp;algorithm, the training data is used by the model to arrive at the weights of the model.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Splitting the dataset\nsplit = int(len(price_AAPL)*0.8)\nX_train, X_test, y_train, y_test = X[:split], X[split:], y[:split], y[split:]<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The test dataset is used to see how the model will perform on new data which would be fed into the model. The test dataset also has the actual value for the output, which helps us in understanding how efficient the model is.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We will look at the confusion matrix later in the code, which essentially is a measure of how accurate the predictions made by the model are.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-5-standardise-the-dataset-data-preprocessing-\">Step 5: Standardise the dataset (Data preprocessing)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Another important step in data preprocessing is to standardise the dataset. This process makes the mean of all the input features equal to zero and also converts their variance to 1. This ensures that there is no bias while training the model due to the different scales of all input features.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If this is not done the neural network might get confused and give a higher weight to those features which have a higher average value than others.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We implement this step by importing the StandardScaler method from sklearn.preprocessing library. We instantiate the variable sc with the StandardScaler() function.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Feature Scaling\nfrom sklearn.preprocessing import StandardScaler\nsc = StandardScaler()\nX_train = sc.fit_transform(X_train)\nX_test = sc.transform(X_test)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gist.github.com\/quantra-go-algo\/b0343358e69848082c4f98742eb51894#file-feature_scaling-py\">Feature_scaling.py&nbsp;<\/a>hosted with \u2764 by&nbsp;<a href=\"https:\/\/github.com\/\">GitHub<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Stay tuned for the next installment to learn how to build the artificial neural network model<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Originally posted on&nbsp;<a href=\"https:\/\/blog.quantinsti.com\/neural-network-python\/\">QuantInsti<\/a>. Visit their blog for additional insights on this topic.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We will start by importing a few libraries, the others will be imported as and when they are used in the program at different stages. <\/p>\n","protected":false},"author":368,"featured_media":191319,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[339,343,349,338,341],"tags":[7257,806,852,7008,15385,1225,1224,595,5482,15386],"contributors-categories":[13654],"class_list":["post-191306","post","type-post","status-publish","format-standard","has-post-thumbnail","category-data-science","category-programing-languages","category-python-development","category-ibkr-quant-news","category-quant-development","tag-algorithmic-trading","tag-data-science","tag-machine-learning","tag-neural-network","tag-neuron-python","tag-numpy","tag-pandas","tag-python","tag-talib","tag-yahoo-finance","contributors-categories-quantinsti"],"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v28.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Neural Network In Python: Types, Structure And Trading Strategies &#8211; Part III<\/title>\n<meta name=\"description\" content=\"We will start by importing a few libraries, the others will be imported as and when they are used in the program at different stages.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/191306\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Neural Network In Python: Types, Structure And Trading Strategies - Part III | IBKR Campus US\" \/>\n<meta property=\"og:description\" content=\"We will start by importing a few libraries, the others will be imported as and when they are used in the program at different stages.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-02T14:28:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-02T21:01:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"563\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Chainika Thakar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Chainika Thakar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Chainika Thakar\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/c97b4c6a477fa019494f67cff50fcb10\"\n\t            },\n\t            \"headline\": \"Neural Network In Python: Types, Structure And Trading Strategies &#8211; Part III\",\n\t            \"datePublished\": \"2023-06-02T14:28:10+00:00\",\n\t            \"dateModified\": \"2023-06-02T21:01:17+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\\\/\"\n\t            },\n\t            \"wordCount\": 936,\n\t            \"commentCount\": 0,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/06\\\/python-blue-background-digits.jpg\",\n\t            \"keywords\": [\n\t                \"Algorithmic Trading\",\n\t                \"Data Science\",\n\t                \"Machine Learning\",\n\t                \"Neural Network\",\n\t                \"Neuron Python\",\n\t                \"NumPy\",\n\t                \"Pandas\",\n\t                \"Python\",\n\t                \"Talib\",\n\t                \"Yahoo Finance\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Python Development\",\n\t                \"Quant\",\n\t                \"Quant Development\"\n\t            ],\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"CommentAction\",\n\t                    \"name\": \"Comment\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\\\/#respond\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\\\/\",\n\t            \"name\": \"Neural Network In Python: Types, Structure And Trading Strategies - Part III | IBKR Campus US\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/06\\\/python-blue-background-digits.jpg\",\n\t            \"datePublished\": \"2023-06-02T14:28:10+00:00\",\n\t            \"dateModified\": \"2023-06-02T21:01:17+00:00\",\n\t            \"description\": \"We will start by importing a few libraries, the others will be imported as and when they are used in the program at different stages.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/06\\\/python-blue-background-digits.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/06\\\/python-blue-background-digits.jpg\",\n\t            \"width\": 1000,\n\t            \"height\": 563,\n\t            \"caption\": \"Python\"\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/c97b4c6a477fa019494f67cff50fcb10\",\n\t            \"name\": \"Chainika Thakar\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/chainikathakar\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Neural Network In Python: Types, Structure And Trading Strategies &#8211; Part III","description":"We will start by importing a few libraries, the others will be imported as and when they are used in the program at different stages.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/191306\/","og_locale":"en_US","og_type":"article","og_title":"Neural Network In Python: Types, Structure And Trading Strategies - Part III | IBKR Campus US","og_description":"We will start by importing a few libraries, the others will be imported as and when they are used in the program at different stages.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/","og_site_name":"IBKR Campus US","article_published_time":"2023-06-02T14:28:10+00:00","article_modified_time":"2023-06-02T21:01:17+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg","type":"image\/jpeg"}],"author":"Chainika Thakar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Chainika Thakar","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/"},"author":{"name":"Chainika Thakar","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/c97b4c6a477fa019494f67cff50fcb10"},"headline":"Neural Network In Python: Types, Structure And Trading Strategies &#8211; Part III","datePublished":"2023-06-02T14:28:10+00:00","dateModified":"2023-06-02T21:01:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/"},"wordCount":936,"commentCount":0,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg","keywords":["Algorithmic Trading","Data Science","Machine Learning","Neural Network","Neuron Python","NumPy","Pandas","Python","Talib","Yahoo Finance"],"articleSection":["Data Science","Programming Languages","Python Development","Quant","Quant Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/","name":"Neural Network In Python: Types, Structure And Trading Strategies - Part III | IBKR Campus US","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg","datePublished":"2023-06-02T14:28:10+00:00","dateModified":"2023-06-02T21:01:17+00:00","description":"We will start by importing a few libraries, the others will be imported as and when they are used in the program at different stages.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/neural-network-in-python-types-structure-and-trading-strategies-part-iii\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg","width":1000,"height":563,"caption":"Python"},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/c97b4c6a477fa019494f67cff50fcb10","name":"Chainika Thakar","url":"https:\/\/www.interactivebrokers.com\/campus\/author\/chainikathakar\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/191306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/368"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=191306"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/191306\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/191319"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=191306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=191306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=191306"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=191306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}