bcp6 0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bcp6/__init__.py +2 -0
- bcp6/data.txt +66 -0
- bcp6-0.1.dist-info/METADATA +3 -0
- bcp6-0.1.dist-info/RECORD +6 -0
- bcp6-0.1.dist-info/WHEEL +5 -0
- bcp6-0.1.dist-info/top_level.txt +1 -0
bcp6/__init__.py
ADDED
bcp6/data.txt
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import numpy as np
|
|
3
|
+
import pandas as pd
|
|
4
|
+
import matplotlib.pyplot as plt
|
|
5
|
+
from sklearn.preprocessing import MinMaxScaler
|
|
6
|
+
from tensorflow.keras.models import Sequential
|
|
7
|
+
from tensorflow.keras.layers import LSTM, Dense, Dropout
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
key = '9868b3d065ca4448baaf699d7fb35fd4'
|
|
11
|
+
url = f'https://api.twelvedata.com/time_series?symbol=BTC/USD&start_date=2021-11-03&end_date=2021-11-20&interval=5min&order=asc&apikey={key}'
|
|
12
|
+
data = pd.DataFrame(requests.get(url).json()['values'])
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
scaler = MinMaxScaler()
|
|
16
|
+
prices = scaler.fit_transform(data[['close']])
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
n = 24
|
|
20
|
+
x, y = [], []
|
|
21
|
+
|
|
22
|
+
for i in range(n, len(prices) - 12):
|
|
23
|
+
x.append(prices[i-n:i])
|
|
24
|
+
y.append(prices[i+12])
|
|
25
|
+
|
|
26
|
+
x, y = np.array(x), np.array(y)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
model = Sequential([
|
|
30
|
+
LSTM(128, return_sequences=True, activation='relu', input_shape=(n, 1)),
|
|
31
|
+
Dropout(0.4),
|
|
32
|
+
LSTM(64, return_sequences=True, activation='relu'),
|
|
33
|
+
Dropout(0.3),
|
|
34
|
+
LSTM(32, activation='relu'),
|
|
35
|
+
Dropout(0.2),
|
|
36
|
+
Dense(1, activation='sigmoid')
|
|
37
|
+
])
|
|
38
|
+
|
|
39
|
+
model.compile(optimizer='adam', loss='mse', metrics=['accuracy'])
|
|
40
|
+
model.fit(x, y, epochs=10, batch_size=64)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
url = f'https://api.twelvedata.com/time_series?symbol=BTC/USD&start_date=2021-11-20&end_date=2021-11-24&interval=5min&order=asc&apikey={key}'
|
|
44
|
+
test = pd.DataFrame(requests.get(url).json()['values'])
|
|
45
|
+
|
|
46
|
+
actual = pd.to_numeric(test['close']).values.reshape(-1, 1)
|
|
47
|
+
test_scaled = scaler.transform(actual)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
x_test = np.array([
|
|
51
|
+
test_scaled[i-n:i, 0]
|
|
52
|
+
for i in range(n, len(test_scaled))
|
|
53
|
+
]).reshape(-1, n, 1)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
pred = scaler.inverse_transform(model.predict(x_test))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
plt.figure(figsize=(12, 6))
|
|
60
|
+
plt.plot(actual[n:], label='Actual Bitcoin Prices', color='green')
|
|
61
|
+
plt.plot(pred, label='Predicted Prices', color='red')
|
|
62
|
+
plt.title('Bitcoin Price Prediction')
|
|
63
|
+
plt.xlabel('Time Interval')
|
|
64
|
+
plt.ylabel('Price')
|
|
65
|
+
plt.legend()
|
|
66
|
+
plt.show()
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
bcp6/__init__.py,sha256=pwtQip-X7m3MJmJrjU_W6wjdx0XelvzY2I_kJ401bIw,94
|
|
2
|
+
bcp6/data.txt,sha256=zmc9jbAXjrXWRJ0Vy3JKbDCeJWPf4o4xNqtgbFTjlF0,1882
|
|
3
|
+
bcp6-0.1.dist-info/METADATA,sha256=GK7uBnKNVb1oYAOsvpLhDpNOFdPlDQj3sccFYWrdKAI,49
|
|
4
|
+
bcp6-0.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
5
|
+
bcp6-0.1.dist-info/top_level.txt,sha256=oHFugHm9VhXLA9HtRGNNLWzmjsAhapiPE9LhNT3xD7Q,5
|
|
6
|
+
bcp6-0.1.dist-info/RECORD,,
|
bcp6-0.1.dist-info/WHEEL
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bcp6
|