create account

[Python!] 지옥으로 가는(?) 비트코인 가격을 예측해보자. by yoon

View this thread on: hive.blogpeakd.comecency.com
· @yoon · (edited)
$6.16
[Python!] 지옥으로 가는(?) 비트코인 가격을 예측해보자.
https://steemitimages.com/DQmW99L4W9PjZm3cibpqZx2TGMM4w2y16PHgWg9f6x5PoHA/yoon.png
​
<center> illustration by @carrotcake </center>
​
***

## Prophet를 이용한 비트코인 가격 예측
이번 시간에는 지옥으로(?) 가고 있는 비트코인의 가격을 예측해 볼 계획입니다. 저는 예언 능력이 눈꼽만치도 없으니, 지난번처럼 예언자라 이름 붙은 페이스북의 Prophet을 이용해 보겠습니다.

비트코인 데이터는 여러 곳에서 제공하는데 야후 파이낸스에서 비트코인 가격 데이터를 제공하기 때문에 여기에서 가져오겠습니다. BTC-USD 가격입니다.

[야후 파이낸스](https://finance.yahoo.com/quote/BTC-USD?p=BTC-USD&.tsrc=fin-srch)

파이썬에서 가져오는 명령어는 다음과 같습니다. 
```
BTC = web.DataReader('BTC-USD','yahoo',start,end)
```
#### 입력
```
import warnings
warnings.filterwarnings("ignore")
import pandas as pd
import pandas_datareader.data as web
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from datetime import datetime
from fbprophet import Prophet

start = datetime(2010, 1, 1)
end = datetime(2018, 11, 19)

BTC = web.DataReader('BTC-USD','yahoo',start,end)
BTC.head()
```
#### 입력/출력 화면
![스크린샷 2018-11-19 오후 8.56.02.png](https://ipfs.busy.org/ipfs/QmYEyk7gPvgtJgyKZS5PrkERxBmhtCBVhJce3i53sg9aG2)
2010년 7월 16일부터 가격이 있네요. 비트코인 시세 0.05달러. 1 BTC가 55원 정도 했나 봅니다.

그래프를 그려보겠습니다.
#### 입력
```
BTC['Close'].plot(figsize=(12,6), grid=True);
```

#### 입력/출력 화면
![스크린샷 2018-11-19 오후 8.57.24.png](https://ipfs.busy.org/ipfs/QmUorf98wioWPP5YKkaSW25dX4eSjdTR1UKJ94kdtsW6xM)

급등했다가 급격하게 장렬하게 추락하고 있습니다. 시계열 ds와 종가 y만 정리합니다.

#### 입력
```
df = pd.DataFrame({'ds':BTC.index, 'y':BTC['Close']})
df.reset_index(inplace=True)
del df['Date']
df.head()

m = Prophet(daily_seasonality=True)
m.fit(df);
future = m.make_future_dataframe(periods=365)
future.tail()

forecast = m.predict(future)
forecast[['ds','yhat','yhat_lower','yhat_upper']].tail()

m.plot(forecast);
```
#### 입력/출력 화면
![스크린샷 2018-11-19 오후 9.00.25.png](https://ipfs.busy.org/ipfs/QmYzvVzouMJhvJf8w3gMzveZGys7AFjQaDzs2MrwTvRMYd)

이렇게 떨어지고 있는데, 올라간다고 나오는군요. 그동안 계속 오르는 추세였으니까 그런 것 같습니다. 이것만 보고 희망회로를 돌리면 안되기 때문에 입력 기간을 바꾸어 보겠습니다.

## 전망2
비트코인 가격 데이터를 2013년 1월 1일부터 입력한 결과입니다. 추세가 길지 않으니 더이상 상승하는 걸로만 나오지는 않는군요. 2015년 1월 1일부터 입력하면 또 다르게 나오겠죠?

![스크린샷 2018-11-19 오후 9.03.21.png](https://ipfs.busy.org/ipfs/QmS9FNW9xzxikeQjEkYs4YhtCXJG9NMs4xfMSiDXSMASgp)

## 전망3
2015년부터의 데이터를 이용하면 하락하는 추세로 나옵니다. 심지어 제로를 넘어 마이너스로 향하는... (이것이 진정한 지옥?)

입력 데이터를 어떻게 사용하느냐에 따라 저마다 다른 결과가 나오는데, 예측이란 게 얼마나 쉽지 않은 일인지 조금이나마 느껴집니다.

![스크린샷 2018-11-19 오후 9.06.27.png](https://ipfs.busy.org/ipfs/QmZrBs2oaQAoTpSs4hY9ZjSqydN8gXpRjFB9Zpowqv23TX)

prophet한테 이런 예측을 맡겨도 되는 건가 싶습니다.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 133 others
properties (23)
authoryoon
permlink4wtfau-python
categorykr
json_metadata{"community":"busy","app":"busy/2.5.6","format":"markdown","tags":["kr","kr-dev","busy","jjangjjangman","sndbox"],"users":["carrotcake"],"links":["/@carrotcake","https://finance.yahoo.com/quote/BTC-USD?p=BTC-USD&.tsrc=fin-srch"],"image":["https://steemitimages.com/DQmW99L4W9PjZm3cibpqZx2TGMM4w2y16PHgWg9f6x5PoHA/yoon.png","https://ipfs.busy.org/ipfs/QmYEyk7gPvgtJgyKZS5PrkERxBmhtCBVhJce3i53sg9aG2","https://ipfs.busy.org/ipfs/QmUorf98wioWPP5YKkaSW25dX4eSjdTR1UKJ94kdtsW6xM","https://ipfs.busy.org/ipfs/QmYzvVzouMJhvJf8w3gMzveZGys7AFjQaDzs2MrwTvRMYd","https://ipfs.busy.org/ipfs/QmS9FNW9xzxikeQjEkYs4YhtCXJG9NMs4xfMSiDXSMASgp","https://ipfs.busy.org/ipfs/QmZrBs2oaQAoTpSs4hY9ZjSqydN8gXpRjFB9Zpowqv23TX"]}
created2018-11-19 12:11:30
last_update2018-11-20 01:38:00
depth0
children9
last_payout2018-11-26 12:11:30
cashout_time1969-12-31 23:59:59
total_payout_value4.728 HBD
curator_payout_value1.428 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,453
author_reputation173,293,211,289,240
root_title"[Python!] 지옥으로 가는(?) 비트코인 가격을 예측해보자."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,551,297
net_rshares9,891,327,265,725
author_curate_reward""
vote details (197)
@anpigon ·
prophet한테 스팀잇도 전망도 물어봐주세요~~ㅎㅎ
넘 재미있습니다.ㅋㅋ
properties (22)
authoranpigon
permlinkre-yoon-4wtfau-python-20181119t232732397z
categorykr
json_metadata{"tags":["kr"],"app":"steemit/0.1"}
created2018-11-19 23:27:33
last_update2018-11-19 23:27:33
depth1
children2
last_payout2018-11-26 23:27:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length41
author_reputation17,258,940,000,931
root_title"[Python!] 지옥으로 가는(?) 비트코인 가격을 예측해보자."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,582,696
net_rshares0
@yoon ·
알겠습니다 ^^
properties (22)
authoryoon
permlinkre-anpigon-re-yoon-4wtfau-python-20181120t133735974z
categorykr
json_metadata{"tags":["kr"],"app":"steemit/0.1"}
created2018-11-20 13:37:36
last_update2018-11-20 13:37:36
depth2
children1
last_payout2018-11-27 13:37:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length8
author_reputation173,293,211,289,240
root_title"[Python!] 지옥으로 가는(?) 비트코인 가격을 예측해보자."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,616,417
net_rshares0
@anpigon ·
감사합니다.ㅋ
properties (22)
authoranpigon
permlinkre-yoon-re-anpigon-re-yoon-4wtfau-python-20181120t152751409z
categorykr
json_metadata{"tags":["kr"],"app":"steemit/0.1"}
created2018-11-20 15:27:51
last_update2018-11-20 15:27:51
depth3
children0
last_payout2018-11-27 15:27:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7
author_reputation17,258,940,000,931
root_title"[Python!] 지옥으로 가는(?) 비트코인 가격을 예측해보자."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,622,217
net_rshares0
@bukio ·
짱짱맨 호출에 응답하여 보팅하였습니다. 꾸준한 활동을 응원합니다.

북이오(@bukio)는 창작자와 함께 하는 첫번째 프로그램을 만들었습니다. 이를 위해 첫번째 길드(Guild) 구성을 위한 [공지글](https://steemit.com/bukio/@bukio/5ypkpr)을 게시하였습니다. 영문 문학작품의 한글 번역에 관심이 있는 분들의 많은 참여를 바랍니다. 고맙습니다.
properties (22)
authorbukio
permlinkre-bukio-jjangjjangman-1542660240052
categorykr
json_metadata"{"tags":["bukio", "jjangjjangman"],"app":"steemer/1.0"}"
created2018-11-19 20:44:00
last_update2018-11-19 20:44:00
depth1
children0
last_payout2018-11-26 20:44:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length210
author_reputation11,545,563,591,097
root_title"[Python!] 지옥으로 가는(?) 비트코인 가격을 예측해보자."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,576,049
net_rshares0
@gomdory ·
![](https://ipfs.busy.org/ipfs/QmSpSf3UTPCZUwCEfi1sWKKcUXWKH3SnpEaYaqRuWu7omz)
@yoon님 넘치는 사랑 감사합니다. 곰도뤼~

[[곰돌이 명성도 55기념 이벤트] 너의 보팅을 두배로 돌려줄께~ / 스팀잇에 빛을 비춰줘~ lightsteem alpha](https://steemit.com/gomdory/@blockchainstudio/55-lightsteem-alpha)
properties (22)
authorgomdory
permlinkre-4wtfau-python-20181119t122352
categorykr
json_metadata""
created2018-11-19 12:23:54
last_update2018-11-19 12:23:54
depth1
children0
last_payout2018-11-26 12:23:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length242
author_reputation38,104,394,235,725
root_title"[Python!] 지옥으로 가는(?) 비트코인 가격을 예측해보자."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,551,867
net_rshares0
@jyinvest ·
과거 데이터를 바탕으로 임의의 패턴을 만들어내는것 뿐이니까요. 큰의미를 부여할 필요는 없다고 봅니다~
properties (22)
authorjyinvest
permlinkre-yoon-4wtfau-python-20181119t122409404z
categorykr
json_metadata{"tags":["kr"],"app":"steemit/0.1"}
created2018-11-19 12:24:09
last_update2018-11-19 12:24:09
depth1
children0
last_payout2018-11-26 12:24:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length56
author_reputation25,687,578,009,800
root_title"[Python!] 지옥으로 가는(?) 비트코인 가격을 예측해보자."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,551,885
net_rshares0
@kanade1025 ·
ㄷㄷ마이너스라니....
현실이 되지는 않겠죠? 아마...
properties (22)
authorkanade1025
permlinkre-yoon-4wtfau-python-20181119t141104463z
categorykr
json_metadata{"community":"busy","app":"busy/2.5.6","format":"markdown","tags":["kr"],"users":[],"links":[],"image":[]}
created2018-11-19 14:11:03
last_update2018-11-19 14:11:03
depth1
children0
last_payout2018-11-26 14:11:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length31
author_reputation10,272,169,136,063
root_title"[Python!] 지옥으로 가는(?) 비트코인 가격을 예측해보자."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,557,086
net_rshares0
@steem-ua ·
#### Hi @yoon!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your **UA** account score is currently 4.667 which ranks you at **#1629** across all Steem accounts.
Your rank has dropped 58 places in the last three days (old rank 1571).

In our last Algorithmic Curation Round, consisting of 286 contributions, your post is ranked at **#52**.
##### Evaluation of your UA score:

* Some people are already following you, keep going!
* The readers like your work!
* Good user engagement!


**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-4wtfau-python-20181119t232212z
categorykr
json_metadata"{"app": "beem/0.20.9"}"
created2018-11-19 23:22:15
last_update2018-11-19 23:22:15
depth1
children0
last_payout2018-11-26 23:22:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length623
author_reputation23,214,230,978,060
root_title"[Python!] 지옥으로 가는(?) 비트코인 가격을 예측해보자."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,582,468
net_rshares0
@steemitboard ·
Congratulations @yoon! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<table><tr><td>https://steemitimages.com/60x60/http://steemitboard.com/notifications/postallweek.png</td><td>You published a post every day of the week</td></tr>
</table>

<sub>_[Click here to view your Board of Honor](https://steemitboard.com/@yoon)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>


To support your work, I also upvoted your post!


**Do not miss the last post from @steemitboard:**
<table><tr><td><a href="https://steemit.com/steemfest/@steemitboard/meet-the-steemians-contest-the-results-the-winners-and-the-prizes"><img src="https://steemitimages.com/64x128/https://cdn.steemitimages.com/DQmeLukvNFRsa7RURqsFpiLGEZZD49MiU52JtWmjS5S2wtW/image.png"></a></td><td><a href="https://steemit.com/steemfest/@steemitboard/meet-the-steemians-contest-the-results-the-winners-and-the-prizes">Meet the Steemians Contest - The results, the winners and the prizes</a></td></tr><tr><td><a href="https://steemit.com/steemfest/@steemitboard/meet-the-steemians-contest-special-attendees-revealed"><img src="https://steemitimages.com/64x128/https://cdn.steemitimages.com/DQmeLukvNFRsa7RURqsFpiLGEZZD49MiU52JtWmjS5S2wtW/image.png"></a></td><td><a href="https://steemit.com/steemfest/@steemitboard/meet-the-steemians-contest-special-attendees-revealed">Meet the Steemians Contest - Special attendees revealed</a></td></tr><tr><td><a href="https://steemit.com/steemfest/@steemitboard/meet-the-steemians-contest-intermediate-results"><img src="https://steemitimages.com/64x128/https://cdn.steemitimages.com/DQmeLukvNFRsa7RURqsFpiLGEZZD49MiU52JtWmjS5S2wtW/image.png"></a></td><td><a href="https://steemit.com/steemfest/@steemitboard/meet-the-steemians-contest-intermediate-results">Meet the Steemians Contest - Intermediate results</a></td></tr></table>

> Support [SteemitBoard's project](https://steemit.com/@steemitboard)! **[Vote for its witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1)** and **get one more award**!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-yoon-20181119t193752000z
categorykr
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2018-11-19 19:37:51
last_update2018-11-19 19:37:51
depth1
children0
last_payout2018-11-26 19:37:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,161
author_reputation38,975,615,169,260
root_title"[Python!] 지옥으로 가는(?) 비트코인 가격을 예측해보자."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,573,256
net_rshares0