feat: get ta indicators from taapi
This commit is contained in:
parent
1712851a07
commit
3f5ee3f5b2
|
|
@ -10,4 +10,5 @@ eval_data/
|
|||
.env
|
||||
.env.local
|
||||
|
||||
*/reports/*
|
||||
*/reports/*
|
||||
tests/
|
||||
|
|
@ -12,7 +12,8 @@ def create_market_analyst(llm, toolkit):
|
|||
company_name = state["company_of_interest"]
|
||||
|
||||
tools = [
|
||||
toolkit.get_binance_data
|
||||
toolkit.get_binance_data,
|
||||
toolkit.get_taapi_bulk_indicators
|
||||
]
|
||||
|
||||
system_message = (
|
||||
|
|
|
|||
|
|
@ -133,6 +133,56 @@ class Toolkit:
|
|||
"""
|
||||
return interface.get_fear_and_greed_index()
|
||||
|
||||
@staticmethod
|
||||
@tool
|
||||
def get_taapi_bulk_indicators(
|
||||
symbol: Annotated[str, "Ticker symbol of the asset, e.g. 'BTC'"],
|
||||
interval: Annotated[
|
||||
str,
|
||||
"Interval for the data, e.g. '1m', '5m', '1h', '1d'",
|
||||
] = "15m",
|
||||
ema_period: Annotated[int, "EMA period, default is 30"] = 30,
|
||||
ichimoku_conversionPeriod: Annotated[int, "Ichimoku conversion line period, default is 9"] = 9,
|
||||
ichimoku_basePeriod: Annotated[int, "Ichimoku base line period, default is 26"] = 26,
|
||||
ichimoku_spanPeriod: Annotated[int, "Ichimoku span period, default is 52"] = 52,
|
||||
ichimoku_displacement: Annotated[int, "Ichimoku displacement, default is 26"] = 26,
|
||||
supertrend_period: Annotated[int, "Supertrend period, default is 7"] = 7,
|
||||
supertrend_multiplier: Annotated[float, "Supertrend multiplier, default is 3.0"] = 3.0,
|
||||
psar_start: Annotated[float, "Parabolic SAR start, default is 0.02"] = 0.02,
|
||||
psar_increment: Annotated[float, "Parabolic SAR increment, default is 0.02"] = 0.02,
|
||||
psar_maximum: Annotated[float, "Parabolic SAR maximum, default is 0.2"] = 0.2,
|
||||
donchianchannels_period: Annotated[int, "Donchian Channels period, default is 20"] = 20,
|
||||
macd_optInFastPeriod: Annotated[int, "MACD fast period, default is 12"] = 12,
|
||||
macd_optInSlowPeriod: Annotated[int, "MACD slow period, default is 26"] = 26,
|
||||
macd_optInSignalPeriod: Annotated[int, "MACD signal period, default is 9"] = 9,
|
||||
rsi_period: Annotated[int, "RSI period, default is 14"] = 14,
|
||||
stochrsi_rsiPeriod: Annotated[int, "Stochastic RSI RSI period, default is 14"] = 14,
|
||||
stochrsi_kPeriod: Annotated[int, "Stochastic RSI %K period, default is 5"] = 5,
|
||||
stochrsi_dPeriod: Annotated[int, "Stochastic RSI %D period, default is 3"] = 3,
|
||||
stochrsi_stochasticPeriod: Annotated[int, "Stochastic RSI stochastic period, default is 14"] = 14,
|
||||
trix_period: Annotated[int, "TRIX period, default is 30"] = 30,
|
||||
stc_fastLength: Annotated[int, "STC fast length, default is 23"] = 23,
|
||||
stc_slowLength: Annotated[int, "STC slow length, default is 50"] = 50,
|
||||
stc_cycleLength: Annotated[int, "STC cycle length, default is 10"] = 10,
|
||||
atr_period: Annotated[int, "ATR period, default is 14"] = 14,
|
||||
bbands_period: Annotated[int, "Bollinger Bands period, default is 20"] = 20,
|
||||
bbands_stddev: Annotated[float, "Bollinger Bands standard deviation, default is 2.0"] = 2.0,
|
||||
keltnerchannels_period: Annotated[int, "Keltner Channels period, default is 20"] = 20,
|
||||
keltnerchannels_multiplier: Annotated[float, "Keltner Channels multiplier, default is 2"] = 2,
|
||||
keltnerchannels_atrLength: Annotated[int, "Keltner Channels ATR length, default is 10"] = 10,
|
||||
chop_period: Annotated[int, "Chop period, default is 14"] = 14,
|
||||
) -> str:
|
||||
"""
|
||||
Retrieve bulk technical indicators from TAAPI.io for a given symbol and interval.
|
||||
Args:
|
||||
symbol (str): Ticker symbol of the asset, e.g. 'BTC'
|
||||
interval (str): Interval for the data, e.g. '1m', '5m', '1h', '1d'
|
||||
Returns:
|
||||
str: A formatted string containing the bulk technical indicators from TAAPI.io for the specified symbol and interval.
|
||||
"""
|
||||
taapi_bulk_indicators_result = interface.get_taapi_bulk_indicators("BTC", "15m")
|
||||
return taapi_bulk_indicators_result
|
||||
|
||||
@staticmethod
|
||||
@tool
|
||||
def get_reddit_news(
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
from .blockbeats_utils import fetch_news_from_blockbeats
|
||||
from .coindesk_utils import fetch_news_from_coindesk
|
||||
from .googlenews_utils import getNewsData
|
||||
from .binance_utils import *
|
||||
from .reddit_utils import fetch_top_from_category
|
||||
|
||||
from .interface import (
|
||||
# Universal functions
|
||||
get_binance_ohlcv,
|
||||
# News and sentiment functions
|
||||
get_blockbeats_news,
|
||||
|
|
@ -16,7 +12,7 @@ from .interface import (
|
|||
# Financial statements functions
|
||||
# TODO
|
||||
# Technical analysis functions
|
||||
# TODO
|
||||
get_taapi_bulk_indicators,
|
||||
# Market data functions
|
||||
get_binance_data
|
||||
)
|
||||
|
|
@ -33,7 +29,7 @@ __all__ = [
|
|||
# Financial statements functions
|
||||
# TODO
|
||||
# Technical analysis functions
|
||||
# TODO
|
||||
"get_taapi_bulk_indicators",
|
||||
# Market data functions
|
||||
"get_binance_data"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from .reddit_utils import fetch_top_from_category
|
|||
from .googlenews_utils import *
|
||||
from .binance_utils import *
|
||||
from .alternativeme_utils import fetch_fear_and_greed_from_alternativeme
|
||||
from .taapi_utils import *
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from datetime import datetime
|
||||
|
|
@ -72,6 +73,49 @@ def get_fear_and_greed_index() -> str:
|
|||
fng = fetch_fear_and_greed_from_alternativeme()
|
||||
return f"""## Fear and Greed Index: {fng[0]}\n0 means \"Extreme Fear\", while 100 means \"Extreme Greed\"\nPrevious daily FnG: {','.join(fng[1:])}"""
|
||||
|
||||
def get_taapi_single_indicator(
|
||||
symbol: Annotated[str, "ticker symbol of the asset"],
|
||||
indicator: Annotated[
|
||||
str,
|
||||
"Technical analysis indicator to fetch, e.g., 'sma', 'ema', 'rsi', 'macd', etc.",
|
||||
],
|
||||
interval: Annotated[str, "time interval for the data, e.g., '1m', '5m', '1h'"] = "15m",
|
||||
) -> str:
|
||||
"""
|
||||
Fetch technical analysis indicators for a given symbol and interval.
|
||||
|
||||
Args:
|
||||
symbol (str): The trading pair symbol (e.g., 'BTCUSDT').
|
||||
indicator (str): The technical analysis indicator to fetch (e.g., 'sma', 'ema', 'rsi', 'macd').
|
||||
interval (str): The time interval for the data (e.g., '1m', '5m', '1h').
|
||||
|
||||
Returns:
|
||||
str: A formatted string containing the latest technical analysis indicators.
|
||||
"""
|
||||
ta_data = fetch_ta_from_taapi(symbol, indicator, interval)
|
||||
return f"## {symbol} Technical Analysis ({indicator}) at {interval}: {ta_data}\n"
|
||||
|
||||
def get_taapi_bulk_indicators(
|
||||
symbol: Annotated[str, "ticker symbol of the asset"],
|
||||
interval: Annotated[str, "time interval for the data, e.g., '1m', '5m', '1h'"] = "15m",
|
||||
**kwargs: dict
|
||||
) -> str:
|
||||
"""
|
||||
Fetch bulk technical analysis indicators for a given symbol and interval.
|
||||
|
||||
Args:
|
||||
symbol (str): The trading pair symbol (e.g., 'BTC/USDT').
|
||||
interval (str): The time interval for the data (e.g., '1m', '5m', '1h').
|
||||
**kwargs: Additional parameters for the indicators.
|
||||
Returns:
|
||||
str: A formatted string containing the latest technical analysis indicators.
|
||||
"""
|
||||
bulk = TAAPIBulkUtils(symbol, bulk_interval=interval, **kwargs)
|
||||
trend_momentum = bulk.fetch_trend_momentum_indicators_from_taapi()
|
||||
volatility_structure = bulk.fetch_volatility_structure_indicators_from_taapi()
|
||||
return f"## {symbol} Trend and Momentum Indicators at {interval}:\n{trend_momentum}\n\n" + \
|
||||
f"## {symbol} Volatility and Pattern Indicators at {interval}:\n{volatility_structure}\n"
|
||||
|
||||
def get_google_news(
|
||||
query: Annotated[str, "Query to search with"],
|
||||
curr_date: Annotated[str, "Curr date in yyyy-mm-dd format"],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,112 @@
|
|||
|
||||
import os
|
||||
from datetime import datetime, timedelta
|
||||
import requests
|
||||
from .utils import Singleton
|
||||
|
||||
def fetch_ta_from_taapi(symbol: str, indicator: str, interval: str = "15m", **params):
|
||||
"""
|
||||
Fetch technical analysis data from TAAPI.io for a given symbol and indicator.
|
||||
:note: For free plan, the rate limit is 1 request per 15 seconds.
|
||||
|
||||
:param symbol: The trading pair symbol (e.g., 'BTC/USDT').
|
||||
:param indicator: The technical indicator to fetch (e.g., 'rsi', 'macd').
|
||||
:param interval: The time interval for the data (default is '15m').
|
||||
:return: Technical analysis data for the specified indicator. (Raw JSON text)
|
||||
"""
|
||||
api_key = os.getenv("TAAPI_API_KEY")
|
||||
params = {
|
||||
"secret": api_key,
|
||||
"exchange": "binance",
|
||||
"symbol": symbol,
|
||||
"interval": interval,
|
||||
**params
|
||||
}
|
||||
url = f"https://api.taapi.io/{indicator}"
|
||||
response = requests.get(url, params=params)
|
||||
return response.text if response.status_code == 200 else None
|
||||
|
||||
class TAAPIBulkUtils(metaclass=Singleton):
|
||||
"""
|
||||
Singleton class for fetching bulk technical analysis data from TAAPI.io.\n
|
||||
:note: For free plan, the rate limit is 1 request per 15 seconds.
|
||||
"""
|
||||
|
||||
trend_momentum_indicators = [
|
||||
"ema", "ichimoku", "supertrend", "donchianchannels",
|
||||
"macd", "rsi", "stochrsi", "trix", "stc", "vwap"
|
||||
]
|
||||
volatility_structure_indicators = [
|
||||
"atr", "bbands", "keltnerchannels", "chop", "engulfing",
|
||||
"hammer", "morningstar", "eveningstar", "3whitesoldiers", "3blackcrows"
|
||||
]
|
||||
indicators = trend_momentum_indicators + volatility_structure_indicators
|
||||
|
||||
def __init__(self, symbol, bulk_interval: str = "15m", **kwargs):
|
||||
"""
|
||||
Initialize the TAAPIUtils with a trading pair symbol and interval.
|
||||
|
||||
:param symbol: The trading pair symbol (e.g., 'BTC/USDT').
|
||||
:param bulk_interval: The time interval for the data (default is '15m'). Only for bulk data.
|
||||
:param kwargs: Additional parameters for the indicators.
|
||||
"""
|
||||
self.api_key = os.getenv("TAAPI_API_KEY")
|
||||
self.bulk_data = None
|
||||
self.last_fetch_time = None
|
||||
|
||||
symbol = symbol.upper()
|
||||
if not symbol.endswith("/USDT") and not symbol.endswith("/USDC"):
|
||||
symbol += "/USDT"
|
||||
self.symbol = symbol
|
||||
self.bulk_interval = bulk_interval
|
||||
self.indicator_params = [
|
||||
{
|
||||
"indicator": indicator,
|
||||
**({k.replace(f"{indicator}_", ""): v for k, v in kwargs.items() if k.startswith(f"{indicator}_")})
|
||||
} for indicator in self.indicators
|
||||
]
|
||||
|
||||
def __fetch_bulk_ta_from_taapi(self):
|
||||
if self.bulk_data is not None and self.last_fetch_time is not None and \
|
||||
datetime.now() - self.last_fetch_time < timedelta(seconds=15):
|
||||
return self.bulk_data
|
||||
|
||||
url = "https://api.taapi.io/bulk"
|
||||
body = {
|
||||
"secret": self.api_key,
|
||||
"construct": {
|
||||
"exchange": "binance",
|
||||
"symbol": self.symbol,
|
||||
"interval": self.bulk_interval,
|
||||
"indicators": self.indicator_params
|
||||
}
|
||||
}
|
||||
self.last_fetch_time = datetime.now()
|
||||
response = requests.post(url, json=body)
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
if "data" in data and isinstance(data["data"], list):
|
||||
format_floats_in_dict = lambda d: {k: (round(v, 4) if isinstance(v, float) else v) for k, v in d.items()}
|
||||
self.bulk_data = {
|
||||
item["indicator"]: format_floats_in_dict(item["result"])
|
||||
for item in data["data"]
|
||||
}
|
||||
else:
|
||||
print(f"Error fetching bulk data: {response.status_code} - {response.text}")
|
||||
self.bulk_data = None
|
||||
|
||||
def fetch_trend_momentum_indicators_from_taapi(self):
|
||||
"""
|
||||
Fetch trend and momentum indicators from TAAPI.io.
|
||||
:return: A dictionary containing the latest values for each trend and momentum indicator.
|
||||
"""
|
||||
self.__fetch_bulk_ta_from_taapi()
|
||||
return {indicator: self.bulk_data.get(indicator, {}) for indicator in self.trend_momentum_indicators}
|
||||
|
||||
def fetch_volatility_structure_indicators_from_taapi(self):
|
||||
"""
|
||||
Fetch volatility and structure indicators from TAAPI.io.
|
||||
:return: A dictionary containing the latest values for each volatility and structure indicator.
|
||||
"""
|
||||
self.__fetch_bulk_ta_from_taapi()
|
||||
return {indicator: self.bulk_data.get(indicator, {}) for indicator in self.volatility_structure_indicators}
|
||||
|
|
@ -6,6 +6,13 @@ from typing import Annotated
|
|||
|
||||
SavePathType = Annotated[str, "File path to save data. If None, data is not saved."]
|
||||
|
||||
class Singleton(type):
|
||||
_instances = {}
|
||||
def __call__(cls, *args, **kwargs):
|
||||
if cls not in cls._instances:
|
||||
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
||||
return cls._instances[cls]
|
||||
|
||||
def save_output(data: pd.DataFrame, tag: str, save_path: SavePathType = None) -> None:
|
||||
if save_path:
|
||||
data.to_csv(save_path)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ DEFAULT_CONFIG = {
|
|||
"quick_think_llm": "qwen-turbo",
|
||||
"backend_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
||||
"api_key_env_name": "DASHSCOPE_API_KEY",
|
||||
"max_tokens": 1000, # Maximum tokens for LLM responses
|
||||
"max_tokens": 2000, # Maximum tokens for LLM responses
|
||||
# Debate and discussion settings
|
||||
"max_debate_rounds": 1,
|
||||
"max_risk_discuss_rounds": 1,
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ class TradingAgentsGraph:
|
|||
return {
|
||||
"market": ToolNode(
|
||||
[
|
||||
self.toolkit.get_taapi_bulk_indicators,
|
||||
self.toolkit.get_binance_data
|
||||
]
|
||||
),
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ PROMPTS = {
|
|||
#region Fundamentals Analyst
|
||||
"fundamentals_analyst": {
|
||||
"system_message": (
|
||||
"You are a researcher tasked with analyzing fundamental information over the past week about an asset. Please write a comprehensive report of the asset's fundamental information such as financial documents, company profile, basic company financials, company financial history, insider sentiment and insider transactions to gain a full view of the company's fundamental information to inform traders. Make sure to include as much detail as possible. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions." +
|
||||
"You are a researcher tasked with analyzing fundamental information over the past week about an asset. Please write a comprehensive report of the asset's fundamental information such as financial documents, company profile, basic company financials, company financial history, insider sentiment and insider transactions to gain a full view of the company's fundamental information to inform traders. Make sure to include as much detail as possible. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions. The report should not exceed {max_tokens}tokens." +
|
||||
" Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read."
|
||||
)
|
||||
},
|
||||
|
|
@ -23,31 +23,39 @@ PROMPTS = {
|
|||
#region Market Analyst
|
||||
"market_analyst": {
|
||||
"system_message": (
|
||||
"""You are a trading assistant tasked with analyzing financial markets. Your role is to select the **most relevant indicators** for a given market condition or trading strategy from the following list. The goal is to choose up to **8 indicators** that provide complementary insights without redundancy. Categories and each category's indicators are:
|
||||
"""You are a trading assistant tasked with analyzing financial markets.Please make sure to call get_binance_data first to retrieve the CSV that is needed to generate indicators.
|
||||
You must also call `get_taapi_bulk_indicators` to retrieve and analyze trend momentum indicators, volatility and structure indicators, etc. When passing the `interval` parameter, make sure its value is between **5m and 1d**. **Note: the `get_taapi_bulk_indicators` tool can only be called once.**
|
||||
The returned indicators include:
|
||||
|
||||
Moving Averages:
|
||||
- close_50_sma: 50 SMA: A medium-term trend indicator. Usage: Identify trend direction and serve as dynamic support/resistance. Tips: It lags price; combine with faster indicators for timely signals.
|
||||
- close_200_sma: 200 SMA: A long-term trend benchmark. Usage: Confirm overall market trend and identify golden/death cross setups. Tips: It reacts slowly; best for strategic trend confirmation rather than frequent trading entries.
|
||||
- close_10_ema: 10 EMA: A responsive short-term average. Usage: Capture quick shifts in momentum and potential entry points. Tips: Prone to noise in choppy markets; use alongside longer averages for filtering false signals.
|
||||
**Trend Indicators:**
|
||||
* `ema`: Exponential Moving Average, used to assess short- to mid-term trend; reacts quickly but may be affected by noise in choppy markets.
|
||||
* `supertrend`: Trend-following indicator that clearly defines bullish/bearish switching, ideal for swing entries in trending markets.
|
||||
* `ichimoku`: A multi-dimensional trend tool that includes support/resistance and trend consensus zones.
|
||||
* `donchianchannels`: High-low breakout bands used to detect trend initiation points.
|
||||
|
||||
MACD Related:
|
||||
- macd: MACD: Computes momentum via differences of EMAs. Usage: Look for crossovers and divergence as signals of trend changes. Tips: Confirm with other indicators in low-volatility or sideways markets.
|
||||
- macds: MACD Signal: An EMA smoothing of the MACD line. Usage: Use crossovers with the MACD line to trigger trades. Tips: Should be part of a broader strategy to avoid false positives.
|
||||
- macdh: MACD Histogram: Shows the gap between the MACD line and its signal. Usage: Visualize momentum strength and spot divergence early. Tips: Can be volatile; complement with additional filters in fast-moving markets.
|
||||
**Momentum Indicators:**
|
||||
* `macd`: Dual moving average momentum indicator; useful for identifying trend initiation and divergence signals.
|
||||
* `rsi`: Detects overbought/oversold conditions; helps identify pullbacks and rebounds in swing trades.
|
||||
* `stochrsi`: A more sensitive version of RSI, ideal for identifying short-term swing highs and lows.
|
||||
* `stc`: Schaff Trend Cycle, a fast-reacting trend cycle detector, quicker than MACD.
|
||||
* `trix`: Smoothed momentum oscillator that filters out minor price fluctuations in ranging markets.
|
||||
* `vwap`: Volume Weighted Average Price, measures the current price relative to the cost basis zone.
|
||||
|
||||
Momentum Indicators:
|
||||
- rsi: RSI: Measures momentum to flag overbought/oversold conditions. Usage: Apply 70/30 thresholds and watch for divergence to signal reversals. Tips: In strong trends, RSI may remain extreme; always cross-check with trend analysis.
|
||||
**Volatility Indicators:**
|
||||
* `atr`: Average True Range, measures volatility and helps set stop-loss/take-profit levels.
|
||||
* `bbands`: Bollinger Bands, used to detect extreme price deviations and identify reversal or breakout zones.
|
||||
* `keltnerchannels`: Volatility channel based on ATR, useful for identifying pullback entries in trends.
|
||||
* `chop`: Choppiness Index, indicates whether the market is trending or ranging, useful for strategy selection.
|
||||
|
||||
Volatility Indicators:
|
||||
- boll: Bollinger Middle: A 20 SMA serving as the basis for Bollinger Bands. Usage: Acts as a dynamic benchmark for price movement. Tips: Combine with the upper and lower bands to effectively spot breakouts or reversals.
|
||||
- boll_ub: Bollinger Upper Band: Typically 2 standard deviations above the middle line. Usage: Signals potential overbought conditions and breakout zones. Tips: Confirm signals with other tools; prices may ride the band in strong trends.
|
||||
- boll_lb: Bollinger Lower Band: Typically 2 standard deviations below the middle line. Usage: Indicates potential oversold conditions. Tips: Use additional analysis to avoid false reversal signals.
|
||||
- atr: ATR: Averages true range to measure volatility. Usage: Set stop-loss levels and adjust position sizes based on current market volatility. Tips: It's a reactive measure, so use it as part of a broader risk management strategy.
|
||||
**Structure Indicators** (Return value explanation: `0` means no pattern found on the last candle; `100` means the pattern is found; `-100` indicates the reverse trend of the pattern is found):
|
||||
* `engulfing`: Engulfing pattern, a strong trend reversal signal commonly found at swing turning points.
|
||||
* `hammer`: Hammer candle with a long lower shadow, a bullish bottom signal useful for confirming dip entries.
|
||||
* `morningstar`: Morning Star, a three-candle bullish reversal pattern, suitable for mid-term swing entry.
|
||||
* `eveningstar`: Evening Star, a bearish reversal formation signaling potential swing tops or exit points.
|
||||
* `3whitesoldiers`: Three White Soldiers, a bullish continuation pattern often used for trend confirmation and adding to positions.
|
||||
* `3blackcrows`: Three Black Crows, a bearish reversal pattern, suitable for exiting at the top of an uptrend.
|
||||
|
||||
Volume-Based Indicators:
|
||||
- vwma: VWMA: A moving average weighted by volume. Usage: Confirm trends by integrating price action with volume data. Tips: Watch for skewed results from volume spikes; use in combination with other volume analyses.
|
||||
|
||||
Select indicators that provide diverse and complementary information. Avoid redundancy (e.g., do not select both rsi and stochrsi). Also briefly explain why they are suitable for the given market context. Please make sure to call get_binance_data first to retrieve the CSV that is needed to generate indicators. Write a very detailed and nuanced report of the trends you observe. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions.""" +
|
||||
Write a very detailed and nuanced report of the trends you observe. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions. The report should not exceed {max_tokens}tokens.""" +
|
||||
" Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read."
|
||||
)
|
||||
},
|
||||
|
|
@ -56,7 +64,7 @@ Select indicators that provide diverse and complementary information. Avoid redu
|
|||
#region News Analyst
|
||||
"news_analyst": {
|
||||
"system_message": (
|
||||
"You are a news researcher tasked with analyzing recent news and trends over the past week. Please write a comprehensive report of the current state of the world that is relevant for trading and macroeconomics. Look at news from Blockbeats, and CoinDesk to be comprehensive. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions." +
|
||||
"You are a news researcher tasked with analyzing recent news and trends over the past week. Please write a comprehensive report of the current state of the world that is relevant for trading and macroeconomics. Look at news from Blockbeats, and CoinDesk to be comprehensive. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions. The report should not exceed {max_tokens}tokens." +
|
||||
" Make sure to append a Makrdown table at the end of the report to organize key points in the report, organized and easy to read."
|
||||
)
|
||||
},
|
||||
|
|
@ -65,7 +73,7 @@ Select indicators that provide diverse and complementary information. Avoid redu
|
|||
#region Social Media Analyst
|
||||
"social_media_analyst": {
|
||||
"system_message": (
|
||||
"You are a social media and company specific news researcher/analyst tasked with analyzing social media posts, recent company news, and public sentiment for a specific company over the past week. You will be given a company's name your objective is to write a comprehensive long report detailing your analysis, insights, and implications for traders and investors on this company's current state after looking at social media and what people are saying about that company, analyzing sentiment data of what people feel each day about the company, and looking at recent company news. Try to look at all sources possible from social media to sentiment to news. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions." +
|
||||
"You are a social media and company specific news researcher/analyst tasked with analyzing social media posts, recent company news, and public sentiment for a specific company over the past week. You will be given a company's name your objective is to write a comprehensive long report detailing your analysis, insights, and implications for traders and investors on this company's current state after looking at social media and what people are saying about that company, analyzing sentiment data of what people feel each day about the company, and looking at recent company news. Try to look at all sources possible from social media to sentiment to news. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions. The report should not exceed {max_tokens}tokens." +
|
||||
" Make sure to append a Makrdown table at the end of the report to organize key points in the report, organized and easy to read."
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,32 +19,38 @@ PROMPTS = {
|
|||
#region Market Analyst
|
||||
"market_analyst": {
|
||||
"system_message": (
|
||||
"""你是一名交易助理,负责分析金融市场走势。你的任务是从以下指标列表中,选出与当前市场环境或交易策略最相关的最多 8 个指标。你的目标是选择信息互补、避免重复的指标组合。指标分类及说明:
|
||||
"""你是一名交易助理,负责分析金融市场走势。请调用 get_binance_data 以获取资产的 K 线、深度、24 小时价格变化、多空比等数据,为了获取中短期的数据,传入 interval 参数时,请保证其范围为5m至1d之间,此外,必须分析15m和1h的趋势。
|
||||
你还必须调用 get_taapi_bulk_indicators 以获取并分析趋势动量指标、波动率结构指标等,传入 interval 参数时,请保证其范围为5m至1d之间,注意,**get_taapi_bulk_indicators 工具只能调用一次**。
|
||||
返回的指标包括:
|
||||
|
||||
移动平均指标:
|
||||
- close_50_sma: 50日简单移动平均线(50 SMA):中期趋势指标。用途:识别趋势方向,并作为动态支撑/阻力位。提示:其响应滞后,建议与更快的指标结合使用,以获取及时信号。
|
||||
- close_200_sma: 200日简单移动平均线(200 SMA):长期趋势基准指标。用途:确认整体市场趋势,识别黄金交叉/死亡交叉形态。提示:反应较慢,更适用于战略性趋势确认,而非频繁交易入场。
|
||||
- close_10_ema: 10日指数移动平均线(10 EMA):对价格变化反应迅速的短期平均。用途:捕捉动量变化和潜在进出场点。提示:在震荡行情中容易受到噪声干扰,建议与较长周期均线结合使用以过滤虚假信号。
|
||||
趋势类指标:
|
||||
- ema: 指数加权均线,判断中短期趋势,反应快但易被震荡干扰
|
||||
- supertrend: 趋势跟踪工具,明确多空切换,适合顺势波段进出
|
||||
- ichimoku: 多维趋势判断工具,含支撑阻力与共振带
|
||||
- donchianchannels: 高低突破区间,适合识别趋势启动点
|
||||
|
||||
MACD 相关指标:
|
||||
- macd: MACD:通过EMA之间的差值计算动量。用途:观察交叉与背离,作为趋势变化的信号。提示:在低波动或震荡市场中应结合其他指标确认信号有效性。
|
||||
- macds: MACD信号线(MACD Signal):MACD线的平滑EMA。用途:与MACD线交叉时提供交易触发信号。提示:建议作为策略组合的一部分使用,以避免产生误判。
|
||||
- macdh: MACD柱状图(MACD Histogram):展示MACD线与信号线之间的差距。用途:可视化动量强度并早期识别背离。提示:可能较为剧烈波动,建议在快节奏市场中搭配过滤器使用。
|
||||
动量类指标:
|
||||
- macd: 双均线动量指标,识别趋势启动与背离信号
|
||||
- rsi: 超买超卖判断,适合捕捉波段回调与反弹机会
|
||||
- stochrsi: 更敏感的RSI版本,用于短周期波段高低点识别
|
||||
- stc: 快速趋势周期识别,比MACD反应更快
|
||||
- trix: 平滑动量变化,适合过滤震荡区域的假信号
|
||||
- vwap: 成交量加权均价,衡量当前价格相对成本区位置
|
||||
|
||||
动量指标:
|
||||
- rsi: 相对强弱指标(RSI):衡量动量,用于识别超买/超卖状态。用途:应用70/30阈值,并关注背离信号以判断反转可能。提示:在强趋势中RSI可能长时间处于极端值,需结合趋势分析确认信号。
|
||||
波动类指标:
|
||||
- atr: 平均真实波幅,衡量波动强度并设定止盈止损
|
||||
- bbands: 捕捉价格极端波动,识别反转与突破
|
||||
- keltnerchannels: 基于ATR的波动通道,适合回踩买入参考
|
||||
- chop: 判断市场处于趋势还是震荡,有助于策略选择
|
||||
|
||||
波动性指标:
|
||||
- boll: 布林中轨(Bollinger Middle):以20日SMA为基础的布林带中线。用途:作为价格波动的动态基准。提示:结合上下轨使用更能有效识别突破或反转。
|
||||
- boll_ub: 布林上轨(Bollinger Upper Band):一般为中轨上方两个标准差。用途:提示可能处于超买状态或突破区域。提示:需结合其他工具确认信号;强趋势中价格可能沿带运行。
|
||||
- boll_lb: 布林下轨(Bollinger Lower Band):一般为中轨下方两个标准差。用途:提示可能的超卖状态。提示:为避免错误信号,应结合其他分析工具。
|
||||
- atr: 平均真实波幅(ATR):通过真实区间平均衡量市场波动。用途:设定止损水平,并根据当前波动性调整仓位大小。提示:属于滞后型指标,适合用于整体风险管理策略中。
|
||||
结构类指标(返回值说明:若值为 0,则表明最后的蜡烛没有找到形态;100表明发现该形态;-100 表明发现该形态的反向趋势):
|
||||
- engulfing: 吞没线,强烈的趋势反转形态,常见于波段转折点
|
||||
- hammer: 锤头线,下影线长的底部信号,适合低吸策略确认
|
||||
- morningstar: 晨星,三段式底部反转形态,适合中期波段进场
|
||||
- eveningstar: 黄昏星,顶部反转结构,提示波段顶部或减仓信号
|
||||
- 3whitesoldiers: 红三兵,多头延续形态,常用于趋势确认加仓
|
||||
- 3blackcrows: 三黑鸦,空头反转形态,适合高位反转波段出场
|
||||
|
||||
成交量指标:
|
||||
- vwma: 成交量加权移动平均线(VWMA):基于成交量加权的价格平均。用途:将价格走势与成交量结合,确认趋势强度。提示:成交量激增时可能造成偏差,建议搭配其他成交量指标使用。
|
||||
|
||||
选择提供多样化和互补信息的指标。避免冗余(例如,不要同时选择rsi和stochrsi)。还简要解释为什么它们适合给定的市场环境。
|
||||
请调用 get_binance_data 以获取资产的 K 线、深度、24 小时价格变化、多空比等数据,为了获取中短期的数据,传入 interval 参数时,请保证其范围为5m至1d之间,此外,必须分析15m和1h的趋势。
|
||||
写一份详细但不超过 {max_tokens}tokens 的报告,说明你观察到的趋势。不要简单地说趋势是混合的,提供详细和细粒度的分析和见解,以帮助交易者做出决策。""" +
|
||||
" 最后请附上一张 Markdown 表格,总结并清晰地整理报告中的关键要点,便于阅读和参考。"
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue