ryanrahmadifa commited on
Commit
9321404
·
1 Parent(s): 4f642eb
app.py CHANGED
@@ -1,4 +1,33 @@
1
  import streamlit as st
 
 
 
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import pandas as pd
3
+ from modules.data_preparation import prepare_df, plot_3dgraph
4
+ import numpy as np
5
+ import datetime
6
 
7
+ st.title('Sentiment Analysis for Price Trend Prediction')
8
+
9
+ st.header(f'Data based on Platts News and Insights Data')
10
+ st.subheader(f'{datetime.datetime.now()}')
11
+
12
+ news_category = st.selectbox("Select Market Movers Category", ("Crude Oil", "Light Ends", "Middle Distillates", "Heavy Distillates"))
13
+
14
+ latest_news = prepare_df(pd.read_csv('data/results_platts_09082024_clean.csv'), news_category)
15
+ top_news = prepare_df(pd.read_csv('data/topresults_platts_09082024_clean.csv'), news_category)
16
+
17
+ df_news = pd.concat([latest_news, top_news], ignore_index=True).drop_duplicates(['headline'])
18
+
19
+ df_mean = pd.DataFrame({
20
+ 'headline' : ['MEAN OF ALL NEWS'],
21
+ 'negative_score' : [df_news['negative_score'].mean()],
22
+ 'neutral_score' : [df_news['neutral_score'].mean()],
23
+ 'positive_score' : [df_news['positive_score'].mean()],
24
+ 'topic_verification' : ['']
25
+ })
26
+
27
+ df_news_final = pd.concat([df_news, df_mean]).drop(columns=['body'])
28
+
29
+ df_news_final.index = np.arange(1, len(df_news_final) + 1)
30
+
31
+ df_news_final
32
+
33
+ st.plotly_chart(plot_3dgraph(df_news_final), use_container_width=True)
data/results_platts_09082024_clean.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/topresults_platts_09082024_clean.csv ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,body,headline,updatedDate,topic_prediction,topic_verification,negative_score,neutral_score,positive_score,trend_prediction,trend_verification
2
+ 0," OPEC+ crude production in July made its biggest jump in almost a year, as Iraq and Kazakhstan raised their output despite committing to deeper cuts, while Russia also remained well over its quota. The group's overall production was up 160,000 b/d compared with June, totaling 41.03 million b/d, the Platts OPEC+ survey from S&P Global Commodity Insights showed Aug. 8. Member countries with quotas produced 437,000 b/d above target in July, up from 229,000 b/d in June. July was the first month of compensation plans introduced by three countries that overproduced in the first half of 2024. Iraq pledged to cut an additional 70,000 b/d in July and Kazakhstan pledged to cut a further 18,000 b/d. Russia's compensation plan does not include additional cuts until October 2024. The survey found that Iraq produced 4.33 million b/d in July, 400,000 b/d above its quota. This contributed to growth in OPEC production of 130,000 b/d to 26.89 million b/d. Non-OPEC producers added a further 14.14 million b/d, up 30,000 b/d month on month. This was driven by Kazakhstan, which increased output by 30,000 b/d. It is now producing 120,000 b/d above quota, taking into account its compensation cut. Russia is also producing above quota, with output at 9.10 million b/d in July, against a quota of 8.98 million b/d. The overproducers are part of a group that is implementing a combined 2.2 million b/d of voluntary cuts, currently in place until the end of the third quarter. The group then plans to gradually bring some of those barrels back to market from September if conditions allow. A further 3.6 million b/d of group-wide cuts are in place until the end of 2025. The rise in output in July came despite the poor performance of the alliance's African contingent, with production in Nigeria, South Sudan, Gabon and Libya falling by a collective 80,000 b/d. Pressure on overproducers has increased in recent weeks, as recession fears have driven oil prices below $80/b. Platts, part of Commodity Insights, assessed Dated Brent at $79.91/b Aug. 7. A long-awaited rise in Chinese demand and high production from non-OPEC countries in the Americas -- including the US, Canada, Brazil and Guyana -- have also weakened prices in recent months. OPEC+ has pledged to stick to its strategy of major production cuts through the third quarter, before gradually bringing barrels back to market. Overproduction and depressed oil prices threaten these plans. The next meeting of the Joint Ministerial Monitoring Committee overseeing the agreement, which is co-chaired by Saudi Arabia and Russia, is scheduled for Oct. 2. A full ministerial meeting is scheduled for Dec. 1. The Platts survey measures wellhead production and is compiled using information from oil industry officials, traders and analysts, as well as by reviewing proprietary shipping, satellite and inventory data. OPEC+ crude production (million b/d) OPEC-9 July-24 Change June-24 Quota Over/under Algeria 0.90 0.00 0.90 0.908 -0.008 Congo-Brazzaville 0.26 0.00 0.26 0.277 -0.017 Equatorial Guinea 0.05 0.00 0.05 0.070 -0.020 Gabon 0.21 -0.01 0.22 0.169 0.041 Iraq*† 4.33 0.11 4.22 3.930 0.400 Kuwait 2.42 0.00 2.42 2.413 0.007 Nigeria 1.46 -0.04 1.50 1.500 -0.040 Saudi Arabia 8.99 0.01 8.98 8.978 0.012 UAE 2.99 0.02 2.97 2.912 0.078 TOTAL OPEC-9 21.61 0.09 21.52 21.157 0.453 OPEC EXEMPT Change Quota Over/under Iran 3.20 0.00 3.20 N/A N/A Libya 1.15 -0.01 1.16 N/A N/A Venezuela 0.93 0.05 0.88 N/A N/A TOTAL OPEC-12 26.89 0.13 26.76 N/A N/A NON-OPEC WITH QUOTAS Change Quota Over/under Azerbaijan 0.49 0.01 0.48 0.551 -0.061 Bahrain 0.18 0.00 0.18 0.196 -0.016 Brunei 0.07 0.01 0.06 0.083 -0.013 Kazakhstan† 1.57 0.03 1.54 1.450 0.120 Malaysia 0.35 0.00 0.35 0.401 -0.051 Oman 0.76 0.00 0.76 0.759 0.001 Russia 9.10 0.00 9.10 8.978 0.122 Sudan 0.03 0.00 0.03 0.064 -0.034 South Sudan 0.04 -0.02 0.06 0.124 -0.084 TOTAL NON-OPEC WITH QUOTAS 12.59 0.03 12.56 12.606 -0.016 NON-OPEC EXEMPT Change Quota Over/under Mexico 1.55 0 1.55 N/A N/A TOTAL NON-OPEC 14.14 0.03 14.11 N/A N/A OPEC+ MEMBERS WITH QUOTAS Change Quota Over/under TOTAL 34.20 0.12 34.08 33.76 0.437 OPEC+ Change Quota Over/under TOTAL 41.03 0.16 40.87 N/A N/A * Includes estimated 250,000 b/d production in the semi-autonomous Kurdistan region of Iraq † Iraq and Kazakhstan quotas reduced in line with compensation plans Source: Platts OPEC+ survey by S&P Global Commodity Insights ","OPEC+ produces 437,000 b/d above quota in first month of compensation cuts",2024-08-08 17:36:29+00:00,Macroeconomic & Geopolitics,Macroeconomic & Geopolitics,0.9936981650538123,0.03949102865047352,0.07103689164109918,Bearish,Bearish
3
+ 1,nan,"Non-OPEC July output up 30,000 b/d at 14.14 mil b/d: Platts survey",2024-08-08 14:00:12+00:00,Macroeconomic & Geopolitics,Macroeconomic & Geopolitics,0.9932350855162315,0.024123551368425825,0.12366691833078211,Bearish,Bearish
4
+ 2,nan,"OPEC+ producers with quotas 437,000 b/d above target in July: Platts survey",2024-08-08 14:00:11+00:00,Macroeconomic & Geopolitics,Macroeconomic & Geopolitics,0.9936222216140704,0.048969414364614584,0.06152339592702592,Bearish,Bearish
5
+ 3,nan,"OPEC crude output up 130,000 b/d at 26.89 mil b/d in July: Platts survey",2024-08-08 14:00:11+00:00,Macroeconomic & Geopolitics,Macroeconomic & Geopolitics,0.9933905710185933,0.03299545514176609,0.10238077772498969,Bearish,Bearish
6
+ 4,nan,"OPEC+ July crude output up 160,000 b/d at 41.03 mil b/d: Platts survey",2024-08-08 14:00:10+00:00,Macroeconomic & Geopolitics,Macroeconomic & Geopolitics,0.9870346671527929,0.02437343317152671,0.2153639976093806,Bearish,Bearish
7
+ 5,nan,"Iraq, Russia, Kazakhstan overproduce in first month of compensation cuts: Platts survey",2024-08-08 14:00:10+00:00,Crude Oil,Crude Oil,0.6294152478714086,0.06749551758023337,0.927845667131505,Bullish,Bullish
8
+ 6," UK-based upstream producer Harbour Energy plans to start its new Talbot oil and gas tie-in project at the J-Area hub in the North Sea by the end of 2024, boosting Ekofisk blend volumes, it said Aug. 8. Harbour, in a statement, reported a 19% year-on-year drop in its UK oil and gas production in the first half of 2024 to 149,000 b/d of oil equivalent. It noted a significant maintenance impact, including a planned shutdown in June at the J-Area, which sends oil and gas to Teesside, with the liquids loaded as Ekofisk blend. Ekofisk is a component in the Platts Dated Brent price assessment process. Talbot, a multiwell development, is expected to recover 18 million boe of light oil and gas over 16 years. It will add to oil volumes flowing through the J-Area into the Norpipe route to Teesside, contributing to the predominantly Norwegian Ekofisk blend. Harbour also flagged an ongoing maintenance impact on production through much of the Q3 2024, including a 40-day shutdown at the Britannia hub starting in August, which will impact flows into the Forties blend. The maintenance was expected to start in the next few days and be completed in September, according to a source close to the situation. Britannia was also expected to be impacted by a four-week shutdown of the SAGE gas pipeline starting Aug. 27 . Harbour has made ""good progress to date on the maintenance shutdowns and our UK capital projects, which are on track to materially increase production in the fourth quarter,"" it said. The North Sea typically sees a drop in production volumes in the summer due to maintenance. Non-UK diversification Harbour reiterated its efforts to diversify away from the UK, with an acquisition of Wintershall Dea assets underway, having strongly objected to punitive tax rates. It said its overall effective tax rate in the first half of 2024 was 85%, partly reflecting not-fully deductible costs under the UK tax regime. Harbour reported 10,000 boe/d of additional production outside the UK in the first half of the year, in Indonesia and Vietnam. It noted progress in Mexico, where Front End Engineering and Design has begun for the Zama oil project, estimated at 700 million barrels of light crude. Harbour is set to increase its Zama stake from 12% to 32% following the Wintershall acquisition. In the first half of 2024 ""we made significant progress towards completing the Wintershall Dea acquisition, which is now expected early in the fourth quarter,"" CEO Linda Cook said. ""The acquisition will transform the scale, geographical diversity and longevity of our portfolio and strengthen our capital structure, enabling us to deliver enhanced shareholder returns over the long run while also positioning us for further opportunities.” Platts Dated Brent was assessed at $79.91/b on Aug. 8, up $3.64 on the day. Platts is part of S&P Global Commodity Insights. ",UK's Harbour Energy says on track with North Sea Talbot oil tie-in,2024-08-08 13:54:45+00:00,Crude Oil,Crude Oil,0.31882130542268583,0.04218598724364094,0.9882147680155492,Bullish,Bullish
9
+ 7," The INPEX-operated Ichthys LNG project in Australia has recovered to an 85% overall production rate after Train 2 restarted on July 28 following an outage on July 20 that was caused by a glitch, an INPEX spokesperson told S&P Global Commodity Insights Aug. 8. Currently, the onshore Ichthys LNG plant is running at 100% at Train 1, and about 70% at Train 2, putting the overall production rate at about 85%, the spokesperson said. The Ichthys LNG project is slated to resume full runs in October, when it plans to carry out some scheduled maintenance work lasting around a week, the spokesperson said. INPEX has estimated that fewer than five LNG cargoes of Ichthys LNG shipments will be affected as a result of the glitch, the spokesperson said. However, the INPEX spokesperson declined to elaborate on actual production volumes at the Ichthys LNG plant, which has yet to reach its operational capacity of 9.3 million mt/year. INPEX has been building a framework for a stable supply of 9.3 million mt/year of LNG at its operated Ichthys project by debottlenecking the facility, upgrading the cooling systems for liquefication and taking measures to address vibration issues. As of July, the Ichthys project has shipped a total of 76 LNG cargoes this year, with July shipments having slipped to 10 cargoes from 11 cargoes in June. Ichthys LNG shipments will slow to 10 cargoes per month in the second half of 2024, the spokesperson said, compared with an average of 11 cargoes per month in the first half of the year. In the first seven months of the year the Ichthys project shipped 14 plant condensate cargoes, 18 field condensate cargoes and 20 LPG cargoes. In the January-June period INPEX produced 662,000 b/d of oil equivalent, and it now expects its 2024 production to be 644,800 boe/d, down from its May outlook of 645,300 boe/d for the year as a result of the Ichthys LNG production issues, the spokesperson said. The project, operated by INPEX with 67.82%, involves piping gas from the offshore Ichthys field in the Browse Basin in Northwestern Australia more than 890 km (552 miles) to the onshore LNG plant near Darwin, which has an 8.9 million mt/year nameplate capacity. At peak, it has the capacity to produce 1.65 million mt/year of LPG and 100,000 b/d of condensate. ",Australia's Ichthys LNG recovers 85% output after Train 2 outage; to recover full runs in Oct,2024-08-08 11:53:44+00:00,Other,Other,0.770051212604236,0.010564989240227092,0.9773946433377442,Bullish,Bullish
10
+ 8," NTPC Limited, India’s largest power generation utility, has partnered with LanzaTech to implement carbon recycling technology at its new facility in central India, in a significant move towards sustainable energy. The project will convert CO2 emissions and green hydrogen into ethanol using LanzaTech's second-generation bioreactor, the US-based company said in a statement Aug. 7. NTPC's upcoming plant will be the first in India to deploy this advanced technology, which captures carbon-rich gases before they enter the atmosphere. The LanzaTech bioreactor uses proprietary microbes to transform these gases into sustainable fuels, chemicals, and raw materials. The microbes convert CO2 and H2 into ethanol, a critical component for producing green energy products such as sustainable aviation fuels (SAF) and renewable diesel. This in turn boosts NTPC's goals by producing ethanol from waste-based feedstocks, promoting a circular carbon economy. According to the statement, the project was conceptualized and designed in collaboration with NTPC's research and development arm, NETRA (NTPC Energy Technology Research Alliance). The facility aims to demonstrate the commercial viability of LanzaTech’s technology in producing ethanol from waste-based feedstocks by leveraging CO2 as sole carbon source. Jakson Green, a new energy firm, is responsible for development of this Chhattisgarh-based facility, handling from design and engineering to procurement and construction. This first-of-its-kind plant is projected to abate 7,300 mt/year of CO2 annually, equivalent to the carbon sequestered by 8,523 acres of forest land. The carbon and hydrogen to renewable ethanol facility is slated to begin operations within two years. Dr. Jennifer Holmgren, CEO of LanzaTech, emphasized the strategic importance of this partnership, stating, “Our collaboration with NTPC and Jakson Green sets a roadmap for the commercial deployment of CO2 as a key feedstock.” Jakson Green is already developing India’s largest green hydrogen fueling station and a low-carbon methanol plant for leading government companies. LanzaTech technology is also being used at various other operations in India, producing ethanol at Indian Oil Corporation’s Panipat facility which will also be used for SAF. The company has also partnered with GAIL and Mangalore Refinery and Petrochemicals Limited on similar projects. Platts, part of Commodity Insights, assessed SAF production costs (palm fatty acid distillate) in Southeast Asia at $1,589.91/mt Aug. 7, down $19.50/mt from the previous assessment. ",NTPC advances clean energy goals with LanzaTech CO2-to-ethanol technology,2024-08-08 11:30:49+00:00,Light Ends,Light Ends,0.21314498348994937,0.11135607578700647,0.9908829648109232,Bullish,Bullish
11
+ 9," UAE-based Dana Gas said it expects to resume drilling activities in Egypt after the country’s parliament ratified a law to consolidate its concessions to operate in the country under a new concession with Egyptian Natural Gas Holding Co. The new agreement ratified by the Egyptian parliament was already approved by the Egyptian Cabinet in March, authorizing the country’s minister of oil and Egyptian Natural Gas to finalize a new concession agreement with Dana Gas, the company said in an Aug. 8 statement. Since 2001, Dana Gas has been in discussions with Egyptian Natural Gas to consolidate three of its four concessions into a new concession with improved terms, according to Dana Gas’s website. “The revised terms should enable meaningful future investments alongside a resumption of drilling activities, positively impacting the company’s production levels in Egypt and helping the country meet its growing gas demand,” Dana Gas said in the statement. Egypt has halted LNG exports during the summer months and has turned to LNG imports instead to meet high seasonal demand amid declining domestic production. The development comes as delivered spot LNG prices to the East Mediterranean continue to trade above $10/MMBtu. Platts, part of S&P Global Commodity Insights, assessed the DES LNG East Mediterranean marker at $12.47/MMBtu Aug. 7, the highest since the assessment started in December 2023. The company’s first-half 2024 production in Egypt was 59,800 boe/d, down 25% from the same period a year earlier, mostly due to natural field declines, according to the statement. Dana Gas did not state when it expects to bring new production streams online in the country. Dana Gas's production in the Kurdish region of northern Iraq increased 3% over the same period to 37,600 boe/d due to increased demand for gas from local power plants, the company said. ",Dana Gas expects to resume drilling activities in Egypt after new concession,2024-08-08 11:23:48+00:00,Other,Other,0.023988005652641385,0.7891432360374782,0.9608502193290972,Bullish,Bullish
12
+ 10,nan,"Indonesia sets Minas crude price at $84.95/b for July, rising $3.35/b from June",2024-08-08 01:41:13+00:00,Middle Distillates,Middle Distillates,0.9926734319450401,0.04286090006550804,0.07892061673161296,Bearish,Bearish
modules/__init__.py ADDED
File without changes
modules/__pycache__/__init__.cpython-39.pyc ADDED
Binary file (213 Bytes). View file
 
modules/__pycache__/data_preparation.cpython-39.pyc ADDED
Binary file (1.77 kB). View file
 
modules/data_preparation.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ import datetime
3
+ import plotly.express as px
4
+ import datetime
5
+
6
+ def clean_text(text):
7
+ new_text = text
8
+ for rgx_match in ['[A-Z ]+:']:
9
+ new_text = re.sub(rgx_match, '', new_text)
10
+ return new_text
11
+
12
+ def prepare_df(df, category):
13
+ try:
14
+ df.drop(columns=['Unnamed: 0'], inplace=True)
15
+ except:
16
+ pass
17
+
18
+ if category == 'Crude Oil':
19
+ news_data = df[(df['topic_verification'] == 'Crude Oil') | (df['topic_verification'] == 'Macroeconomic & Geopolitics')]
20
+ if category == 'Light Ends':
21
+ news_data = df[(df['topic_verification'] == 'Light Ends')]
22
+ if category == 'Middle Distillates':
23
+ news_data = df[(df['topic_verification'] == 'Middle Distillates')]
24
+ if category == 'Heavy Distillates':
25
+ news_data = df[(df['topic_verification'] == 'Heavy Distillates')]
26
+
27
+ actual_day = datetime.date.today() - datetime.timedelta(days=1)
28
+ pattern_del = actual_day.strftime('%b').upper()
29
+
30
+ filter = news_data['headline'].str.contains(pattern_del)
31
+ news_data = news_data[~filter]
32
+
33
+ return news_data
34
+
35
+ def plot_3dgraph(news_data):
36
+ fig = px.scatter_3d(news_data,
37
+ x='neutral_score',
38
+ y='negative_score',
39
+ z='positive_score',
40
+ color='positive_score',
41
+ hover_name ='headline',
42
+ color_continuous_scale='RdBu',
43
+ size_max=40,
44
+ size='negative_score',
45
+ text='headline',
46
+ hover_data='topic_verification')
47
+
48
+ fig.update_layout(
49
+ height=800,
50
+ title=dict(text=f"Platts News Sentiments ({datetime.datetime.now().strftime('%d/%m/%y')})<br><sup>Hover cursor on a datapoint to show news title</sup>", font=dict(size=35), automargin=False)
51
+ )
52
+
53
+ fig.update_traces(textfont_size=8)
54
+
55
+ return fig