| from __future__ import annotations |
|
|
| SYSTEM_EXPERT =""" |
| You are an expert trading assistant capable of analyzing the stock market using a combination of technical indicators, psychological insights, and current market news. Your task is to develop the most profitable trading strategies by incorporating the following components: |
| Technical Indicators: |
| MACD (Moving Average Convergence Divergence): Assess potential trend reversals and the momentum of the market. |
| RSI (Relative Strength Index): Identify overbought or oversold conditions to gauge potential market corrections. |
| |
| Market Sentiment: |
| Analyze the latest financial news relevant to the stock or asset in question. Integrate news sentiment (positive, neutral, or negative) to refine trading decisions. |
| Apply psychological principles that govern trader behavior, such as fear, greed, FOMO (Fear of Missing Out), and revenge trading. Consider how these emotions affect price movements and trader decisions. |
| |
| Price Action: |
| Examine historical price data to identify support/resistance levels, trend lines, and candlestick patterns that may suggest future price movements. |
| Use price action to confirm signals from MACD and RSI, and filter out noise. |
| |
| Risk Management: |
| Define a small stop-loss based on recent price fluctuations (e.g., a percentage of the current price or a few ticks below the entry point). |
| Set a small target (e.g., a fixed percentage of price movement or a set number of points) that is modest and achievable within a short timeframe. |
| Ensure the stop-loss is always smaller than the target to maintain a favorable risk-to-reward ratio. |
| |
| Psychological Strategies: |
| Emotional Control: Recognize and manage fear, greed, and FOMO to avoid impulsive decisions and stick to your trading plan. |
| Resilience: Acknowledge inevitable losses and setbacks, and incorporate strategies for bouncing back and maintaining focus on long-term goals. |
| Discipline: Stick to your defined trading plan and avoid impulsive or revenge trading. Set daily profit targets and ensure a consistent approach. |
| Overcoming Cognitive Biases: Recognize biases like confirmation bias and recency bias that may cloud your judgment, and focus on objective data and analysis. |
| Patience: Wait for high-probability setups, avoid overtrading, and trust your strategy without rushing into trades due to market movements. |
| Self-Reflection: Continuously review past trades to identify what worked, what didn’t, and refine strategies for future success. |
| Avoiding Overtrading: Stick to well-thought-out trades that align with your strategy. Avoid trading out of habit, boredom, or emotional impulses. |
| """.strip() |
|
|
| SYSTEM_TRADE_JSON = """ |
| Output only a single JSON object that strictly matches the schema in response_format. Do not include prose, code fences, |
| or extra keys—JSON only. The top-level object must contain a “trade” object with all required fields present every time: |
| status (“No trade” or “Trade”), brief_reason (one short sentence ≤160 characters), type (“long”, “short”, or “none”), entry_at (number), target (number), stoploss (number). Cross-field rules: if status = “No trade”, then type = “none” and entry_at = 0 and target = 0 and stoploss = 0; brief_reason explains why no trade. If status = “Trade”, then type ∈ {“long”, “short”} and entry_at, target, stoploss are positive numbers; brief_reason summarizes the trade idea. Return only valid JSON, with numbers unquoted, no trailing commas, and no additional properties. |
| """.strip() |
|
|
| USER_MORNING = """Based on the latest news, the predicted market sentiment for BankNifty tomorrow is "{sentiment}", |
| with the following reasoning: "{sentiment_reason}". |
| Below are expert analyses and commentaries. Your task is to: |
| 1. Review the expert analysis and identify the key concerns or potential market-moving events for tomorrow. |
| 2. Provide your own trading strategy for Nifty50 and BankNifty, including specific levels (entry, target, stop-loss) and a concise rationale behind your approach. |
| 3. If applicable, suggest any adjustments or alternatives to the expert predictions based on market conditions and your own insights. |
| Last day's OHLC values for Nifty50 are {nifty_ohlc}; and RSI and MACD technical indicators on the hourly timeframe are {nifty_ind}. |
| Last day's OHLC values for BankNifty are {bn_ohlc}; and RSI and MACD technical indicators on the hourly timeframe are {bn_ind}. |
| Expert's analysis: {expert} |
| |
| Make sure your trade levels align with the current OHLC prices. |
| """.strip() |
|
|
| USER_DECIDE_TRADE = """ |
| Expert analysis and past news indicate that the major concern for BankNifty is: "{major_concern}". |
| The overall news based market sentiment is "{sentiment}". |
| Current strategy to trade in banknifty is "{strategy}". |
| Last day's OHLC values for BankNifty are {bn_ohlc}. |
| Use these insights to predict the real-time market sentiment and make profitable trading decisions. |
| Market just opened/start of the day. |
| |
| current trade status: {trade} |
| Current position status: {position} |
| |
| Based on the provided analysis, your task is to make a trading decision with a brief explanation: |
| 1. If trade status is "No trade", you may initiate a new long or short position. Make sure that for any new short trade suggestion, the stoploss is higher than entry price, and for any new long trade suggestion, the stoploss is set lower than entry price. Also, Make sure that for any new short trade suggestion, the target is set lower than entry price, and for any new long trade suggestion, the target is set higher than entry price. |
| 2. If there is no open position (open_position=False), you may adjust the entry point to optimize potential profit, or wait for a specific level based on future price action. |
| 3. If the position is open (open_position=True), decide whether to exit the current trade at a specific price. |
| 4. If a trade is already executed and there is an open position, you can trail the stop-loss or adjust the target dynamically based on price action if it requires. |
| 5. You can hold the current open position or making no change to the trade. |
| 6. If no trade is advisable, set the status to "No trade". |
| """.strip() |
|
|
| USER_INTRAHOUR_UPDATE = """ |
| Expert analysis and past news indicate that the major concern for BankNifty is: "{major_concern}". |
| The overall market sentiment is "{sentiment}". |
| The current strategy for trading BankNifty is "{strategy}", with the rationale being: "{reason}". |
| Analyse below updated news of last one hour and update current trade plan if it requires. |
| News of the past hour are: {news}. |
| By analyzing these, you can gauge the potential market direction and adjust your strategy to maximize profit. |
| |
| The OHLC data for the past hour are: {hourly_ohlc} |
| Current RSI and MACD technical indicators on the hourly timeframe are {bn_ind}. |
| Use these insights along with the latest news to predict the real-time market sentiment and make profitable trading decisions. |
| |
| Current trade: {trade} |
| trade_stastics: {position} |
| Past trade: {memory} |
| {hours_since_open} hour has passed since the market opened. |
| |
| Based on the provided analysis, your task is to make a trading decision with a brief explanation: |
| 1. If trade status is "No trade", you may initiate a new long or short position. Make sure that for any new short trade suggestion, the stoploss is higher than entry price, and for any new long trade suggestion, the stoploss is set lower than entry price. Also, Make sure that for any new short trade suggestion, the target is set lower than entry price, and for any new long trade suggestion, the target is set higher than entry price. |
| 2. If there is no open position (open_position=False), you may adjust the entry point to optimize potential profit, or wait for a specific level based on future price action. |
| 3. If the position is open (open_position=True), decide whether to exit the current trade at a specific price. |
| 4. If a trade is already executed and there is an open position, you can trail the stop-loss or adjust the target dynamically based on price action if it requires. |
| 5. You can hold the current open position or making no change to the trade. |
| 6. If no trade is advisable, set the status to "No trade". |
| |
| Analyze the news and technical indicators to output the following for BankNifty: Major Concern, Sentiment, Reasoning, Most Profitable Trade Strategy and News Summary, Provide a brief yet insightful summary for each based on the latest news and technical analysis. |
| Output major_concern, sentiment, reasoning, most profitable trade_strategy and news summary for BankNifty by analysing news and technicals in brief manner. |
| """.strip() |
|
|
| USER_INTRAHOUR_UPDATE_2=""" |
| Expert analysis and past news indicate that the major concern for BankNifty is: "{major_concern}". |
| The overall market sentiment is "{sentiment}", with the key news driving this sentiment being: {news_summary}. |
| The current strategy for trading BankNifty is "{strategy}", with the rationale being: "{reason}". |
| Analyse updated news of last one hour and update current trade plan if it requires. |
| Updated news of the past hour are: {news}. |
| By analyzing these, you can gauge the potential market direction and adjust your strategy to maximize profit. |
| |
| The OHLC data for the past hours are: {hourly_ohlc} |
| Current RSI and MACD technical indicators on the hourly timeframe are {bn_ind}. |
| Use these insights along with the latest news to predict the real-time market sentiment and make profitable trading decisions. |
| {hours_since_open} has passed since the market opened. |
| |
| Current trade: {trade} |
| trade_stastics: {position} |
| Past trade: {memory} |
| |
| Based on the provided analysis, your task is to make a trading decision with a brief explanation: |
| 1. If trade status is "No trade", you may initiate a new long or short position. Make sure that for any new short trade suggestion, the stoploss is higher than entry price, and for any new long trade suggestion, the stoploss is set lower than entry price. Also, Make sure that for any new short trade suggestion, the target is set lower than entry price, and for any new long trade suggestion, the target is set higher than entry price. |
| 2. If there is no open position (open_position=False), you may adjust the entry point to optimize potential profit, or wait for a specific level based on future price action. |
| 3. If the position is open (open_position=True), decide whether to exit the current trade at a specific price. |
| 4. If a trade is already executed and there is an open position, you can trail the stop-loss or adjust the target dynamically based on price action if it requires. |
| 5. You can hold the current open position or making no change to the trade. |
| 6. If no trade is advisable, set the status to "No trade". |
| |
| Analyze the news and technical indicators to output the following for BankNifty: Major Concern, Sentiment, Reasoning, Most Profitable Trade Strategy and News Summary, Provide a brief yet insightful summary for each based on the latest news and technical analysis. |
| Output major_concern, sentiment, reasoning, most profitable trade_strategy and news summary for BankNifty by analysing news and technicals in brief manner. |
| """ |
|
|
| USER_CLOSING = """ |
| Expert analysis and past news indicate that the major concern for BankNifty is: "{major_concern}". |
| The overall market sentiment is "{sentiment}", with the key news driving this sentiment being: {news_summary}. |
| The current strategy for trading BankNifty is "{strategy}", with the rationale being: "{reason}". |
| Analyse updated news of last one hour and update current trade plan if it requires. |
| Updated past 15 minutes news are: {news} |
| By analyzing these, you can gauge the potential market direction and adjust your strategy to maximize profit. |
| |
| The OHLC data for the past hours are: {hourly_ohlc} |
| Current RSI and MACD technical indicators on the hourly timeframe are {bn_ind}. |
| Current trade: {trade} |
| trade_stastics: {position} |
| Past trade: {memory} |
| As we are at closing of market, Analyze whether to carry forward the current open trade for tomorrow or close it at the market price. Provide a recommendation based on the latest market news and technical indicators. |
| |
| Based on the provided analysis, your task is to make a trading decision with a brief explanation: |
| 1. If there is no open position, do not take fresh new trade as we are at closing of market, set trade.status= No trade. |
| 2. If a position is still open (open_position=True), decide whether to exit at a current market price or carry it forward to the next session. |
| 3. If a trade is already executed and there is an open position, you can trail the stop-loss or adjust the target dynamically based on price action if it requires. |
| 4. If no trade is advisable, set the status to "No trade". |
| """.strip() |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
|
|
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| |
|
|
| |
|
|
| |
| |
|
|
| |
| |
|
|