{"id":37843,"date":"2024-11-01T10:00:54","date_gmt":"2024-11-01T10:00:54","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=37843"},"modified":"2024-11-01T11:09:18","modified_gmt":"2024-11-01T11:09:18","slug":"automated-trading-using-deep-learning-and-machine-learning-feature-engineering-extracting-features-such-as-trading-volume-moving-averages-rsi-and-applying-them-to-machine-learning-models","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/37843\/","title":{"rendered":"Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models."},"content":{"rendered":"<p><body><\/p>\n<h2>Feature Engineering: Extracting features such as trading volume, moving averages, and RSI to apply to machine learning models<\/h2>\n<p>In recent years, the cryptocurrency market has grown rapidly, with Bitcoin being the most well-known digital asset. Automated trading of such assets has become an attractive choice for many investors. This article will explain how to extract various features that can be used for Bitcoin trading using machine learning and deep learning, and how to build and evaluate models based on them.<\/p>\n<h3>1. Understanding Bitcoin Data<\/h3>\n<p>The first step for automated trading is data collection. To collect data from the Bitcoin market, several factors should be included:<\/p>\n<ul>\n<li>Open Price<\/li>\n<li>Close Price<\/li>\n<li>High Price<\/li>\n<li>Low Price<\/li>\n<li>Volume<\/li>\n<\/ul>\n<p>This data changes over time, so it should be stored in a time-ordered format.<\/p>\n<h3>2. Importance of Feature Engineering<\/h3>\n<p>Feature Engineering is a crucial process that determines the performance of model training. It is essential to extract useful information from time series data like Bitcoin and prepare it for the learning model. Here, we will look at how to extract features using indicators such as trading volume, moving averages, and Relative Strength Index (RSI).<\/p>\n<h4>2.1 Trading Volume<\/h4>\n<p>Trading volume is an indicator of market activity, with high volume possibly indicating strong buying or selling pressure. Therefore, adding volume as a feature can enhance the predictive power of the model.<\/p>\n<h4>2.2 Moving Average<\/h4>\n<p>Moving averages calculate the average price over a given period, smoothing out price movements. Commonly used moving averages include short-term and long-term moving averages. For example, calculating the 5-day and 20-day moving averages and analyzing their crossover can generate trading signals.<\/p>\n<h4>2.3 Relative Strength Index (RSI)<\/h4>\n<p>RSI calculates the ratio of price increases to decreases over a given period, represented as a value between 0 and 100. Values above 70 are interpreted as overbought, while values below 30 are interpreted as oversold, making them useful for trading signals.<\/p>\n<h3>3. Data Collection and Feature Engineering Using Python<\/h3>\n<p>Now we will actually collect Bitcoin data and extract features using the indicators mentioned above. The following code demonstrates how to process Bitcoin data using the pandas and numpy libraries in Python.<\/p>\n<pre><code>\nimport pandas as pd\nimport numpy as np\nimport pandas_datareader.data as web\nimport datetime\n\n# Data collection\nstart = datetime.datetime(2020, 1, 1)\nend = datetime.datetime.now()\n\nbtc_data = web.DataReader('BTC-USD', 'yahoo', start, end)\n\n# Calculate moving averages\nbtc_data['MA5'] = btc_data['Close'].rolling(window=5).mean()\nbtc_data['MA20'] = btc_data['Close'].rolling(window=20).mean()\n\n# Calculate RSI\ndef compute_rsi(data, window):\n    delta = data['Close'].diff(1)\n    gain = (delta.where(delta > 0, 0)).rolling(window=window).mean()\n    loss = (-delta.where(delta < 0, 0)).rolling(window=window).mean()\n    rs = gain \/ loss\n    rsi = 100 - (100 \/ (1 + rs))\n    return rsi\n\nbtc_data['RSI'] = compute_rsi(btc_data, 14)\n\n# Add volume\nbtc_data['Volume'] = btc_data['Volume']\n\n# Final data check\nprint(btc_data.tail())\n    <\/code><\/pre>\n<h3>4. Building and Predicting with Machine Learning Models<\/h3>\n<p>Once the features are prepared, we can build a machine learning model to predict whether the price of Bitcoin will rise or fall. Below is an example code using the scikit-learn library.<\/p>\n<pre><code>\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.metrics import classification_report, accuracy_score\n\n# Handle missing values\nbtc_data.dropna(inplace=True)\n\n# Define features and labels\nfeatures = btc_data[['MA5', 'MA20', 'RSI', 'Volume']]\nlabels = (btc_data['Close'].shift(-1) > btc_data['Close']).astype(int)  # Whether the next day's close price rises\n\n# Split into training and test datasets\nX_train, X_test, y_train, y_test = train_test_split(features, labels, test_size=0.2, random_state=42)\n\n# Train the model\nmodel = RandomForestClassifier(n_estimators=100, random_state=42)\nmodel.fit(X_train, y_train)\n\n# Predict and evaluate\npredictions = model.predict(X_test)\nprint(classification_report(y_test, predictions))\nprint('Accuracy:', accuracy_score(y_test, predictions))\n    <\/code><\/pre>\n<h3>5. Additional Considerations<\/h3>\n<p>To operate an automated trading system, several additional considerations are needed:<\/p>\n<ul>\n<li><strong>Risk management:<\/strong> You should set investment amounts and loss limits to manage risk.<\/li>\n<li><strong>Data accessibility:<\/strong> The quality and quantity of data greatly affect the performance of the model, so reliable data sources must be secured.<\/li>\n<li><strong>Continuous model improvement:<\/strong> It is necessary to periodically retrain the model with new data to improve performance.<\/li>\n<\/ul>\n<h3>6. Conclusion<\/h3>\n<p>Building an automated trading system for Bitcoin using deep learning and machine learning starts with understanding the data and extracting useful indicators. This process maximizes trading efficiency and allows well-designed models to continuously evolve. I hope the processes presented in this article will help readers build their own automated trading systems.<\/p>\n<p>In the future, I hope to develop a proactive automated trading system that responds to market changes using various techniques.<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Feature Engineering: Extracting features such as trading volume, moving averages, and RSI to apply to machine learning models In recent years, the cryptocurrency market has grown rapidly, with Bitcoin being the most well-known digital asset. Automated trading of such assets has become an attractive choice for many investors. This article will explain how to extract &hellip; <a href=\"https:\/\/atmokpo.com\/w\/37843\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models.&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-37843","post","type-post","status-publish","format-standard","hentry","category-deep-learning-automated-trading"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models. - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/37843\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models. - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Feature Engineering: Extracting features such as trading volume, moving averages, and RSI to apply to machine learning models In recent years, the cryptocurrency market has grown rapidly, with Bitcoin being the most well-known digital asset. Automated trading of such assets has become an attractive choice for many investors. This article will explain how to extract &hellip; \ub354 \ubcf4\uae30 &quot;Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models.&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/37843\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T10:00:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:09:18+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/37843\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37843\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models.\",\"datePublished\":\"2024-11-01T10:00:54+00:00\",\"dateModified\":\"2024-11-01T11:09:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37843\/\"},\"wordCount\":546,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Deep learning Automated trading\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/37843\/\",\"url\":\"https:\/\/atmokpo.com\/w\/37843\/\",\"name\":\"Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models. - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T10:00:54+00:00\",\"dateModified\":\"2024-11-01T11:09:18+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37843\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/37843\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/37843\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models. - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","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:\/\/atmokpo.com\/w\/37843\/","og_locale":"ko_KR","og_type":"article","og_title":"Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models. - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Feature Engineering: Extracting features such as trading volume, moving averages, and RSI to apply to machine learning models In recent years, the cryptocurrency market has grown rapidly, with Bitcoin being the most well-known digital asset. Automated trading of such assets has become an attractive choice for many investors. This article will explain how to extract &hellip; \ub354 \ubcf4\uae30 \"Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models.\"","og_url":"https:\/\/atmokpo.com\/w\/37843\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T10:00:54+00:00","article_modified_time":"2024-11-01T11:09:18+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/37843\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/37843\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models.","datePublished":"2024-11-01T10:00:54+00:00","dateModified":"2024-11-01T11:09:18+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/37843\/"},"wordCount":546,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Deep learning Automated trading"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/37843\/","url":"https:\/\/atmokpo.com\/w\/37843\/","name":"Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models. - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T10:00:54+00:00","dateModified":"2024-11-01T11:09:18+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/37843\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/37843\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/37843\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Automated trading using deep learning and machine learning, Feature Engineering Extracting features such as trading volume, moving averages, RSI, and applying them to machine learning models."}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=37843"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37843\/revisions"}],"predecessor-version":[{"id":37844,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37843\/revisions\/37844"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=37843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=37843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=37843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}