This commit is contained in:
aaron 2024-10-06 00:00:34 +08:00
parent fdb3423f29
commit e93ec6516c
7 changed files with 12 additions and 14 deletions

View File

@ -67,6 +67,7 @@ def get_symbols():
def get_future_symbols(): def get_future_symbols():
data = future_client.exchange_info()["symbols"] data = future_client.exchange_info()["symbols"]
print(data)
# 创建DataFrame # 创建DataFrame
columns = ['symbol', 'status','contractType', 'baseAsset', 'quoteAsset'] columns = ['symbol', 'status','contractType', 'baseAsset', 'quoteAsset']

View File

@ -31,7 +31,7 @@ for t in times:
#jin10 #jin10
schedule.every().day.at("00:00").do(jin10.run) schedule.every().day.at("00:00").do(jin10.run)
version = 'V1.22' version = 'V1.23'
print(f'Running... {version}') print(f'Running... {version}')
while True: while True:
schedule.run_pending() schedule.run_pending()

View File

@ -25,6 +25,9 @@ def stratergy_run(symbol, interval, df, debug):
bollinger_length = 20 bollinger_length = 20
bollinger_mult = 2.0 bollinger_mult = 2.0
# 计算EMA 144 200
fast_ema = talib.EMA(df['close'], timeperiod=144)
slow_ema = talib.EMA(df['close'], timeperiod=200)
# 计算 MACD # 计算 MACD
macd, macd_signal, macd_hist = talib.MACD(df['close'], fastperiod=macd_fast_length, slowperiod=macd_slow_length, signalperiod=macd_signal_length) macd, macd_signal, macd_hist = talib.MACD(df['close'], fastperiod=macd_fast_length, slowperiod=macd_slow_length, signalperiod=macd_signal_length)
@ -32,10 +35,9 @@ def stratergy_run(symbol, interval, df, debug):
# 计算布林带 # 计算布林带
upperband, middleband, lowerband = talib.BBANDS(df['close'], timeperiod=bollinger_length, nbdevup=bollinger_mult, nbdevdn=bollinger_mult, matype=0) upperband, middleband, lowerband = talib.BBANDS(df['close'], timeperiod=bollinger_length, nbdevup=bollinger_mult, nbdevdn=bollinger_mult, matype=0)
# 生成交易信号 # 生成交易信号
long_condition = (macd.shift(1) <= 0) & (macd > 0) & (df['high'] < upperband) long_condition = (macd.shift(1) <= 0) & (macd > 0) & (df['high'] < upperband) & (df['close'] > fast_ema | df['close'] > slow_ema)
short_condition = (macd.shift(1) >= 0) & (macd < 0) & (df['low'] > lowerband) short_condition = (macd.shift(1) >= 0) & (macd < 0) & (df['low'] > lowerband) & (df['close'] < fast_ema | df['close'] < slow_ema)
df['Long_Signal'] = np.where(long_condition, True, False) df['Long_Signal'] = np.where(long_condition, True, False)
@ -50,7 +52,7 @@ def stratergy_run(symbol, interval, df, debug):
if latest['Long_Signal'] == True: if latest['Long_Signal'] == True:
direction = '' direction = ''
if direction != "": if direction != "":
message = f"策略:【MACD+BOLL价格策略】\r\n" message = f"策略:【MACD+BOLL策略V1.1\r\n"
message += f"品种: {symbol}\r\n" message += f"品种: {symbol}\r\n"
message += f"周期: {interval}\r\n" message += f"周期: {interval}\r\n"
message += f"信号: 【{direction}\r\n" message += f"信号: 【{direction}\r\n"

View File

@ -4,6 +4,7 @@ import telegram_sender
from datasource import crypto from datasource import crypto
import dingding import dingding
import discord_sender import discord_sender
import setting
# crossover 函数:检测上穿信号 # crossover 函数:检测上穿信号
@ -55,9 +56,7 @@ def stratergy_run(symbol, interval, df, debug):
def run_crypto(interval, debug=False): def run_crypto(interval, debug=False):
for s in setting.symbols:
symbols = ['BTCUSDT','ETHUSDT','BNBUSDT','SOLUSDT','DOGEUSDT','LINKUSDT','NEARUSDT','WIFUSDT','ARBUSDT','ARUSDT','JASMYUSDT','FTMUSDT','EGLDUSDT','ENSUSDT','GALAUSDT','ORDIUSDT','TRUUSDT','LPTUSDT','JUPUSDT','WIFUSDT','AVAXUSDT','GALUSDT','BONKUSDT','UNFIUSDT','CHZUSDT']
for s in symbols:
df = crypto.get_klines(s, interval) df = crypto.get_klines(s, interval)
stratergy_run(s,interval, df, debug) stratergy_run(s,interval, df, debug)

View File

@ -66,8 +66,6 @@ def stratergy_run(symbol, interval, df, debug):
def run_crypto(interval, debug=False): def run_crypto(interval, debug=False):
print('Vegas策略运行.')
for s in setting.symbols: for s in setting.symbols:
df = crypto.get_klines(s, interval) df = crypto.get_klines(s, interval)
stratergy_run(s,interval, df, debug) stratergy_run(s,interval, df, debug)

View File

@ -58,8 +58,6 @@ def stratergy_run(symbol, interval, df, debug):
def run_crypto(interval, debug=False): def run_crypto(interval, debug=False):
print('Vegas策略运行.')
for s in setting.symbols: for s in setting.symbols:
df = crypto.get_klines(s, interval,True) df = crypto.get_klines(s, interval,True)
stratergy_run(s,interval, df, debug) stratergy_run(s,interval, df, debug)

View File

@ -16,9 +16,9 @@ import redis
# print(r.get('r_symbols')) # print(r.get('r_symbols'))
# print(datasource.crypto.get_future_symbols()) print(datasource.crypto.get_future_symbols())
macd_boll.run_crypto('15m', debug=True) # macd_boll.run_crypto('15m', debug=True)
# jin10_cal.run() # jin10_cal.run()