Files
AI-Stock-Trader/WebServer/AIPython/currentprice.py
T

19 lines
412 B
Python

import sys
import yfinance as yf
def getCurrentPrice():
# Get the Symbol from ARGV
symbol = sys.argv[1]
ticker = yf.Ticker(symbol)
data = ticker.history(period="1d", interval="1m")
current_price = data['Close'].iloc[-1]
# Return to C# via stdout
print(f"---RESULT_START---")
print(current_price)
print(f"---RESULT_END---")
if __name__ == "__main__":
getCurrentPrice()