retreat commit

This commit is contained in:
David Brázda
2023-10-09 09:15:52 +02:00
parent a6678f9a4f
commit be93c17848
93 changed files with 16821 additions and 2561 deletions

14
testy/alpacawebsokcet.py Normal file
View File

@ -0,0 +1,14 @@
from alpaca.data.live.stock import StockDataStream
from v2realbot.config import ACCOUNT2_PAPER_API_KEY, ACCOUNT2_PAPER_SECRET_KEY, ACCOUNT2_PAPER_FEED
# keys required
stock_stream = StockDataStream(ACCOUNT2_PAPER_API_KEY, ACCOUNT2_PAPER_SECRET_KEY, raw_data=True, websocket_params={}, feed=ACCOUNT2_PAPER_FEED)
# async handler
async def trade_data_handler(data):
# quote data will arrive here
print(data)
stock_stream.subscribe_trades(trade_data_handler, "BAC")
stock_stream.run()

39
testy/ml/numpybasics.py Normal file
View File

@ -0,0 +1,39 @@
import numpy as np
a = np.arange(20).reshape(2,2,5)
print(a)
#b = np.zeros((3,4))
b = np.arange(12).reshape(3,4)
print(b)
#max z kazdeho sloupce
c = np.max(b, axis=0)
#suma kazdeho radku
c = np.sum(b, axis=1)
c = c.reshape(3,1)
#sumu pridam na konec kazdeho radku, tzn.pripojim sloupce (horizontalne)
d=np.hstack((b,c))
print(d)
#indexovani booleanem
e = np.arange(12).reshape(3,4)
f = e < 5
print(e,f)
print(e[f])
#vsechny mensi nez 5 se stanou 0
e[e<5] = 0
print(e)
# c = np.ones((2,2))
# c = c.reshape(1,4)
# print(c)
# print(c*b)
# d = np.arange(4).reshape(2,2)
# e = d.copy()
# print("d",d)
# print("e",e)
# print(d*e)
# print(d@e)

View File

@ -0,0 +1,37 @@
import numpy as np
t = np.array([[[1,2,3,4,5], [2,2,2,2,2]],
[[3,3,3,3,3], [4,4,4,4,4]],
[[5,5,5,5,5], [6,6,6,6,6]]])
print(t.shape, t.ndim, t.dtype)
print(t[0:2].shape)
#nasledujici je totozne
a = t[:2]
b = t[0:2, :, :]
c = t[0:2, 0:2, 0:5]
#posledni dve cisla kazdeho elementu tensoru 1
a = t[1, :, 3:]
#prostredni 3 cisla z kazdeho elementu
a = t[:, :, 1:-1]
# print(a==b)
print(a)
# print(b)
# print(c)
print(t.reshape((6,5)))
print(t.reshape((30)))
print(t.reshape((30,1)))
print(np.transpose(t))
#operations
u =np.array([5,2,1,1,4])
print(t+u)

View File

@ -0,0 +1,29 @@
import numpy as np
y = np.arange(20).reshape(4,5)
print("y",y)
# y = y[1:5:2,]
y = y[::2,::2]
print("y",y)
# a = np.arange(30).reshape(-1,5)
# #pole_posunute o radek dopredu - future a
# fa = a.copy()
# fa = fa[1:]
# print("fa",fa)
# #acko orizneme vzadu - aby byly stejne dlouhe
# a = a[:-1]
# print(a)
# #a pak porovnáme jejich poslední sloupce a vysledek dáme jako další sloupec s 1 nebo 0
# #nicmene melo by to nejak jit i bez pomocného pole
# posl_sloupec=a[:,-1:]<fa[:,-1:]
# print(posl_sloupec)
# #sloupec 1/0 zda je hodnota nizsi nez hodnota o jeden radek vpredu
# #tak si muzu nadefinovat 1ky kdyz je rising for 5 bars - udealt funkcni
# a = np.hstack((a, posl_sloupec))
# print(a)
# #print(a[posl_sloupec>4])

View File

@ -75,8 +75,8 @@ if res == 0:
else:
print("error",res,sada)
bars = sada["bars"]
indicators = sada["indicators"][0]
# bars = sada["bars"]
# indicators = sada["indicators"][0]
# Zakladni nastaveni
testlist_id = ""
@ -86,11 +86,11 @@ indicator_features = ['samebarslope', 'fastslope','fsdelta', 'fastslope2', 'fsde
features = ["time","high","low","volume","open","close", "trades", "vwap","samebarslope", "fastslope","fsdelta", "fastslope2", "fsdelta2"]
#TODO toto je linearni prediction mod, dodelat podporu BINARY
#u binary bude target bud hotovy indikator a nebo jej vytvorit on the fly
target = 'vwap'
target = 'close'
#predict how many bars in the future
target_steps = 5
name = "model1"
seq = 10
seq = 2
epochs = 500
features.sort()