mirror of
https://github.com/wassname/Volt.git
synced 2026-09-10 11:50:25 +08:00
misc
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
/data/
|
||||
saved-outputs/
|
||||
|
||||
*/.ipynb_checkpoints/*
|
||||
*/__pycache__/*
|
||||
|
||||
@@ -14,19 +14,13 @@ warnings.simplefilter("ignore", NumericalWarning)
|
||||
|
||||
def main(args):
|
||||
|
||||
|
||||
ticker_file = args.ticker_fname + ".txt"
|
||||
data_path = "../../voltron/data/"
|
||||
ticker_file = data_path + args.ticker_fname + ".txt"
|
||||
tckr_list = make_ticker_list(ticker_file)
|
||||
|
||||
if args.end_date.lower() == "none":
|
||||
end_date = datetime.date.today()
|
||||
else:
|
||||
end_date = datetime.datetime.strptime(args.end_date, "%Y-%m-%d")
|
||||
|
||||
|
||||
for tckr in tckr_list:
|
||||
# try:
|
||||
data = GetStockHistory(tckr, history=args.ntrain + args.lookback)
|
||||
data = GetStockHistory(tckr, end_date=args.end_date, history=args.ntrain + args.lookback)
|
||||
if args.kernel.lower() == 'volt':
|
||||
GenerateStockPredictions(tckr, data, forecast_horizon=args.forecast_horizon,
|
||||
train_iters=args.train_iters,
|
||||
@@ -92,7 +86,7 @@ if __name__ == "__main__":
|
||||
)
|
||||
parser.add_argument(
|
||||
"--end_date",
|
||||
default="none",
|
||||
default=None,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--lookback",
|
||||
|
||||
@@ -25,15 +25,10 @@ def main(args):
|
||||
ntrain = args.ntrain
|
||||
seq_len = args.seq_length
|
||||
|
||||
if args.end_date.lower() == "none":
|
||||
end_date = datetime.date.today()
|
||||
else:
|
||||
end_date = datetime.datetime.strptime(args.end_date, "%Y-%m-%d")
|
||||
|
||||
|
||||
for tckr in tckr_list:
|
||||
try:
|
||||
data = GetStockHistory(tckr, history= ntrain + args.lookback)
|
||||
data = GetStockHistory(tckr, end_date=args.end_date, history= ntrain + args.lookback)
|
||||
end_idxs = torch.arange(args.ntrain, data.shape[0],
|
||||
int((data.shape[0]-args.ntrain)/args.ntimes))
|
||||
|
||||
@@ -116,7 +111,7 @@ if __name__ == "__main__":
|
||||
)
|
||||
parser.add_argument(
|
||||
"--end_date",
|
||||
default="none",
|
||||
default=None,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--lookback",
|
||||
@@ -130,4 +125,4 @@ if __name__ == "__main__":
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
main(args)
|
||||
main(args)
|
||||
|
||||
@@ -14,7 +14,11 @@ python GPGenerator.py
|
||||
--n_test_times=100 ## number of test time points
|
||||
```
|
||||
|
||||
```sh
|
||||
# note test_tickers0, resolves to `data/test_tickers0.txt`
|
||||
python ForecastGenerator.py \
|
||||
--ticker_fname test_tickers0 --end_date
|
||||
python LSTMGenerator.py \
|
||||
--ticker_fname test_tickers0
|
||||
|
||||
experiments/stocks/LSTMGenerator.py
|
||||
experiments/stocks/GenerateMultiMeanPreds.py
|
||||
experiments/stocks/ForecastGenerator.py
|
||||
```
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
AAPL
|
||||
MSFT
|
||||
GOOG
|
||||
GOOG
|
||||
TSLA
|
||||
XOM
|
||||
BTU
|
||||
BX
|
||||
PFE
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -60,7 +60,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"id": "3bf4fe43",
|
||||
"id": "2b7ed8c6",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2022-07-16T07:23:41.316461Z",
|
||||
@@ -446,6 +446,32 @@
|
||||
" px_paths[vidx*npx:(vidx*npx + npx), :] = px_pred.detach().T"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"id": "4c9a0f25",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2022-07-16T08:31:56.274593Z",
|
||||
"start_time": "2022-07-16T08:31:56.252823Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"torch.Size([8, 199])"
|
||||
]
|
||||
},
|
||||
"execution_count": 34,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"px_paths.shape"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ae84ab49-1e70-4922-a035-c607a5bbf551",
|
||||
@@ -546,7 +572,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "eba9ee4f",
|
||||
"id": "1d35cbfa",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -34,10 +34,13 @@ def DataGetter(history = 500, fpath="../data/", printing=False, end_date=None,
|
||||
tickers = make_ticker_list(fpath + ticker_file)
|
||||
make_price_files(tickers, start_date, end_date, fpath, printing)
|
||||
|
||||
def GetStockHistory(ticker, end_date=str(datetime.date.today()), history=500):
|
||||
end_date = datetime.datetime.strptime(end_date, "%Y-%m-%d").date()
|
||||
def GetStockHistory(ticker, end_date=None, history=500):
|
||||
if end_date is None:
|
||||
end_date = pd.Timestamp.now().floor('D') - pd.Timedelta('1d')
|
||||
else:
|
||||
end_date = pd.Timestamp(end_date)
|
||||
data = yf.download(tickers=ticker, period='10y', progress=False)
|
||||
end_idx = np.where(data.index == pd.to_datetime(end_date))[0][0]
|
||||
end_idx = np.where(data.index == end_date)[0][0]
|
||||
|
||||
return data.iloc[end_idx-history:end_idx]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user