이하영

open_api 함수 추가

......@@ -237,8 +237,7 @@ class Simulator_Func:
columns=['id', 'order_num', 'code', 'code_name', 'rate', 'purchase_rate',
'purchase_price','present_price', 'valuation_price','valuation_profit',
'holding_amount', 'buy_date', 'item_total_purchase','chegyul_check',
'invest_unit','sell_date', 'sell_price', 'sell_rate', 'rate_std',
'rate_std_mod_val','rate_std_htr', 'rate_htr','rate_std_mod_val_htr',
'invest_unit','sell_date', 'sell_price', 'sell_rate',
'yes_close', 'close', 'd1_diff_rate', 'd1_diff',
'open', 'high','low','volume',
'clo5', 'clo10', 'clo20', 'clo60','clo120',
......@@ -1191,4 +1190,31 @@ class Simulator_Func:
# 매도 리스트가 존재하지 않는다면 매수만 진행
else:
if self.check_balance():
self.auto_trade_buy_stock(str(date_rows_today) + "0900", date_rows_today, date_rows_yesterday)
\ No newline at end of file
self.auto_trade_buy_stock(str(date_rows_today) + "0900", date_rows_today, date_rows_yesterday)
# daily_buy_list 데이터베이스에서 가장 최근의 날짜 테이블을 가져오는 함수
def get_recent_daily_buy_list_date(self):
query="select TABLE_NAME from information_schema.tables " \
"where table_schema = 'daily_buy_list' and TABLE_NAME like '%s' order by table_name desc limit 1"
row = self.engine_daily_buy_list.execute(query % ("20%%")).fetchall()
if len(row) == 0:
return False
return row[0][0]
# 최근 daily_buy_list의 날짜 테이블에서 code에 해당하는 데이터만 가져오는 함수
def get_daily_buy_list_by_code(self,code,date):
query = f"select * from `{date}` where code = '{code}' group by code"
daily_buy_list = self.engine_daily_buy_list.execute(query).fetchall()
df_daily_buy_list = DataFrame(daily_buy_list,
columns=['index', 'index2', 'date', 'check_item',
'code', 'code_name', 'd1_diff', 'd1_diff_rate',
'close', 'open','high', 'low', 'volume',
'clo5', 'clo10', 'clo20', 'clo60', 'clo120',
"clo5_diff_rate", "clo10_diff_rate", "clo20_diff_rate",
"clo60_diff_rate", "clo120_diff_rate",
'yes_clo5', 'yes_clo10', 'yes_clo20', 'yes_clo60','yes_clo120',
'vol5', 'vol10', 'vol20', 'vol60', 'vol120'])
return df_daily_buy_list
......
This diff is collapsed. Click to expand it.
from sqlalchemy import *
from open_api import *
from daily_info import *
from stock_info import *
import config
class CollectorApi():
def __init__(self):
self.open_api=OpenApi()
self.engine_bot=self.open_api.engine_bot
def set_variable(self):
self.open_api.sort="collector"
self.stock_info=StockInfo(config.real_bot,config.real_stockInfo,config.real_dailyInofo)
self.daily_info=DailyInfo()
def update_code(self):
print("update code")
query = "select code_update,jango_data_db_check, possessed_item, today_profit, final_chegyul_check, " \
"db_to_buy_list,today_buy_list, daily_crawler , min_crawler, daily_buy_list " \
"from setting_data limit 1"
result=self.engine_bot.execute(query).fetchall()
print(result)
if result[0][0]!=self.open_api.today():
self.open_api.check_balance()
self.get_code_list()
def set_db_minute_info(self):
print("Make Minute Info Database")
query="select code,code_name from stock_all"
target=self.open_api.engine_dInfo.execute(query).fetchall()
print(target)
app = QApplication(sys.argv)
c=CollectorApi()
c.update_code()
\ No newline at end of file
This diff is collapsed. Click to expand it.