macromarkets-xyz / x

x periments
0 stars 0 forks source link

Second issue #2

Closed donaldknoller closed 2 months ago

donaldknoller commented 2 months ago
  1. In the docker image, update the python script dictGenerate.py to read command line arguments. The first command line argument will be a timestamp in ISO 8601 The second command line argument will be parsed as a string For the file written to /tmp/output.json, the value should be a random number instead of 0.78 (as mentioned in first issue)

  2. Given the python script run_docker_image.py update the following: a. The first argument to the docker image will be a timestamp in ISO 8601 format five minutes from the current time b. The second argument will be a stock ticker (use SPY for now) c. After the docker container completes, compare the output of /tmp/output.json with the value of SPY after five minutes and calculate the accuracy. (you can use yahoo finance library to fetch the price data) d. If the SPY data is not active (aka when the market is closed, use a dummy value for the live SPY price data) e. Store the accuracy score in a new file called results.txt

chiefchimp commented 2 months ago

@donaldknoller For the Dockerfile code, We use CMD python predictionGenerate.py to run the script when the container launches, but it has the following warning after building the Docker image:

chiefchimp commented 2 months ago

@donaldknoller The current flow & logic works like this:

  1. Run runDockerImage.py with a timestamp for the current time and the ability to pass through a stock ticker, with the default value of SPY & a random number for the prediction (predictionGenerate.py which runs in the Docker container on start)
  2. The timestamp, stock ticker, and prediction are saved in a file called output.json in the /tmp directory in the Docker container, the contents are copied to a file in the working directory called output.txt, and the container is stopped.
  3. The script waits 5 minutes before automatically running fetchStockPrice.py, which pulls the price for the stock ticker.
  4. The stock ticker price is saved to results.txtin the working directory which has the following data:

Note, the yfinance library only provides stock ticker prices for last day's close and cannot do shorter time intervals. There are 2 versions of fetchStockPrice.py: