Skip to main content

Lottery utility package

Project description

Stock Analysis Script (Lottery)

This Python script analyzes historical stock data stored in a CSV file (orcl.csv). It calculates and writes two technical indicators, the 5-day Simple Moving Averages (SMA) and the 14-day Relative Strength Index (RSI), to separate CSV files (orcl-sma.csv and orcl-rsi.csv).

Usage

  1. Load Historical Data:

    • The script first loads historical stock data from a CSV file (orcl.csv in this example). The data is expected to have columns like 'Date', 'Open', 'High', 'Low', 'Close', 'Volume', etc. Make sure to adjust the csv_file_path variable with the correct path to your CSV file.
    csv_file_path = ' '  # Add orcl.csv file path
    historical_data = load_historical_data(csv_file_path)
    
  2. Run the Script:

    • Execute the script to load the historical data, calculate technical indicators, and write the results to CSV files. Run the following command in the command line:
    python script_name.py
    

Output Files

Two CSV files (orcl-sma.csv and orcl-rsi.csv) will be generated with the calculated SMA and RSI values, respectively.

Functions

  • load_historical_data(file_path):

    • Loads historical stock data from the specified CSV file into a list of dictionaries.
  • calculate_sma(data, window):

    • Calculates the 5-day Simple Moving Averages (SMA) for the given historical data.
  • calculate_rsi(data, window):

    • Calculates the 14-day Relative Strength Index (RSI) for the given historical data using a provided formula.
  • write_to_csv(file_path, header, data):

    • Writes data to a CSV file with the specified header.

The Stracture of The File:

my-python-project │───README.md │─── setup.py │
│ └───Lotterry | init.py │ Lottery.py

Example of Usage

csv_file_path = ' '  # Add orcl.csv file path
historical_data = load_historical_data(csv_file_path)

sma_5 = calculate_sma(historical_data, window=5)
rsi_14 = calculate_rsi(historical_data, window=14)

sma_header = ['Date', 'SMA_5']
sma_data = [[row['Date'], sma] for row, sma in zip(historical_data, sma_5)]
write_to_csv('orcl-sma.csv', sma_header, sma_data)

rsi_header = ['Date', 'RSI_14']
rsi_data = [[row['Date'], rsi] for row, rsi in zip(historical_data, rsi_14)]
write_to_csv('orcl-rsi.csv', rsi_header, rsi_data)

print(historical_data[:5])
print("5-day SMA:", sma_5[:5])
print("14-day RSI:", rsi_14[:5])
print("Files 'orcl-sma.csv' and 'orcl-rsi.csv' written successfully.")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lottery_dcl-0.1.1-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

Details for the file lottery_dcl-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: lottery_dcl-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for lottery_dcl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 60e48d0308388140e4e4b537fbb07d77f92ca4ff1c1ae6d35692720a346dbfd3
MD5 7ebbcbc0e2e51ec8d3988b4857388719
BLAKE2b-256 41dd17d17674dbe1f00f2ee3ffa16157864f934ebace829a328455aded6fe246

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page