This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import queue | |
import time | |
import pyupbit | |
import datetime | |
from collections import deque | |
class Consumer(threading.Thread): | |
def __init__(self, q): | |
super().__init__() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
# 전역 변수 | |
r = 0 | |
class Consumer(threading.Thread): | |
def run(self): | |
global r | |
for _ in range(1000000): | |
r += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyupbit | |
import plotly.graph_objects as go | |
from plotly.subplots import make_subplots | |
import time | |
import pandas as pd | |
def get_ohlcv(ticker): | |
dfs = [ ] | |
# df = pyupbit.get_ohlcv(ticker, interval="minute1", to="20210423 11:00:00") | |
df = pyupbit.get_ohlcv(ticker, interval="minute1", to="20210414 23:00:00") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import time | |
for page in range(1, 6): | |
url = f"https://www.fss.or.kr/fss/kr/bbs/list.jsp?url=/fss/kr/1207404857348&bbsid=1207404857348&page={page}" | |
resp = requests.get(url) | |
soup = BeautifulSoup(resp.text, 'html5lib') | |
sel = "#contents_area > div.contents > table > tbody > tr > td.tit > a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyupbit | |
tickers = pyupbit.get_tickers(fiat="KRW") | |
price_data = pyupbit.get_current_price(tickers) | |
result = [ ] | |
for ticker, price in price_data.items(): | |
if price < 100: | |
result.append(ticker) | |
print(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyupbit | |
import matplotlib.pyplot as plt | |
import time | |
import pandas as pd | |
def short_trading_for_1percent(ticker): | |
dfs = [ ] | |
df = pyupbit.get_ohlcv(ticker, interval="minute1", to="20210414 23:00:00") | |
dfs.append(df) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
url = "https://www.petronet.co.kr/v3/jsp/pet/tra/KDXQ1900_l.jsp" | |
data = { | |
"term": "m", | |
"by": "2021", | |
"bq": "1", | |
"bm": "01", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
url = "https://www.petronet.co.kr/v3/jsp/pet/tra/KDXQ1900_l.jsp?term=m&by=2021&bq=1&bm=01&ay=2021&aq=1&am=02&PriceCD=1&ProdCd=B0&Parameter=%3ABusisec%3D%271%27%2C%3APriceCD%3D%271%27%2C%3AFromDate%3D%27202101%27%2C%3AToDate%3D%27202102%27%2C%3AProdCD%3D%27%5C%27B0%5C%27+%27&InitialLoadFile=&ProdCDList=B0&ProdNMList=%C8%D6%B9%DF%C0%AF%2C%B5%EE%C0%AF%2C%B0%E6%C0%AF%2C%B0%E6%C1%FA%C1%DF%C0%AF%2C%C1%DF%C0%AF%2C%B9%E6%C4%ABC%C0%AF%2C%B3%B3%BB%E7%2C%BF%EB%C1%A6%2C%C7%D7%B0%F8%C0%AF%2CLPG%2C%BE%C6%BD%BA%C6%C8%C6%AE%2C%C0%B1%C8%B0%C0%AF%2C%B1%E2%C5%B8+%C1%A6%C7%B0%2C%BA%CE%BB%FD%BF%AC%B7%E1%C0%AF" | |
resp = requests.post(url) | |
soup = BeautifulSoup(resp.text, 'html5lib') | |
result = soup.select("#csvExportTable0 > tbody > tr > td:nth-child(2)") | |
for item in result: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
async def A(q): | |
num1 = 3 | |
num2 = await q.get() | |
if num1 < num2: | |
print("OK") | |
async def B(q): | |
num2 = 5 |