"For GUIDANCE On Programmatic Trading WhatsApp Profit Adda Web @ +91-7795780804"

Generative AI Utilizing Google Generative AI API in Python

Decision Tree Learning Price Action Sentiment Analysis Utilizing Generative AI in Python:


For Instructions Follow the above Video then go For the Code Input:



import graphviz
from sklearn.tree import DecisionTreeClassifier, export_graphviz
from sklearn.feature_extraction.text import TfidfVectorizer
news = [
    "BTCUSD consolidates in the early morning, showing a slight positive drift from ~107,000 to ~107,500 with low volume.",
    "A strong bullish impulse propels BTCUSD higher in the late morning, breaking previous resistance levels and reaching ~109,500, confirmed by high buying volume.",
    "Mid-day period sees BTCUSD consolidating after the initial rally, ranging between ~109,000 and ~109,500, often indicative of an accumulation phase before a further move.",
    "Another powerful bullish surge pushes BTCUSD to new daily highs above 111,000 in the afternoon, accompanied by very high buying volume.",
    "Late trading hours witness profit-taking, causing BTCUSD to pull back from its daily peak towards ~110,000, indicating short-term bearish pressure."
]
labels = [
    1,  # Initial slight positive drift
    1,  # Strong bullish impulse with high volume
    1,  # Consolidation in an uptrend, typically a continuation pattern
    1,  # Second powerful bullish surge to new highs
    -1  # Profit-taking and short-term pullback
]
vec=TfidfVectorizer(max_features=10)
X=vec.fit_transform(news)
clf=DecisionTreeClassifier(max_depth=3,random_state=42).fit(X,labels)
dot=export_graphviz(clf,
                   out_file=None,
                   feature_names=vec.get_feature_names_out(),
                   class_names=['Negative','Positive'],
                   filled=True,rounded=True)
graphviz.Source(dot).render('sentiment_tree',format='png',cleanup=True)
from IPython.display import Image, display
display(Image('senti2.png'))

For Decision Tree Classifier Flow Chart Anlysis Checkout this Code:


import requests
import base64
api_key=open('genai_api_key.txt','r').read().strip()
chart=base64.b64encode(open('sentiment_tree.png','rb').read()).decode("utf-8")
url="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent"

print(requests.post(
	url,
	headers={'x-goog-api-key':api_key},
	json={'contents':[{
	'parts':[{'text':'Analyse this Flow Chart and Provide me the Details in Few Words and Let me Know Whether it is Positive or Negative'},
             {'inline_data':{'mime_type':'image/jpeg',
                             'data':chart
                 
             }}
             
            ]
	}]}
	).json()['candidates'][0]['content']['parts'][0]['text'])

Price Action Sentiment Analysis Utilizing Generative AI with Chartbot in Python:


For Instructions Follow the above Video then go For the Code Input:



import requests
import base64
api_key=open('genai_api_key.txt','r').read().strip()
chart=base64.b64encode(open('chart.png','rb').read()).decode("utf-8")
url="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent"
prompt = '''
You are a professional price action and news analyser.
Look carefully at the given candlestick with moving average and volume chart image.

Based on the visible trend, candle patterns, volume behavior and News,
generate high-quality sentiment such as 1: Positive, -1: Negative.

Output strictly in valid list format like this:

Each news should include:
financial_news = [
    "summarized news 1",
    "summarized news 2 and so on....",
]


sentiments = [1, -1 and so on...]  # 1: Positive, -1: Negative
'''
response=requests.post(
	url,
	headers={'x-goog-api-key':api_key},
	json={'contents':[{
	'parts':[{'text':prompt},
             {'inline_data':{'mime_type':'image/jpeg',
                             'data':chart
                 
             }}
             
            ]
	}]}
	).json()['candidates'][0]['content']['parts'][0]['text']
print(response)

Generative AI Utilizing Google Generative AI API in Python:


For Instructions Follow the above and below Video then go For the Code Input:



Follow this Shorts Video as well for Instructions to get your Google Generative AI API Key:



import requests
api_key=open('genai_api_key.txt','r').read().strip()
url="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent"

print(requests.post(
	url,
	headers={'x-goog-api-key':api_key},
	json={'contents':[{
	'parts':[{'text':'Explain AI in few words'}]
	}]}
	).json()['candidates'][0]['content']['parts'][0]['text'])

Price Action Analysis Utilizing Generative AI API and Chartbot in Python:


For Instructions Follow the above Video then go For the Code Input:



import requests
import base64
api_key=open('genai_api_key.txt','r').read().strip()
chart=base64.b64encode(open('18_10_25.png','rb').read()).decode("utf-8")
url="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent"

print(requests.post(
	url,
	headers={'x-goog-api-key':api_key},
	json={'contents':[{
	'parts':[{'text':'Analyse this Chart and Provide me the Details of Price Action it Consists'},
             {'inline_data':{'mime_type':'image/jpeg',
                             'data':chart
                 
             }}
             
            ]
	}]}
	).json()['candidates'][0]['content']['parts'][0]['text'])

Output of Price Action Analysis as a Generated Response in Text:


This chart displays the BTCUSD pair on a 15-minute candlestick timeframe, along with trading volume, covering approximately 22 hours from October 17th, 21:00 to October 18th, around 19:00. Here's a detailed analysis of the price action and volume: **Overall Trend & Volatility:** The chart shows a period of significant volatility followed by consolidation, an attempted rally, and then another pullback. The price initially surged, then underwent a sharp correction, followed by a long period of range-bound trading with relatively lower volume, before a moderate bullish push and subsequent rejection. **Key Price Action & Volume Details:** 1. **Oct 17, 21:00 - Oct 18, ~01:00 (Initial Volatility & Peak):** * **Price Action:** The period begins with a strong bullish impulse. BTCUSD quickly rises from approximately **106000** to its peak around **107300 - 107350**. This rapid ascent is characterized by multiple large green candlesticks with some upper wicks, indicating initial strong buying pressure. * After reaching the peak, there's an immediate and sharp reversal. Large red candlesticks dominate, pushing the price back down quickly towards **106200**. There's a slight bounce from this level, but another attempt to reach the prior high is rejected around **107250**, confirming significant resistance. The price then falls further, establishing a temporary bottom around **106200**. * **Volume:** This entire initial phase sees the highest trading volume on the chart. Both the strong bullish push and the subsequent sharp bearish correction are accompanied by very large volume bars (both green and red), indicating high market participation and conviction in these movements. The peak volume occurs during the initial ascent and the subsequent sharp drop, suggesting strong contention between buyers and sellers. 2. **Oct 18, ~01:00 - Oct 18, ~12:00 (Consolidation & Lower Volume):** * **Price Action:** Following the initial volatility, the market enters a prolonged period of consolidation. The price largely trades in a range between **106200** (acting as support) and **107000** (acting as resistance), with some attempts to break higher failing around **106750 - 107000**. * The candlesticks become smaller and choppier, indicative of indecision. There are minor fluctuations up and down within this range, but no clear sustained direction. Several minor rallies are quickly met with selling pressure, and minor dips find buying support. * **Volume:** Volume significantly drops during this phase compared to the initial hours. The volume bars are generally small, reflecting a lack of strong conviction from either buyers or sellers. This is typical for a consolidation phase where market participants are waiting for a clearer direction. 3. **Oct 18, ~12:00 - Oct 18, ~16:00 (Afternoon Rally Attempt):** * **Price Action:** Around 12:00, the price finds strong support again at the **106200 - 106250** level. A new bullish impulse begins, pushing the price upward. It climbs steadily, forming several green candlesticks, reaching approximately **107000 - 107100**. This attempt looks more concerted than the earlier bounces within the consolidation range. * However, the rally again meets resistance at or just below the previous high/resistance zone of **107200 - 107300**. Price fails to break decisively above **107100**. * **Volume:** This rally is accompanied by a noticeable increase in volume, especially during the initial green candles from 12:00 to 13:00. This suggests renewed buying interest and confirms the strength behind this specific upward move. However, as the price approaches the resistance level, volume slightly decreases or becomes mixed, hinting at exhaustion or strong selling pressure entering the market. 4. **Oct 18, ~16:00 - End of Chart (~19:00):** * **Price Action:** After failing to break through the **107000 - 107100** resistance, the price experiences another sharp rejection. Several large red candlesticks quickly push the price back down to around **106750**. * In the final hours shown, the price attempts to stabilize around **106750**, forming smaller green and red candles, but the immediate trend is bearish following the rejection from the afternoon high. * **Volume:** The rejection from the 107000-107100 area is accompanied by a spike in red volume bars, indicating renewed selling pressure. Subsequent volume remains moderate as the price tries to find a new equilibrium. **Key Levels Identified:** * **Resistance:** * **107200 - 107350:** A very strong resistance zone, acting as a ceiling for price rallies. * **107000 - 107100:** A significant psychological and technical resistance level, repeatedly tested and rejected. * **Support:** * **106200 - 106250:** A clear support level, where the price has bounced multiple times after significant drops. * **106750:** An immediate, minor support level formed towards the end of the chart after the latest pullback. In summary, the chart depicts a volatile 22-hour period for BTCUSD, starting with a high-volume surge and crash, followed by a long period of low-volume consolidation within a relatively tight range. A subsequent rally attempt on increasing volume was ultimately rejected by established resistance, leading to another pullback. The market appears to be struggling to break above the **107000-107300** resistance zone.

Deep Learning for Stock Price Prediction

Deep Learning for Stock Close Price Prediction based on Open Price:


For Instructions Follow the above Video then go For the Code Input:



import os
os.environ['TF_CPP_MIN_LOG']='2'
import requests 
import pandas as pd  
from datetime import datetime, timedelta 
import matplotlib.pyplot as plt 
#import tensorflow
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense

#get btcusd data from delta exchnage india
base_url="https://api.india.delta.exchange"
url=f"{base_url}/v2/history/candles"
end=int(datetime.now().timestamp())
start=int((datetime.now()-timedelta(days=1)).timestamp())
params={
    'symbol':'BTCUSD',
    'resolution':'15m',
    'start':start,
    'end':end
}
r=requests.get(url,params=params)
data=r.json().get('result',[])
df=pd.DataFrame(data,columns=['time','open','high','low','close','volume']).sort_values('time')
df['time']=pd.to_datetime(df['time'],unit='s')
df['time']=df['time'].dt.tz_localize('UTC').dt.tz_convert('Asia/Kolkata')
df.set_index('time',inplace=True)
#feature and target
X=df[['open']]
y=df['close']
#model
model=Sequential([Dense(64,activation='relu'),
    Dense(32,activation='relu'),
    Dense(1)
    ])
model.compile(optimizer='adam',loss='mse',metrics=['mae'])

model.fit(X,y,epochs=50)

#predict
predict=model.predict(X)

#plot
plt.plot(df.index,y,label='actual')
plt.plot(df.index,predict,label='predicted',linestyle='--')
plt.show()