1
This commit is contained in:
parent
8e058603ff
commit
7a544b3bed
@ -1,7 +1,7 @@
|
||||
import requests
|
||||
from binance.spot import Spot
|
||||
import pandas as pd
|
||||
|
||||
from datetime import timezone, timedelta
|
||||
|
||||
api_key = "HCpeel8g6fsTK2630b7BvGBcS09Z3qfXkLVcAY2JkpaiMm1J6DWRvoQZBQlElDJg"
|
||||
api_secret= "TySs6onlHOTrGzV8fMdDxLKTWWYnQ4rCHVAmjrcHby17acKflmo7xVTWVsbqtxe7"
|
||||
@ -85,7 +85,7 @@ def get_klines(symbol,interval):
|
||||
df['volume'] = df['volume'].astype('float64')
|
||||
|
||||
# 将时间戳转换为日期时间格式
|
||||
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
|
||||
df['close_time'] = pd.to_datetime(df['close_time'], unit='ms')
|
||||
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms', utc=True).map(lambda x: x.tz_convert('Asia/Shanghai'))
|
||||
df['close_time'] = pd.to_datetime(df['close_time'], unit='ms', utc=True).map(lambda x: x.tz_convert('Asia/Shanghai'))
|
||||
|
||||
return df
|
||||
5
main.py
5
main.py
@ -3,7 +3,6 @@ import setting
|
||||
import time
|
||||
import monitors.vegas as vegas
|
||||
import monitors.large_transfer as lt
|
||||
import utils
|
||||
|
||||
# 监控大额转账
|
||||
schedule.every(setting.whaleAlert_minutes).minutes.do(lt.run)
|
||||
@ -15,9 +14,7 @@ times = ["00:00", "04:00", "08:00", "12:00", "16:00", "20:00"]
|
||||
for t in times:
|
||||
schedule.every().day.at(t).do(vegas.run_crypto, interval = '4h')
|
||||
|
||||
print(f'Running... V1.1')
|
||||
print(f'Pairs:')
|
||||
print(utils.get_top_binance_usdt_pairs(20))
|
||||
print(f'Running... V1.2')
|
||||
while True:
|
||||
schedule.run_pending()
|
||||
time.sleep(1)
|
||||
|
||||
@ -48,7 +48,19 @@ def stratergy_run(symbol, interval,df):
|
||||
if latest['longResut']==True:
|
||||
direction = '多'
|
||||
|
||||
message = f"⭐️信号提醒⭐️\r\n\r\n策略:【Vegas趋势跟踪V1.0】\r\n品种: {symbol}\r\n周期: {interval}\r\n信号: 【{direction}】\r\n当前价格:{latest['open']}\r\n\r\n{latest['timestamp']}"
|
||||
message = f"⭐️信号提醒⭐️\r\n\
|
||||
\r\n\
|
||||
策略:【Vegas趋势跟踪V1.0】\r\n\
|
||||
品种: {symbol}\r\n\
|
||||
周期: {interval}\r\n\
|
||||
信号: 【{direction}】\r\n\
|
||||
r\n\
|
||||
当前价格:{latest['open']}\r\n\
|
||||
EMA13:{latest['ema13']}\r\n\
|
||||
EMA144:{latest['ema144']}\r\n\
|
||||
EMA169:{latest['ema169']}\r\n\
|
||||
\r\n\
|
||||
{latest['timestamp']}"
|
||||
print(f"{symbol} - {interval} is checked!")
|
||||
if direction != "":
|
||||
telegram_sender.send_message(setting.chat_id, message)
|
||||
@ -57,7 +69,8 @@ def stratergy_run(symbol, interval,df):
|
||||
def run_crypto(interval):
|
||||
print('Vegas策略运行....')
|
||||
|
||||
symbols = crypto.get_top_binance_usdt_pairs(10)
|
||||
# symbols = crypto.get_top_binance_usdt_pairs(10)
|
||||
symbols = ['BTCUSDT',"ETHUSDT",'LTCUSDT','DOGEUSDT','FTMUSDT','FILUSDT','OPUSDT','SOLUSDT','BNBUSDT','BCHUSDT','ETCUSDT','ARUSDT']
|
||||
for s in symbols:
|
||||
df = crypto.get_klines(s, interval)
|
||||
stratergy_run(s,interval, df)
|
||||
|
||||
22
test.py
22
test.py
@ -2,25 +2,7 @@ import yfinance as yf
|
||||
import pandas as pd
|
||||
import monitors
|
||||
import monitors.vegas
|
||||
|
||||
# monitors.vegas.run('1d')
|
||||
from datasource import crypto
|
||||
|
||||
|
||||
|
||||
import yfinance as yf
|
||||
import pandas as pd
|
||||
|
||||
# 定义股票代码(例如苹果公司的股票代码为AAPL)
|
||||
ticker = 'AAPL'
|
||||
|
||||
# 下载日线数据
|
||||
data = yf.download(ticker, interval='1d', period='2y') # 过去一年的数据
|
||||
|
||||
# 打印数据
|
||||
print(data)
|
||||
|
||||
# 如果需要将时间格式转换为可读格式
|
||||
data.index = pd.to_datetime(data.index)
|
||||
|
||||
# 打印前几行数据
|
||||
print(data.head())
|
||||
print(crypto.get_klines('BTCUSDT', '1h'))
|
||||
43
utils.py
43
utils.py
@ -1,43 +0,0 @@
|
||||
import requests
|
||||
|
||||
|
||||
# 获取市值前10的币种
|
||||
def get_top_coins_by_market_cap(top):
|
||||
|
||||
coingecko_url = "https://api.coingecko.com/api/v3/coins/markets"
|
||||
params = {
|
||||
'vs_currency': 'usd',
|
||||
'order': 'market_cap_desc',
|
||||
'per_page': top,
|
||||
'page': 1
|
||||
}
|
||||
response = requests.get(coingecko_url, params=params)
|
||||
coins = response.json()
|
||||
return coins
|
||||
|
||||
# 获取Binance上的USDT交易对信息
|
||||
def get_binance_usdt_pairs():
|
||||
url = "https://api.binance.com/api/v3/exchangeInfo"
|
||||
response = requests.get(url)
|
||||
data = response.json()
|
||||
|
||||
usdt_pairs = [symbol['symbol'] for symbol in data['symbols'] if (symbol['quoteAsset'] == 'USDT' and symbol['status'] == 'TRADING')]
|
||||
return usdt_pairs
|
||||
|
||||
def get_top_binance_usdt_pairs(top):
|
||||
# 获取市值前10的币种
|
||||
top_coins = get_top_coins_by_market_cap(top)
|
||||
|
||||
# 获取Binance上的USDT交易对
|
||||
usdt_pairs = get_binance_usdt_pairs()
|
||||
|
||||
|
||||
# 筛选出前10币种中与USDT有交易对的币种
|
||||
top_pairs = []
|
||||
for coin in top_coins:
|
||||
coin_symbol = coin['symbol'].upper()
|
||||
pair = f"{coin_symbol}USDT"
|
||||
if pair in usdt_pairs:
|
||||
top_pairs.append(pair)
|
||||
|
||||
return top_pairs
|
||||
Loading…
Reference in New Issue
Block a user