https://github.com/dev-michael-schmidt/pyspark-stocks
https://github.com/dev-michael-schmidt/pyspark-stocks
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dev-michael-schmidt/pyspark-stocks
- Owner: dev-michael-schmidt
- Created: 2024-07-26T18:57:20.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-07-26T19:34:46.000Z (10 months ago)
- Last Synced: 2025-01-14T11:16:21.584Z (5 months ago)
- Language: Python
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This PySpark project fetches data from Yahoo Finance's public stock data API, parses the CSV and loads it into a PySpark DataFrame, and then performs (currently)
- Simple Moving Average (specify window in days)
- Exponential Moving Average (specify in days)This DataFrame includes:
- `date`, self explanatory
- `open` Opening price of the day
- `high` Highest price seen that day
- `low` Lowest price seen that day
- `close` Price seen on market close
- `symbol` The symbol on the exchangeYou can include/add technicals via a builder pattern.
- `sma_10d` a 10-day simple moving average (default to 10, you can specify the span)
- `ema_10d` a 10-day exponential moving average (defaults to 10, you can specify span)
- More technical markers to comeUsage:
```
stock_history_df = (TechnicalBuilder(stock_history_df)
.SMA(10)
.EMA(10)
.build())
stock_history_df.show()
```Example output:
```
+----------+---------+-------+------+-------+----------+------+--------------+---------------+
| date| open| high| low| close| volume|symbol| sma_10d| ema_10d|
+----------+---------+-------+------+-------+----------+------+--------------+---------------+
| 2024-03-01| 508.98| 513.28| 508.5| 512.84| 7.68059E7| SPY| 512.84| 512.846|
| 2024-03-04| 512.03| 514.20| 512.0| 512.29| 4.97993E7| SPY| 512.57| 512.749978118|
| 2024-03-05| 510.23| 510.70| 504.9| 507.17| 7.28556E7| SPY| 510.776652333| 511.7372536057|
| 2024-03-06| 510.54| 512.07| 508.4| 509.75| 6.83824E7| SPY| 510.5199| 511.375936341|
```