python 移动平均线

With the evolution of technology rapidly evolving, so do strategies in the stock market. In this post, I’ll go over how I created a SMA(Short Moving Average) strategy.

随着技术的飞速发展,股票市场的策略也在不断发展。 在本文中,我将介绍如何创建SMA(短期移动平均线)策略。

DISCLAIMER: Stocks can be risky and it is very possible to lose money. I have not used this strategy to make any financial gains, investments, or purchases. I do not recommend you read this article and use the strategy for your own investment purposes and/or financial gain. I am not responsible for your losses if you choose to use this. The strategy below is only an experiment.

免责声明:股票可能具有风险,很可能会亏损。 我没有使用这种策略来获得任何财务收益,投资或购买。 我不建议您阅读本文,并出于自己的投资目的和/或财务收益而使用该策略。 如果您选择使用此方式,我对您的损失不承担任何责任。 以下策略只是一个实验。

I decided to look at Apple stock (AAPL) because they are a technology giant making big financial gains in the past few months. As of today, August 13, 2020, AAPL opened at $457.72. On March 18, 2020, they opened at $239.77. I’m no expert when it comes to driving prices up and down but the fact is AAPL rose more than $200 in a five month span. I know there are signals in the market that let a consumer know when the right time to buy and sell is and I wanted to explore if a SMA strategy would be of any help.

我决定研究Apple股票(AAPL),因为它们是一家在过去几个月中取得了可观财务收益的技术巨头。 截至今天,2020年8月13日,AAPL开盘价为457.72美元。 2020年3月18日,它们开盘价为239.77美元。 我不是专家来推动价格上下,但事实是AAPL在五个月内上涨了200多美元。 我知道市场上有一些信号可以让消费者知道什么时候是正确的买卖时间,我想探讨一下SMA策略是否有帮助。

The first thing I did was go to Yahoo Finance and download the 5 year historical data csv file and explored the data.

我做的第一件事是去Yahoo Finance并下载5年历史数据csv文件并浏览了数据。

Then, I inspected to make sure there were no missing values. I assumed there wouldn’t be because stocks are tracked and monitored so closely, but it does not hurt to make sure.

然后,我检查以确保没有遗漏任何值。 我以为不会那样做,是因为对库存进行了如此密切的跟踪和监控,但是确保这样做没有任何害处。

For my experiment, we are not interested in the high point, low point, or volume, so we can drop those columns. The adjusted close is a more accurate representation of where the stock’s price is at.

对于我的实验,我们对高点,低点或音量不感兴趣,因此我们可以删除这些列。 调整后的收盘价更准确地表示了股票价格所在的位置。

Now I want to plot my graph for a visual representation.

现在,我想以图形方式绘制图形。

The x-axis represents the different entry dates and does not have actual value. It is clear AAPL is on the rise, but for how long? What if we would have predicted when this massive rise occurred?

x轴表示不同的输入日期,并且没有实际值。 很明显,AAPL正在上升,但是持续了多长时间? 如果我们能预料到这种大幅度增长将如何?

The strategy implemented used the crossing of the SMA-30 and SMA 100. SMA-30 is the Short Moving Average of 30 days and SMA-100 is Short Moving Average of 100 days. So, the next thing to do is to find out what the 30 and 100 day averages are.

实施的策略使用了SMA-30和SMA 100的交叉点。SMA-30是30天的短期移动均线,而SMA-100是100天的短期移动均线。 因此,接下来要做的是找出30天和100天的平均值。

The first 29 entries will have a NaN value because there is not enough data to create the 30 day average. However we see that in the 30th entry, we have enough data and now have our 30 day average.

前29个条目将具有NaN值,因为没有足够的数据来创建30天平均值。 但是,我们看到在第30个条目中,我们有足够的数据,现在有了30天的平均值。

The same code can be applied to the 100 day average, but now the window will equal 100.

可以将相同的代码应用于100天的平均值,但是现在该窗口等于100。

Now we can create another graph to see how the averages move with the actual price of the stock. This gives us a clearer picture of the average versus the price.

现在我们可以创建另一个图形,以查看平均数如何随股票的实际价格变动。 这使我们可以更清楚地了解平ASP格。

We see the 100 day average does not move as fast as the 30 day average or the actual price, which makes sense because it is reliant on 100 days of information. The 30 day average moves a little more and the actual price is not bound to any other day, so it will move the most. Now we need indicators to buy and sell.

我们看到100天平均值的移动速度不及30天平均值或实际价格快,这是有道理的,因为它依赖于100天的信息。 30天的平ASP格变动幅度更大,而实际价格不受其他日期的限制,因此价格涨幅最大。 现在我们需要指标来买卖。

This function will tell us when the averages cross. Depending on how the SMA-30 crosses the SMA-100, that will tell us when to buy and when to sell. I also want the price and date of the cross so I am better informed. the final product is

该函数将告诉我们均线何时穿过。 根据SMA-30与SMA-100的交叉方式,这将告诉我们何时购买和何时出售。 我也想知道十字架的价格和日期,以便更好地通知我。 最终产品是

We see the most recent buy signal occurred on May 5, 2020 at the price of $318.66.

我们看到最近的购买信号发生在2020年5月5日,价格为318.66美元。

The strategy is not 100% correct and that is important information going into any trade. There are losses and gains from using this.

该策略不是100%正确的,这是进入任何交易的重要信息。 使用此方法会带来损失和收益。

翻译自: https://medium.com/analytics-vidhya/sma-short-moving-average-in-python-c656956a08f8

python 移动平均线


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

相关文章:

  • SMA(简单移动平均线)
  • 统计学分析公式 MA移动平均线
  • 为新开的餐厅设计网站html,18个以餐饮美食为主题的优秀网页设计
  • H5 HTML 移动端触摸拖拽drag drop 自定义拖拽样式 使用PointerEvent模拟的拖拽方案
  • Angular cdk 学习之 drag-drop
  • vue drag函数拖拽效果实现
  • Vue 拖拽缩放组件 vue-drag-resize属性
  • Android使用DragAndDrop拖拽效果实现宫格位置变换
  • Js学习之拖拉事件(drag)
  • d3.js学习笔记(5)drag拖拽操作数据
  • H5--drag拖拽事件
  • android游戏备份农场,zynga旗下的虚拟农场farmville将正式进入android平台
  • Zynga完成对快速增长的超休闲游戏领域的领导者——伊斯坦布尔的Rollic的收购
  • Zynga旗下魔法三消手机游戏《Harry Potter: Puzzles Spells》邀请玩家一起参加最新推出的游戏内系列活动——俱乐部挑战赛
  • Zynga的数据分析
  • 解密Zynga:专注 流水线 数据控
  • Zynga发布魔法三消手游《Harry Potter: Puzzles Spells》
  • Zynga就收购顶尖移动设备游戏《Toon Blast》和《Toy Blast》的开发商伊斯坦布尔Peak公司达成协议
  • Zynga任命Noel Watson为董事会成员
  • 曹金明:Zynga大败局--数据控是如何把游戏做败的
  • Zynga和StarLark庆祝《Golf Rival》面世四周年
  • Zynga将Cocos2D-X移植到Emscripten
  • Zynga和Unity:独家奖励广告
  • 创造下一个Zynga传奇
  • Zynga以特别的《CSR Racing 2》系列活动庆祝布加迪110周年
  • 游戏出海Get,TikTok联手Zynga推出一款基于HTML5打造的手机游戏
  • Zynga重返公有云 是否大势所趋
  • Zynga公布2019年第三季度财务业绩
  • Zynga公布2020年第四季度及全年财务业绩
  • Zynga研发之道探秘:用数据说话

python 移动平均线_Python中的SMA(短期移动平均线)相关推荐

  1. python map用法_Python中ChainMap的一种实用用法

    Python部落(python.freelycode.com)组织翻译,禁止转载,欢迎转发. 简而言之ChainMap:将多个字典视为一个,解锁Python超能力. Python标准库中的集合模块包含 ...

  2. python基本统计量_Python中简单统计量的计算

    本篇文章给大家带来的内容是关于Python中简单统计量的计算,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 1.这些操作都要确保已经在电脑中安装好了Anaconda集成库,如果安装好 ...

  3. python解析原理_Python 中 -m 的典型用法、原理解析与发展演变

    在命令行中使用 Python 时,它可以接收大约 20 个选项(option),语法格式如下: python [-bBdEhiIOqsSuvVWx?] [-c command | -m module- ...

  4. python与会计学_Python 中用于表示逻辑与的关键字分别是 ____

    [单选题]某分部工程双代号网络图如下图所示,其作图错误是( ). (2.5分) [填空题]指示计算机执行某种操作的命令称为( ). [判断题]结构化程序设计强调程序设计风格和程序结构的规范化,提倡清晰 ...

  5. python正则表达式空格_python中的正则表达式的使用

    一.正则表达式简介 正则表达式:又称正规表示式.正规表示法.正规表达式.规则表示式.常规表示法(英语:Regular Expression,在代码中常简写为regex.regexp或者是RE),是计算 ...

  6. python wraps模块_python中 wraps 的作用

    这里使用两段代码比较加入wraps装饰器后,函数打印的结果对比: 新建文件名:Testword 代码1:不加wraps装饰器 # coding=utf-8 from functools import ...

  7. 用python输出数组_Python 中输出数组中的全部元素

    只需要在开头加上一句即可 import numpy as np np.set_printoptions(threshold=np.inf) Python 输出到文本中 参考:https://blog. ...

  8. cad2017单段线_CAD中如何绘制多段线

    如果我们不设置选项,多段线绘制看上去跟直线绘制没什么区别,都可以连续绘制多段直线.那么大家知道CAD中如何绘制多段线吗?下面是学习啦小编整理的CAD中如何绘制多段线的方法,希望能帮到大家! CAD中绘 ...

  9. python 移动平均线_Python中的移动平均线

    python 移动平均线 There are situations, particularly when dealing with real-time data, when a conventiona ...

  10. python在excel中数据画线_python中操作excel数据

    python操作excel,python有提供库 本文介绍openpyxl,他只支持新型的excell( xlsx)格式,读取速度还可以 1.安装 pip install openpyxl 2.使用 ...

最新文章

  1. Hive 正则匹配函数 regexp_extract
  2. 图像几何变换:旋转,缩放,斜切
  3. 解决ubuntu apt-get install出现E:Clould not get lock /var/lib/dpkg/lock
  4. 解决linux下无线网卡被物理禁用问题
  5. 关于医学院网络中心成立工作室的设想
  6. C++继承详解:共有(public)继承,私有(private)继承,保护(protected)继承
  7. md5 php 加密后乱码_PHP md5函数 的16位字符乱码问题解决-阿里云开发者社区
  8. Python与Java曝漏洞,黑客利用FTP注入攻击可绕过防火墙
  9. 【个人笔记】OpenCV4 C++ 快速入门 17课
  10. 尾矿库监测 GNSS北斗高精度定位终端机应用
  11. 为什么仿宋字体打印出楷体_请问仿宋体和楷体有什么区别?
  12. 数学建模常用模型22:回归模型
  13. ActiveMq的简介
  14. Raspberry Pi 4B SSH、VNC及串口连接配置
  15. 【Easyx库】(1)
  16. 切面(@Aspect)和事务(@Transactional)莫名失效:`is not eligible for getting processed by all BeanPostProcesso
  17. 计算机考研与就业的利弊分析,考研和就业怎么选择 考研和就业的利弊分析
  18. FileSystemWatcher 用法
  19. ZZULIOJ:1053: 正弦函数
  20. TMC6300-LA:微型BLDC/PMSM驱动

热门文章

  1. 负载均衡添加ssl证书
  2. 20张图片梳理工业软件全貌
  3. 纯CSS+CSS3右上角倾斜四十五度封页角效果
  4. android studio sdk samples,qcloud-sdk-android-samples
  5. 百度网盘mac损害计算机,百度网盘Mac版和Mac同步盘有哪些区别?百度网盘Mac版常见问题解答...
  6. SQL窗口函数OVER用法整理
  7. matlab中用plot函数绘制的常用设置以及五点三次平滑法的实现
  8. 个体和公司以及小微企业的区别
  9. 鸿蒙和小米哪个值得入手,鸿蒙系统能够吸引小米的优势是什么
  10. mysql 数据库健康巡检 报告