달력

4

« 2024/4 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

'챗봇'에 해당되는 글 2

  1. 2023.02.24 일목균형표(Ichimoku Chart) 파이썬 코드(feat. chatGPT)
  2. 2023.02.22 open AI vs you.com
728x90
반응형

안녕하세요.

오늘도 챗GPT와 함께 파이썬 코드를 만들어보았습니다.

 

주식 차트중 하나인 일목균형표입니다.

https://namu.wiki/w/%EC%9D%BC%EB%AA%A9%EA%B7%A0%ED%98%95%ED%91%9C

 

일목균형표 - 나무위키

전환선 (과거 9일간의 최고가+과거 9일간의 최저가)/2기준선(과거 26일간의 최고가+과거 26일간의 최저가)/2후행스팬금일 종가를 26일 전에 기입선행스팬1(금일 전환선값+금일 기준선값)/2, 이 수치

namu.wiki

일명 구름대라고 하는 곳을 벗어나는 주식이 좀더 강하다라는 이야기 인데 이걸 파이썬 코드로 한번 짜보겠습니다.

예전에는 이런것들을 일일이 구글링해서 운좋게 파이썬 코드가 있으면 복붙하면 되지만,

만약에 없었다면 수식을 보면서 일일이 만들어야 하는 수고로움이 있었죠.

하지만. chatGPT와 함께.ㅎㅎ 요즘 너무 친하게 지내는 것 같습니다.^^;;

짧은 영어실력임에도 영어로 질문하면 뭔가 조금더 정밀하게 대답을 해주는 것 같아서 영어로 진행해 보았습니다.

https://openai.com/blog/chatgpt/

 

ChatGPT: Optimizing Language Models for Dialogue

We’ve trained a model called ChatGPT which interacts in a conversational way. The dialogue format makes it possible for ChatGPT to answer followup questions, admit its mistakes, challenge incorrect premises, and reject inappropriate requests. ChatGPT is

openai.com

 

please make a Ichimoku Chart for stock in python
Sure, I can guide you through creating an Ichimoku Chart for a stock in Python. The Ichimoku Chart is a popular technical analysis tool that combines multiple indicators to provide a comprehensive view of a stock's price action.

To create an Ichimoku Chart, we need to calculate several indicators and plot them on a chart. The indicators we will use are:
Tenkan-sen (Conversion Line): This is the midpoint of the highest high and lowest low over the past 9 periods.Kijun-sen (Base Line): This is the midpoint of the highest high and lowest low over the past 26 periods.Senkou Span A (Leading Span A): This is the average of the Tenkan-sen and Kijun-sen plotted 26 periods ahead.Senkou Span B (Leading Span B): This is the midpoint of the highest high and lowest low over the past 52 periods, plotted 26 periods ahead.Chikou Span (Lagging Span): This is the current closing price plotted 26 periods behind.
Here is the Python code to calculate these indicators and plot the Ichimoku Chart for a stock:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# Load stock price data into a pandas dataframe
df = pd.read_csv('stock_price_data.csv')

# Calculate Tenkan-sen (Conversion Line)
period9_high = df['High'].rolling(window=9).max()
period9_low = df['Low'].rolling(window=9).min()
df['tenkan_sen'] = (period9_high + period9_low) / 2

# Calculate Kijun-sen (Base Line)
period26_high = df['High'].rolling(window=26).max()
period26_low = df['Low'].rolling(window=26).min()
df['kijun_sen'] = (period26_high + period26_low) / 2

# Calculate Senkou Span A (Leading Span A)
df['senkou_span_a'] = ((df['tenkan_sen'] + df['kijun_sen']) / 2).shift(26)

# Calculate Senkou Span B (Leading Span B)
period52_high = df['High'].rolling(window=52).max()
period52_low = df['Low'].rolling(window=52).min()
df['senkou_span_b'] = ((period52_high + period52_low) / 2).shift(26)

# Calculate Chikou Span (Lagging Span)
df['chikou_span'] = df['Close'].shift(-26)

# Plot the Ichimoku Chart
plt.figure(figsize=(12,8))
plt.plot(df['Date'], df['tenkan_sen'], color='red', label='Tenkan-sen')
plt.plot(df['Date'], df['kijun_sen'], color='blue', label='Kijun-sen')
plt.fill_between(df['Date'], df['senkou_span_a'], df['senkou_span_b'], where=df['senkou_span_a'] >= df['senkou_span_b'], color='green', alpha=0.2, label='Bullish Cloud')
plt.fill_between(df['Date'], df['senkou_span_a'], df['senkou_span_b'], where=df['senkou_span_a'] < df['senkou_span_b'], color='red', alpha=0.2, label='Bearish Cloud')
plt.plot(df['Date'], df['chikou_span'], color='purple', label='Chikou Span')
plt.plot(df['Date'], df['Close'], color

일목균형표에 대한 간략한 설명과 함께 코드를 리턴해주었습니다만!!!!!!!!!!!!!!!!!!!

짤렸네요.ㅋㅋㅋ

그래서 코드로 옮길시 제가 임의로 막 작성했어요.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# Load stock price data into a pandas dataframe
df = pd.read_csv('stock_price_data.csv')

# Calculate Tenkan-sen (Conversion Line)
period9_high = df['High'].rolling(window=9).max()
period9_low = df['Low'].rolling(window=9).min()
df['tenkan_sen'] = (period9_high + period9_low) / 2

# Calculate Kijun-sen (Base Line)
period26_high = df['High'].rolling(window=26).max()
period26_low = df['Low'].rolling(window=26).min()
df['kijun_sen'] = (period26_high + period26_low) / 2

# Calculate Senkou Span A (Leading Span A)
df['senkou_span_a'] = ((df['tenkan_sen'] + df['kijun_sen']) / 2).shift(26)

# Calculate Senkou Span B (Leading Span B)
period52_high = df['High'].rolling(window=52).max()
period52_low = df['Low'].rolling(window=52).min()
df['senkou_span_b'] = ((period52_high + period52_low) / 2).shift(26)

# Calculate Chikou Span (Lagging Span)
df['chikou_span'] = df['Close'].shift(-26)

# Plot the Ichimoku Chart
plt.figure(figsize=(12,8))
plt.plot(df['Date'], df['tenkan_sen'], color='red', label='Tenkan-sen')
plt.plot(df['Date'], df['kijun_sen'], color='blue', label='Kijun-sen')
plt.fill_between(df['Date'], df['senkou_span_a'], df['senkou_span_b'], where=df['senkou_span_a'] >= df['senkou_span_b'], color='green', alpha=0.2, label='Bullish Cloud')
plt.fill_between(df['Date'], df['senkou_span_a'], df['senkou_span_b'], where=df['senkou_span_a'] < df['senkou_span_b'], color='red', alpha=0.2, label='Bearish Cloud')
plt.plot(df['Date'], df['chikou_span'], color='purple', label='Chikou Span')
plt.plot(df['Date'], df['Close'], color='black', label='Close')

이렇게 짤린부분을 수습(?)을 하고 나서 실행을 해보았으나..에러가 나요~^^

전 그나마 얼마되지 않는 짬밥 좀 있다고 위에 리턴해준 코드를 보자마자 에러 날것을 알고 있었지만...

이런 문구를 보니 친절하지 않는 GPT에게 서운함이..ㅎㅎ

상단에 csv로 저장하는 부분. 즉 데이터가 있어야 합니다.

역시나 엄청 친절하지는 않는 GPT아조씨..ㅋ

 

걍 제가 작성해도 되지만..

그래도 다시 한번 물어봤습니다.

how to get the stock_price_data.csv

솔직히 기대를 안하고 물어봤는데...

To get the 'stock_price_data.csv' file, you can use a financial data API or a web scraper to retrieve the historical stock price data for the desired stock. Here's an example of how to use the 'yfinance' library in Python to download historical stock price data:
import yfinance as yf

# Set the stock ticker symbol and the date range
ticker = 'AAPL'
start_date = '2020-01-01'
end_date = '2022-02-24'

# Download the historical stock price data using yfinance
data = yf.download(ticker, start=start_date, end=end_date)

# Save the data to a CSV file
data.to_csv('stock_price_data.csv')
This code will download the historical stock price data for Apple (AAPL) from January 1, 2020 to February 24, 2022 and save it to a CSV file named stock_price_data.csv in the current directory. You can modify the code to download the data for a different stock and date range by changing the ticker, start_date, and end_date variables.

예상외로..간략한 사용법과 함께 yfinance 라이브러리로  실행하는 방법을 알려줍니다.

전 구글코랩을 자주 이용하기 때문에 yfinance가 설치가 안되어 있어서 에러가 날줄? 알지만. 걍 복붙 해봅니다.ㅎ

역시나 ' No module named 'yfinance' 를 뱉어내는 군요^^

그래서!!!!!!! 또 물어봤습니다.

how to install yfinance library in python.

(너무나 정직한(?) 저의 검소한 영어 실력.ㅋ)

To install the yfinance library in Python, you can use pip, which is a package manager for Python. Here are the steps to install yfinance:
1. Open a terminal or command prompt.
2. Type pip install yfinance and press Enter.
3. Wait for pip to download and install the yfinance library and its dependencies.
Here's an example of how to use yfinance to download historical stock price data:
import yfinance as yf

# Set the stock ticker symbol and the date range
ticker = 'AAPL'
start_date = '2020-01-01'
end_date = '2022-02-24'

# Download the historical stock price data using yfinance
data = yf.download(ticker, start=start_date, end=end_date)

# Print the data to the console
print(data)
This code will download the historical stock price data for Apple (AAPL) from January 1, 2020 to February 24, 2022 and print it to the console. You can modify the code to download the data for a different stock and date range by changing the ticker, start_date, and end_date variables.

오.. 친절하게 알려줍니다.

그래서 설치

!pip install yfinance

 

설치후 다시 재실행

다시 stock_price_data.csv 를 로딩하고,

코드실행..두근두근..

오...만들어지네요.ㅋ

이게 정확한지는 모르겠지만, 무료의 한계인가요? 짤린 코드 뒤가 궁금하지만. 여기까지 해보았구요.

 

역시나 오늘도 느끼는 거지만 질문을 잘 던져야 한다는 것 같아요. 그래서 좀더 구체적인 질문을 해보았어요.

이렇게 답변을 주길래 실행을 해봤는데..

에러가 나네요.ㅋ

아마도 mplfinance 라이브러리가 뭔가 업데이트가 되면서 mpf.make_ichimoku 모듈이 없나봐요.

 

오늘도 chatGPT한테서 하나 배우고 갑니다.

 

좋은 하루 되세요~^^

728x90
반응형
:
Posted by 패치#노트
2023. 2. 22. 20:43

open AI vs you.com Any2023. 2. 22. 20:43

728x90
반응형

요즘 핫한 Chat GPT 를 이용해서 다양한 질문들을 많이 해보고 있습니다.

코딩할때도 물론 도움이 되고, 아직은 완벽한 것은 아니지만 서서히 인공지능 세상이 오고 있다는 생각이 많이 드네요.

코딩하다가 모를때 물어보기도 편하고, 코딩도 짜주는 그냥 조수 같은 느낌?ㅎ

 

오늘은 제목 그대로 각각의 AI 챗봇에게 지금 이 사이트가 어떤지 물어봤습니다.


먼저 you.com

who are you - AI Search Based Chat | AI for Search Engines

 

 

 

 

CodeStockers is an online platform for developers to share and collaborate on code. It provides a range of tools and features to help developers write better code quickly, including an editor with syntax highlighting, auto-completion, linting, and code refactoring; a library of code snippets and tutorials to get developers up and running quickly; and a community where users can interact and share code and ideas. CodeStockers also offers an API to allow developers to integrate CodeStockers into their existing applications. The platform is open source, so developers can customize and extend it to suit their needs. Furthermore, CodeStockers allows users to collaborate on code projects in real-time, enabling them to share and work on the same project simultaneously. CodeStockers also provides a suite of integrated tools such as version control, task management, and code reviews, allowing developers to easily manage their workflow and streamline their development process.
코드스토커는 개발자들이 코드를 공유하고 협업할 수 있는 온라인 플랫폼이다. 문법 강조, 자동 완성, 보풀, 코드 리팩토링을 포함한 편집기, 개발자가 빠르게 실행할 수 있는 코드 스니펫 및 튜토리얼 라이브러리, 사용자가 상호 작용하고 코드와 아이디어를 공유할 수 있는 커뮤니티를 포함하여 개발자가 더 나은 코드를 빠르게 작성할 수 있도록 도와주는 다양한 도구와 기능을 제공한다. 코드스토커는 또한 개발자들이 코드스토커를 기존 응용 프로그램에 통합할 수 있도록 API를 제공한다. 플랫폼은 오픈 소스이므로 개발자는 자신의 요구에 맞게 맞춤형으로 확장할 수 있다. 또한 코드스토커는 사용자가 코드 프로젝트에 대해 실시간으로 협업할 수 있도록 해 동일한 프로젝트를 동시에 공유하고 작업할 수 있도록 한다. CodeStockers는 또한 버전 제어, 작업 관리, 코드 검토와 같은 통합 도구 모음을 제공하여 개발자가 워크플로우를 쉽게 관리하고 개발 프로세스를 간소화할 수 있도록 합니다.

다음은 Open AI에서 제공하는 곳

(open AI에서 로그인을 해야 chat GPT를 이용할 수 있습니다.)

 

 

ChatGPT: Optimizing Language Models for Dialogue (openai.com)

 

ChatGPT: Optimizing Language Models for Dialogue

We’ve trained a model called ChatGPT which interacts in a conversational way. The dialogue format makes it possible for ChatGPT to answer followup questions, admit its mistakes, challenge incorrect premises, and reject inappropriate requests. ChatGPT is

openai.com

I apologize, but as an AI language model, I do not have access to real-time information or websites beyond what has been crawled and indexed by search engines. However, I can provide some general information about what a website is and what it might contain.

A website is a collection of web pages that are accessed through a domain name, such as www.codestockers.com. Websites can contain a variety of content, including text, images, videos, and interactive elements like forms or chatbots. Websites can be designed for various purposes, such as marketing, e-commerce, education, or entertainment.
Based on its domain name, www.codestockers.com could potentially be a website related to software development or programming. However, without more information or an active website to examine, it is difficult to provide more detail.
미안하지만, AI 언어 모델로서, 나는 검색 엔진에 의해 탐색되고 색인화된 것 이상의 실시간 정보나 웹사이트에 접근할 수 없다. 그러나 웹 사이트가 무엇이고 웹 사이트에 포함될 수 있는 내용에 대한 일반적인 정보로 제공할 수 있습니다.

웹 사이트는 www.codestockers.com과 같은 도메인 이름을 통해 액세스되는 웹 페이지의 모음입니다. 웹 사이트는 텍스트, 이미지, 비디오 및 폼 또는 챗봇과 같은 대화형 요소를 포함한 다양한 콘텐츠를 포함할 수 있습니다. 웹 사이트는 마케팅, 전자 상거래, 교육 또는 엔터테인먼트와 같은 다양한 목적을 위해 설계될 수 있습니다.
도메인 이름에 따르면 www.codestockers.com은 잠재적으로 소프트웨어 개발 또는 프로그래밍과 관련된 웹 사이트일 수 있습니다. 그러나 더 많은 정보나 검토할 활성 웹 사이트가 없으면 더 자세한 정보를 제공하기가 어렵습니다.

 

 


결론은... 글쎄? 솔직히 개인적인 사이트라서 별 다른 글이 안 올라올 것이라고는 생각했지만.. 뭔가 혁신적인 뭔 분석이 나올지 알았지만..그닥.ㅋ

you.com 은 노력한 흔적이라도 보이고 있지만, ㅎㅎ

 

그래도 인공지능 세상~~~ 곧 만날것 같은 희망이 보이네요^^

728x90
반응형
:
Posted by 패치#노트