蒙特卡洛方法生成随机数_随机股票生成器—财务方面的蒙特卡洛模拟

蒙特卡洛方法生成随机数 金融, 机器学习 (Finance, Machine Learning)In this article, I will focus on how to create a procedural stock from nowhere, that at every iteration will randomly move up or down. While you may th...
摘要由CSDN通过智能技术生成

蒙特卡洛方法生成随机数

金融, 机器学习 (Finance, Machine Learning)

In this article, I will focus on how to create a procedural stock from nowhere, that at every iteration will randomly move up or down. While you may think that creating a random stock (or a sequence of them) is useless, because it does not reflect any real scenario, it is a tool that can prove itself useful for technical analysis or stressing any algo/model before even deploying it into the market.

在本文中,我将重点介绍如何从无处创建过程库存,该过程库存在每次迭代时都会随机地上下移动。 尽管您可能认为创建随机库存(或它们的序列)是没有用的,因为它不能反映任何实际情况,但它是一种工具,可以证明自己对技术分析或在部署任何算法/模型之前都非常有用进入市场。

股票走势背后的数学 (The math behind stock movements)

According to the random walk theory, stock movements (so-called returns) appear to be completely random. But this does not simply end the problem. If the issue is randomness, I could simply start from a price of 1000 on day 0, generating random numbers between -100 and 100 every day, adding them to the price of the previous day. This idea of randomness is not wrong, but too simple.

根据随机游走理论,股票走势(所谓的收益)似乎是完全随机的。 但这并不能简单地解决问题。 如果问题是随机性,我可以简单地从第0天的价格1000开始,每天生成介于-100和100之间的随机数,并将它们添加到前一天的价格中。 这种随机性的想法没有错,但是太简单了。

The idea is to simulate a stock movement randomly, but as closer to reality as possible. Therefore, choosing a random number to add to every iteration is a sloppy way of representing reality.

这个想法是随机模拟股票走势,但要尽可能接近现实。 因此,选择一个随机数添加到每个迭代中是代表现实的草率方法。

股票退货 (Stock Returns)

Movement of stock prices between iterations (in easy words, the way a stock moves from day 0 to day 1, and then from day 1 to day 2…) are measured by using a specific measure of value: returns.

两次迭代之间的股价变动(简单地说,就是股票从第0天到第1天,然后从第1天到第2天……的移动方式)是通过使用特定的价值度量来衡量的:回报。

The simplest way to calculate stock returns is by calculating the percentage change between one iteration and the next, as you can see from the picture. The only thing I need to do to simulate the movement of a stock is creating a sequence of iterations where the stock price moves thanks to the simulated return. This is how the price changes over time, I will not affect it directly.

从图中可以看出,计算股票收益的最简单方法是计算一次迭代与下一次迭代之间的百分比变化。 我唯一需要模拟的是模拟股票的波动,就是创建一系列的迭代,其中由于模拟的收益,股票的价格会波动。 这是价格随时间变化的方式,我不会直接影响它。

(Example)

For example, If I wanted to simulate the picture above, I know that my stock price starts at 1000 on day 0. I will generate the first return (+.03) and use it to increase the stock price on day 1:

例如,如果我想模拟上面的图片,我知道我的股价在第0天从1000开始。我将生成第一个收益(+.03),并用它来增加第1天的股价:

#day_1 stock price
1000*(1+0.03) = 1030

For the price of

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值