如何击败腾讯

个人项目 (Personal Proyects)

Note from Towards Data Science’s editors: While we allow independent authors to publish articles in accordance with our rules and guidelines, we do not endorse each author’s contribution. You should not rely on an author’s works without seeking professional advice. See our Reader Terms for details.

Towards Data Science编辑的注意事项: 尽管我们允许独立作者按照我们的 规则和指南 发表文章 ,但我们不认可每位作者的贡献。 您不应在未征求专业意见的情况下依赖作者的作品。 有关 详细信息, 请参见我们的 阅读器条款

摘要 (Summary)

This is a personal project in which I have tried to develop a trading application using machine learning tools. Starting with data modelling along with a categorisation based on distribution and machine learning techniques, I have developed a trading strategy for beginner investors to generate low-risk profit with the help of this application.

这是一个个人项目,我尝试使用机器学习工具开发交易应用程序。 从数据建模以及基于分布和机器学习技术的分类开始,我已经开发了一种交易策略,供初学者使用此应用程序产生低风险利润。

介绍 (Introduction)

The market analysis is both interesting and complex as it can be seen in the following link [1]. Nevertheless, there are several works carried out with machine-learning which try to shed light on this field.

市场分析既有趣又复杂,因为可以在以下链接中看到[1] 。 然而,机器学习方面进行了一些工作,试图为这一领域提供启示。

In this piece of work, I have created an application consisting of two main points:

在本文中,我创建了一个包含两个要点的应用程序:

  1. A screen where stock market index may be analysed over different temporal horizons. Here it can be found a candlestick chart; a chart to analyse technical indicators [2]; a line chart which shows the percentage of price change between days, as well as a box-plot representing this last chart in order to understand that distribution.

    一个可以在不同时间范围内分析股市指数的屏幕。 在这里可以找到一个烛台图分析技术指标的图表[2] ; 线形图显示了两天之间价格变化的百分比,以及表示最后一个图的箱形图,以了解这种分布。

  2. A screen where the analysis of the trading strategy which I have developed (Strategyone) can be done. This strategy is divided into two different parts: the first one consisting of the prediction of stock market index movements by means of machine learning, whereas the second one involves the comparison between the current data vectors prediction and what happened in the past. The chosen temporal horizons range from 7, 14, 21 to 28 days.

    可以在此屏幕上分析我开发的交易策略( Strategyone )。 该策略分为两个不同的部分:第一个部分包括通过机器学习预测股市指数运动,而第二个则包括当前数据向量预测与过去发生的情况之间的比较 。 所选的时间范围为7、14、21至28天。

This last section is explained thoroughly in “How to beat the market” and “Trading strategy”

最后一部分在“如何战胜市场”和“交易策略”中进行了详细说明。

Data has been obtained through the Alpha Vantage API [3], while a list of the stock market index from the Finnhub API [4].

数据是通过Alpha Vantage API [3]获得的 ,而股票市场指数则是从Finnhub API [4]获得的 。

语境 (Context)

As a physicist I have been always fascinated by the complex systems world: how certain formulae can be applied to and have interesting results either to biological systems or financial ones, as well as to a group of several electrons.

作为物理学家,我一直着迷于复杂的系统世界:如何将某些公式应用于生物系统或金融系统以及一组多个电子,并对它们产生有趣的结果。

Likewise, how the individual study of an element of the system might result into a different behaviour when it is studied within the system.

同样,当在系统中进行研究时,对系统元素的个别研究可能如何导致不同的行为。

Consequently, this project emerges from the curiosity about the stock market in addition to the software and intellectual challenge that implies to understand such a complex system as the market is.

因此,除了对理解市场这样一个复杂系统的软件和知识挑战之外,该项目还来自对股票市场的好奇心。

The project has gone through three stages: the first version of this work was developed as the final thesis of the Master’s Degree in Data Science which I attended in [5], and whose aim was only the creation of classification model which could predict the future of an stock in the market using machine learning. The second version was designed externally to the Master’s and it tried to improve the first one. Finally, the third version is the one here discussed, and it offers a significant improvement, the development of a trading strategy.

该项目经历了三个阶段:这项工作的第一个版本是我在[5]中参加的数据科学硕士学位的最终论文,其目的仅仅是建立可以预测未来的分类模型。使用机器学习来分析市场中的股票 第二个版本是在硕士课程外部设计的,它试图改进第一个版本。 最后,这里讨论的是第三个版本,它提供了显着的改进,即交易策略的发展。

如何打败市场 (How to beat the market)

In order to use a classification model to predict market movements, I needed to categorise the data. These prediction categories have been called “Strong bull”, predictions in which the price increase is significant; “Bull”, when there is a price increase; “Keep”, the price remains the same; “Bear”, a decrease on the price, and “Strong bear”, the price decrease is significant [6].

为了使用分类模型来预测市场走势,我需要对数据进行分类。 这些预测类别被称为“强牛”,即价格上涨显着的预测。 “牛”,当价格上涨时; “保持”,价格保持不变; 价格下降的“熊市”和价格下跌的“强熊市”很明显[6] 。

How are the stock market index categories chosen?

如何选择股市指数类别?

This have done through the distribution of percentage variation in the stock price. As our aim is predicting the future, in the registers, the percentage variation column needs the daily information about how the price varies in relation to the temporal horizon that we want to predict.

这是通过分配股票价格的百分比变化来实现的 。 由于我们的目标是预测未来,因此在价格记录中,百分比变化列需要有关价格如何相对于我们要预测的时间范围变化每日信息

Therefore, the variation percentage to be categorised is compared to the last 4-month distribution, and one of the categories abovementioned will be selected based on the range of the percentiles in relation to that distribution.

因此,将要分类的变化百分比与最近4个月的分布进行比较,并且将基于相对于该分布的百分位数范围选择上述类别之一。

In this way, we could categorise all the data given a temporal horizon, and this will always be about the future.

这样,我们可以在时间范围内对所有数据进行分类,而这将永远与未来有关。

Once the categorisation is done, the next step was getting to know which the best way to apply an algorithm of classification with more precision is. After a number of trials and different ideas, the selected process was scaling the data by means of the robust scaler technique and Random Forest as classification algorithm. These were the chosen ones since they provide an average higher precision upon all the categories.

分类完成后,下一步就是知道哪种方法更准确地应用分类算法。 经过大量的试验和不同的想法,选择的过程是通过健壮的缩放器技术和随机森林作为分类算法来缩放数据。 选择它们是因为它们在所有类别上均提供了平均较高的精度。

Only following these steps, we can obtain a model which is able to predict “Strong bull” with a 40 % level of accuracy.

仅按照这些步骤,我们就可以得到能够以40%的准确度预测“强牛”的模型

交易策略 (Trading Strategy)

The trading strategy will be based on what happened in the past and on the idea that we guess correctly provided that we win, omitting that in order to win we must also guess the right predicted category.

交易策略将基于过去发生的情况以及我们能够正确猜出的想法(前提是我们获胜),而忽略了为了获胜,我们还必须猜出正确的预测类别

That is, if the prediction is “Bull”, we carry out a long position operation and the resulting outcome is actually “Strong bull”, our prediction will be considered as accurate. Likewise, if we predict “Strong bull” and the result is “Bull” or when the prediction is “Strong bear”, we carry out a short position movement and the outcome achieved is “Bear” and the other way round.

也就是说,如果预测为“牛”,我们执行多头头寸操作,而结果实际上为“强牛”,我们的预测将被认为是准确的。 同样,如果我们预测“强牛”而结果为“牛”,或者当预测为“强熊”时,我们进行空头头寸移动并且获得的结果为“熊”,反之亦然。

If none of the abovementioned cases take place, the operation will be considered as a fail.

如果上述情况均未发生,则该操作将被视为失败。

Having this in mind, the strategy will only consist of long position operation and when the model predicts “Strong bull” given that it is the category with higher accuracy from the classification model.

考虑到这一点, 该策略将仅包括多头头寸操作,并且当模型预测“强牛”时该策略将被认为是分类模型中具有较高准确性的类别。

How does the strategy work?

该策略如何运作?

Once the robust scaler is applied to all the registers, the category is predicted and the actual categorisation, a PCA is applied to reduce the number of dimensions to 4 maintaining the 95 % of data variability. Therefore, we have other 4 variables together with the prediction linked to the register and its actual category. How the variables are can be known when something is predicted in relation to the real category, so we arrange the prediction and the category, and we calculate the median associated to each profile curve to understand how to describe each one.

一旦将鲁棒缩放器应用于所有寄存器,预测了类别并进行了实际分类, 便会应用PCA将维数减少到4,以保持95%的数据可变性。 因此,我们还有其他4个变量以及链接到寄存器及其实际类别的预测。 当预测与真实类别有关的某物时可以知道变量的方式 ,因此我们安排了预测和类别,并计算了与每个轮廓曲线相关的中位数以了解如何描述每个轮廓。

As a result, we will have described the variables in which “Strong bull” is predicted” and the actual outcome was “Strong bull” or any other category.

结果,我们将描述“强牛”被预测的变量,而实际结果是“强牛”或任何其他类别。

All of this will be limited to the last 6-month-data in relation to the prediction day in order to avoid the influence of an old market state on the strategy. The results obtained are summarised below:

所有这些都将仅限于与预测日相关的最后6个月的数据,以避免旧市场状况对策略的影响。 获得的结果总结如下:

Description of the variables for each prediction-category after the PCA.
PCA之后每个预测类别的变量说明。

The interpretation of this table is that in the last 6 months before the prediction of “Strong bull” and the category was guess correctly, the variables of the main components had as the median.

该表的解释是,在“强牛”的预测出现之前的最近6个月中,该类别被正确猜出,主要成分的变量为中位数。

Consequently, in order to carry out a operation, we must apply the data of the day in which we are doing the prediction a robust scaler and a PCA,

因此,为了执行操作,我们必须应用进行预测的当天的数据,鲁棒的缩放器和PCA,

If the prediction obtained is “Strong bull”, we will have reached the first step to carry out the operation. The second step is checking which profile of the previous curves is more similar to the data that is being predicted. This will be done using the cosine similarity which will allow us to observe the more similar vector to the data. If it corresponds to “Strong bull-strong bull”, we will have the key to perform a safer operation.

如果获得的预测是“坚强的公牛”,我们将到达执行该操作的第一步。 第二步是检查先前曲线的轮廓与正在预测的数据更相似。 这将使用余弦相似度完成,这将使我们能够观察到与数据更相似的向量。 如果它对应于“强牛-强牛”,我们将拥有执行更安全操作的钥匙。

Following this trading strategy, we will obtain almost a 50 % level of accuracy, but, as it was mentioned at the beginning, guessing correctly does not imply guessing the category too.

按照这种交易策略,我们将获得几乎50%的准确度 ,但是,正如开头提到的那样,正确猜测并不意味着也猜测类别。

Guessing correctly does not imply guessing the category too

正确猜测并不意味着也猜测类别

Under our circumstances, a correct guessing will be also the prediction of “Strong bull” and obtaining “Bull” as a final result. The strategy level of accuracy reaches 58 % when this is taken into account.

在我们的情况下,正确的猜测也将是对“强牛”的预测,并最终获得“牛”。 考虑到这一点,策略的准确性达到58%。

结论 (Conclusion)

The aim of this piece of work was the development of a strategy which allows a beginner investor to carry out to generate low-risk profit without suffering a total loss. As I have mentioned, the strategy ensures a 58 % level of accuracy under the described conditions, but, on a personal note, it is not a strategy to be implemented automatically because the error level assumed raises up to 40%.

这项工作的目的是开发一种策略,该策略允许初学者投资者开展活动以产生低风险的利润而不会造成总损失。 正如我已经提到的那样,该策略可确保在所描述的条件下达到58%的准确度,但是,就个人而言,由于假定的错误级别会上升到40%,因此这不是自动实施的策略。

However, it is interesting to see how a level of accuracy over 50 % is obtained in the performed operations, following a strategy based only on data and with a limited and minimal knowledge about the stock market.

然而,有趣的是,遵循仅基于数据且对股票市场的了解有限且很少的策略,在执行的操作中如何获得超过50%的准确度。

All the project code can be read on: GitHub/esan94/bsm03

所有项目代码都可以在GitHub / esan94 / bsm03上阅读

后续步骤 (Following Steps)

The possible next steps to improve might include:

可能需要改进的后续步骤可能包括:

  • The change of the data model.数据模型的变化。
  • The improvement of the classification algorithm.分类算法的改进。
  • The addition to the project of more knowledge about the stock market.除了该项目以外,还拥有有关股票市场的更多知识。
  • The assignation of value to the main components to apply the cosine similarity.将值分配给主要成分以应用余弦相似度。

资源资源 (Resources)

  • [1] https://en.wikipedia.org/wiki/Efficient-market_hypothesis

    [1] https://en.wikipedia.org/wiki/Efficient-market_hypothesis

  • [2] https://www.investopedia.com/technical-analysis-4689657

    [2] https://www.investopedia.com/technical-analysis-4689657

  • [3] https://www.alphavantage.co/

    [3] https://www.alphavantage.co/

  • [4] https://finnhub.io/

    [4] https://finnhub.io/

  • [5] https://kschool.com/

    [5] https://kschool.com/

  • [6] https://www.investopedia.com/insights/digging-deeper-bull-and-bear-markets/

    [6] https://www.investopedia.com/insights/digging-deeper-bull-and-bear-markets/

You can follow me on LinkedIn, GitHub o Medium.

您可以在LinkedIn , GitHub或 o 中关注我。

Translation made by Paloma Sánchez Narváez.

翻译由PalomaSánchezNarváez撰写 。

翻译自: https://towardsdatascience.com/beating-stock-market-8b33c5afb633

如何击败腾讯


http://www.taodudu.cc/news/show-997584.html

相关文章:

  • 如何将Jupyter Notebook连接到远程Spark集群并每天运行Spark作业?
  • twitter 数据集处理_Twitter数据清理和数据科学预处理
  • 使用管道符组合使用命令_如何使用管道的魔力
  • 2020年十大币预测_2020年十大商业智能工具
  • 为什么我们需要使用Pandas新字符串Dtype代替文本数据对象
  • nlp构建_使用NLP构建自杀性推文分类器
  • 时间序列分析 lstm_LSTM —时间序列分析
  • 泰晤士报下载_《泰晤士报》和《星期日泰晤士报》新闻编辑室中具有指标的冒险活动-第1部分:问题
  • 异常检测机器学习_使用机器学习检测异常
  • 特征工程tf-idf_特征工程-保留和删除的内容
  • 自我价值感缺失的表现_不同类型的缺失价值观和应对方法
  • 学习sql注入:猜测数据库_面向数据科学家SQL:学习简单方法
  • python自动化数据报告_如何:使用Python将实时数据自动化到您的网站
  • 学习深度学习需要哪些知识_您想了解的有关深度学习的所有知识
  • 置信区间估计 预测区间估计_估计,预测和预测
  • 地图 c-suite_C-Suite的模型
  • sap中泰国有预扣税设置吗_泰国餐厅密度细分:带有K-means聚类的python
  • 傅里叶变换 直观_A / B测试的直观模拟
  • 鸽子 迷信_人工智能如何帮助我战胜鸽子
  • scikit keras_Scikit学习,TensorFlow,PyTorch,Keras…但是天秤座呢?
  • 数据结构两个月学完_这是我作为数据科学家两年来所学到的
  • 迈向数据科学的第一步:在Python中支持向量回归
  • 使用Python和MetaTrader在5分钟内开始构建您的交易策略
  • ipywidgets_未来价值和Ipywidgets
  • 用folium模块画地理图_使用Folium表示您的地理空间数据
  • python创建类统计属性_轻松创建统计数据的Python包
  • knn分类 knn_关于KNN的快速小课程
  • 机器学习集群_机器学习中的多合一集群技术在无监督学习中应该了解
  • 政府公开数据可视化_公开演讲如何帮助您设计更好的数据可视化
  • 消费者行为分析_消费者行为分析-是否点击广告?

如何击败腾讯_击败股市相关推荐

  1. 如何击败腾讯_要击败这个新的电子游戏,请对其重新编程

    如何击败腾讯 真正击败Double Fine Productions的新视频游戏 Hack'n'Slash的唯一方法是对其进行重新编程. 但是,玩游戏,一个sendup传统的冒险游戏像塞尔达传说,这对 ...

  2. 腾讯AI击败王者荣耀职业队,全靠自学、策略清奇,一天训练量为人类440年

    问耕 发自 麦蒿寺 量子位 出品 | 公众号 QbitAI 王者峡谷,风云突变. 一场激烈的对战正在进行,左侧是五位人类职业电竞高手组成的赛区联队,另一方是--嗯?他们的对手没有出场?五个座椅空空荡荡 ...

  3. AI种黄瓜大赛,微软击败腾讯、英特尔夺冠

    荷兰瓦赫宁根大学(Wageningen University)发起的温室挑战赛──AI 种黄瓜比赛,微软团队击败了腾讯和英特尔等同业及人类园艺专家,成为获胜者.腾讯和中国农业科学院等机构组成的 iGr ...

  4. 最强蜗牛击败毁灭机器人_最强蜗牛:恶魔形态解锁攻略

    小编今天给各位玩家朋友们带来的是最强蜗牛:恶魔形态解锁攻略,有记得的玩家朋友吗?不记得也没有关系,小编已经帮助大家把最强蜗牛:恶魔形态解锁攻略找了出来,你只需要动动你的小手就可以轻松知道啦,快来瞧一瞧 ...

  5. 最强蜗牛击败毁灭机器人_最强蜗牛恶魔形态怎么解锁 恶魔形态所有阶级详解[多图]...

    最强蜗牛恶魔形态怎么解锁?恶魔形态是需要玩家进行解锁的,恶魔形态有几个阶段,不同阶段的效果也不同,下面为大家带来恶魔形态所有阶级详解,一起看看吧! 恶魔形态解锁方法:肌体进化到10级,解锁恶魔形态. ...

  6. 最强蜗牛击败毁灭机器人_【最强蜗牛攻略】恶魔所有阶段攻略(详细教程)

    最强蜗牛恶魔所有阶段攻略 一.形态能力 恶魔形态的蜗牛,会在探索途中,收割敌人的灵魂. 探索结束时,这些可怜的亡魂,都将成为你的供品(随探索国家发生变化). 二.形态变化I-IV阶 恶魔1阶 称号:恶 ...

  7. 最强蜗牛击败毁灭机器人_最强蜗牛恶魔形态怎么玩_恶魔形态能力变化突变攻略_3DM手游...

    最强蜗牛中恶魔形态是很多玩家小伙伴十分喜欢的一个形态,那么最强蜗牛恶魔形态怎么玩呢?还不知道的小伙伴快来一起看看<最强蜗牛>恶魔形态玩法介绍的相关内容吧. 形态玩法大全:点击查看 < ...

  8. 最强蜗牛击败毁灭机器人_最强蜗牛恶魔形态怎么解锁 最强蜗牛恶魔形态所有阶级介绍...

    最强蜗牛恶魔形态怎么解锁?恶魔是最强蜗牛手游中主角可以进化的形态之一,那么这个形态要什么解锁呢?解锁后每个阶段的属性又会发生什么变化呢?下面就是最强蜗牛恶魔形态所有阶级介绍了,大家一起来看看吧! 最强 ...

  9. 最强蜗牛击败毁灭机器人_最强蜗牛恶魔形态所有阶级详解_恶魔形态介绍

    最强蜗牛中的恶魔形态是最实用的心态,那游戏中恶魔心态所有阶级属性怎样样呢?接下来编辑就给大伙带来了最强蜗牛恶魔形态所有阶级简介,一起来看看吧. 形态能力 恶魔形态的蜗牛,会在探索途中,收割敌人的灵魂. ...

最新文章

  1. 税友报税软件让修改服务器地址,税友报税软件让修改服务器地址
  2. python安装不了jieba_python安装jieba失败怎么办?_后端开发
  3. HDFS中常用的shell命令总结
  4. 内存模型是怎么解决缓存一致性的
  5. 在vue中安装使用vux
  6. java如何从方法返回多个值
  7. 25岁“天才少年”曹原再发一篇Nature!1个月时间内的第二篇!
  8. GitLab 小组中的项目访问权限赋予给用户
  9. 通过Java得到的时间与操作系统时间不一致,如何修改Java虚拟机时间?
  10. 谷歌秋季新品发布会即将召开 Pixel 4系列将正式亮相
  11. 蔬菜大棚原理_天津大棚报价大棚的造价、温室大棚
  12. svg写入/识别html元素和css样式
  13. STK航空仿真(五):坐标系
  14. dpdk大页内存原理
  15. android内存置换,安卓手机64GB内存如何更换内存
  16. 更新后的哥德巴赫猜想(位运算)
  17. uwp版的音乐播放器练手
  18. SQL---日期时间函数
  19. 用fock实现简易shell(程序替换)
  20. 迷茫之后:Java研发转型售前——选择大于努力!

热门文章

  1. python-3.8.0 新特性之赋值表达式
  2. 餐厅点餐系统:测试与部署
  3. #191 sea(动态规划)
  4. spark集群配置以及java操作spark小demo
  5. Jmeter测试普通java类说明
  6. Snipaste截图
  7. 读zepto核心源码学习JS笔记(3)--zepto.init()
  8. 数据格式转换(一)PDF转换技术
  9. 启动mac版docker自带的k8s
  10. python数据结构与算法