获取pricenow测试通过,需写breakoutlog逻辑
This commit is contained in:
parent
c4de17b7ec
commit
f35670ca53
@ -334,9 +334,11 @@ class TurtleTrading_OnTime(object):
|
||||
# stock_zh_a_spot_df['时间'] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
# mysql_database.insert_db(stock_zh_a_spot_df, "stock_price", True, "代码")
|
||||
|
||||
# etf_data = ak.fund_etf_spot_em()
|
||||
etf_data = ak.fund_etf_spot_ths()
|
||||
etf_data = etf_data.dropna(subset=['当前-单位净值'])
|
||||
etf_data = ak.fund_etf_spot_em()
|
||||
# etf_data = ak.fund_etf_spot_ths()
|
||||
# etf_data = etf_data.dropna(subset=['当前-单位净值'])
|
||||
etf_data = etf_data.dropna(subset=['最新价'])
|
||||
|
||||
# etf_data['时间'] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
# mysql_database.insert_db(etf_data, "etf_price", True, "代码")
|
||||
return stock_data, etf_data
|
||||
@ -562,23 +564,21 @@ class TurtleTrading_OnTime(object):
|
||||
(now.hour == 15 and now.minute <= 0)
|
||||
)
|
||||
|
||||
if not is_trading_time:
|
||||
# 非交易时间,等待 1 分钟后继续循环
|
||||
time.sleep(60)
|
||||
continue
|
||||
# if not is_trading_time:
|
||||
# # 非交易时间,等待 1 分钟后继续循环
|
||||
# time.sleep(60)
|
||||
# continue
|
||||
|
||||
# 获取股票和ETF数据
|
||||
stock_data, etf_data = self.get_stocks_data()
|
||||
|
||||
# 根据类型获取当前价格
|
||||
if self.turtle.Type == "stock":
|
||||
self.turtle.PriceNow = stock_data[
|
||||
stock_data['代码'] == self.turtle.TradeCode
|
||||
]['最新价'].iloc[-1]
|
||||
elif self.turtle.Type == "etf":
|
||||
self.turtle.PriceNow = etf_data[
|
||||
etf_data['代码'] == self.turtle.TradeCode
|
||||
]['当前-单位净值'].iloc[-1]
|
||||
if self.turtle.type == "stock":
|
||||
self.turtle.PriceNow = float(stock_data.loc[etf_data['代码'] == self.turtle.TradeCode, '最新价'].values[0])
|
||||
|
||||
elif self.turtle.type == "etf":
|
||||
# self.turtle.PriceNow = float(etf_data.loc[etf_data['基金代码'] == self.turtle.TradeCode, '当前-单位净值'].values[0])
|
||||
self.turtle.PriceNow = float(etf_data.loc[etf_data['代码'] == self.turtle.TradeCode, '最新价'].values[0])
|
||||
|
||||
# 判断当前仓位状态并执行相应操作
|
||||
if self.turtle.TrigerTime == 0:
|
||||
@ -660,7 +660,7 @@ class TurtleTrading_OnTime(object):
|
||||
|
||||
if __name__ == '__main__':
|
||||
user_email = "guoyize2209@163.com"
|
||||
t = TurtleTrading('513300', "etf", 0.0025, 100000, 200000)
|
||||
t = TurtleTrading('513870', "etf", 0.0025, 100000, 200000)
|
||||
# t.get_ready(100)
|
||||
|
||||
a = TurtleTrading_OnTime(t, user_email)
|
||||
|
1114
etf_data.csv
Normal file
1114
etf_data.csv
Normal file
File diff suppressed because it is too large
Load Diff
1126
etf_data_em.csv
Normal file
1126
etf_data_em.csv
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user