Commit ae655aa7 authored by malinga-1234's avatar malinga-1234

Added company financial files

parent 5cba3c26
y,net_profit_margin,earnings_per_share
2014-3,8.1,0.04
2014-4,7.5,0.01
2014-5,7.09,0.02
2014-6,6.7,0.02
2014-7,12.1,0.05
2014-8,10.6,0.03
2014-9,12.3,0.08
2014-10,12.78,0.01
2014-11,10.2,0.03
2014-12,11.32,0.04
2015-1,11.11,0.02
2015-2,9.56,0.01
2015-3,10.98,0.04
2015-4,10.9,0.03
2015-5,11.34,0.02
2015-6,12.99,0.06
2015-7,12.4,0.01
2015-8,12.4,0.15
2015-9,11.63,0.27
2015-10,13.8,0.23
2015-11,13.9,0.22
2015-12,12.27,0.21
2016-1,11.7,0.23
2016-2,16.8,0.25
2016-3,12.66,0.26
2016-4,15.9,0.21
2016-5,15.9,0.17
2016-6,12.4,0.27
2016-7,8.8,0.23
2016-8,11,0.34
2016-9,11.63,0.27
2016-10,12.6,0.28
2016-11,12.8,0.32
2016-12,12.44,0.38
2017-1,16.6,0.33
2017-2,11.78,0.21
2017-3,13.05,0.4
2017-4,11.9,0.3
2017-5,12.65,0.28
2017-6,9.5,0.27
2017-7,8.9,0.23
2017-8,7.8,0.21
2017-9,7.82,0.19
2017-10,5.8,0.17
2017-11,6.9,0.21
2017-12,7.43,0.22
2018-1,6.9,0.27
2018-2,6.5,0.32
2018-3,8.73,0.27
2018-4,7.9,0.22
2018-5,3.8,0.32
2018-6,2.3,0.08
2018-7,6.8,0.28
2018-8,6.3,0.67
2018-9,3.26,0.85
2018-10,1.9,0.32
2018-11,2.4,0.21
2018-12,2.51,0.07
2019-1,5.9,0.32
2019-2,2.5,0.32
2019-3,3.51,0.69
2019-4,5.8,0.32
2019-5,3.8,0.56
2019-6,3.13,0.85
2019-7,3.9,0.32
2019-8,7.9,0.21
2019-9,2.74,0.1
2019-10,6.8,0.32
2019-11,3.8,0.21
2019-12,3.59,1.02
y,ds
2022-03,0.04
2022-04,0.01
2022-05,0.02
2022-06,0.02
2022-07,0.05
2022-08,0.03
2022-09,0.08
2022-10,0.01
2022-11,0.03
2022-12,0.04
2022-01,0.02
2022-02,0.01
2022-03,0.04
2022-04,0.03
2022-05,0.02
2022-06,0.06
2022-07,0.01
2022-08,0.15
2022-09,0.27
2022-10,0.23
2022-11,0.22
2022-12,0.21
2022-01,0.23
2022-02,0.25
2022-03,0.26
2022-04,0.21
2022-05,0.17
2022-06,0.27
2022-07,0.23
2022-08,0.34
2022-09,0.27
2022-10,0.28
2022-11,0.32
2022-12,0.38
2022-01,0.33
2022-02,0.21
2022-03,0.4
2022-04,0.3
2022-05,0.28
2022-06,0.27
2022-07,0.23
2022-08,0.21
2022-09,0.19
2022-10,0.17
2022-11,0.21
2022-12,0.22
2022-01,0.27
2022-02,0.32
2022-03,0.27
2022-04,0.22
2022-05,0.32
2022-06,0.08
2022-07,0.28
2022-08,0.67
2022-09,0.85
2022-10,0.32
2022-11,0.21
2022-12,0.07
2022-01,0.32
2022-02,0.32
2022-03,0.69
2022-04,0.32
2022-05,0.56
2022-06,0.85
2022-07,0.32
2022-08,0.21
2022-09,0.1
2022-10,0.32
2022-11,0.21
2022-12,1.02
\ No newline at end of file
y,ds
2022-03,8.1
2022-04,7.5
2022-05,7.09
2022-06,6.7
2022-07,12.1
2022-08,10.6
2022-09,12.3
2022-10,12.78
2022-11,10.2
2022-12,11.32
2022-01,11.11
2022-02,9.56
2022-03,10.98
2022-04,10.9
2022-05,11.34
2022-06,12.99
2022-07,12.4
2022-08,12.4
2022-09,11.63
2022-10,13.8
2022-11,13.9
2022-12,12.27
2022-01,11.7
2022-02,16.8
2022-03,12.66
2022-04,15.9
2022-05,15.9
2022-06,12.4
2022-07,8.8
2022-08,11
2022-09,11.63
2022-10,12.6
2022-11,12.8
2022-12,12.44
2022-01,16.6
2022-02,11.78
2022-03,13.05
2022-04,11.9
2022-05,12.65
2022-06,9.5
2022-07,8.9
2022-08,7.8
2022-09,7.82
2022-10,5.8
2022-11,6.9
2022-12,7.43
2022-01,6.9
2022-02,6.5
2022-03,8.73
2022-04,7.9
2022-05,3.8
2022-06,2.3
2022-07,6.8
2022-08,6.3
2022-09,3.26
2022-10,1.9
2022-11,2.4
2022-12,2.51
2022-01,5.9
2022-02,2.5
2022-03,3.51
2022-04,5.8
2022-05,3.8
2022-06,3.13
2022-07,3.9
2022-08,7.9
2022-09,2.74
2022-10,6.8
2022-11,3.8
2022-12,3.59
\ No newline at end of file
y,ds
2014-03,8.1
2014-04,7.5
2014-05,7.09
2014-06,6.7
2014-07,12.1
2014-08,10.6
2014-09,12.3
2014-10,12.78
2014-11,10.2
2014-12,11.32
2015-01,11.11
2015-02,9.56
2015-03,10.98
2015-04,10.9
2015-05,11.34
2015-06,12.99
2015-07,12.4
2015-08,12.4
2015-09,11.63
2015-10,13.8
2015-11,13.9
2015-12,12.27
2016-01,11.7
2016-02,16.8
2016-03,12.66
2016-04,15.9
2016-05,15.9
2016-06,12.4
2016-07,8.8
2016-08,11
2016-09,11.63
2016-10,12.6
2016-11,12.8
2016-12,12.44
2017-01,16.6
2017-02,11.78
2017-03,13.05
2017-04,11.9
2017-05,12.65
2017-06,9.5
2017-07,8.9
2017-08,7.8
2017-09,7.82
2017-10,5.8
2017-11,6.9
2017-12,7.43
2018-01,6.9
2018-02,6.5
2018-03,8.73
2018-04,7.9
2018-05,3.8
2018-06,2.3
2018-07,6.8
2018-08,6.3
2018-09,3.26
2018-10,1.9
2018-11,2.4
2018-12,2.51
2019-01,5.9
2019-02,2.5
2019-03,3.51
2019-04,5.8
2019-05,3.8
2019-06,3.13
2019-07,3.9
2019-08,7.9
2019-09,2.74
2019-10,6.8
2019-11,3.8
2019-12,3.59
\ No newline at end of file
y,ds
2014-03,0.04
2014-04,0.01
2014-05,0.02
2014-06,0.02
2014-07,0.05
2014-08,0.03
2014-09,0.08
2014-10,0.01
2014-11,0.03
2014-12,0.04
2015-01,0.02
2015-02,0.01
2015-03,0.04
2015-04,0.03
2015-05,0.02
2015-06,0.06
2015-07,0.01
2015-08,0.15
2015-09,0.27
2015-10,0.23
2015-11,0.22
2015-12,0.21
2016-01,0.23
2016-02,0.25
2016-03,0.26
2016-04,0.21
2016-05,0.17
2016-06,0.27
2016-07,0.23
2016-08,0.34
2016-09,0.27
2016-10,0.28
2016-11,0.32
2016-12,0.38
2017-01,0.33
2017-02,0.21
2017-03,0.4
2017-04,0.3
2017-05,0.28
2017-06,0.27
2017-07,0.23
2017-08,0.21
2017-09,0.19
2017-10,0.17
2017-11,0.21
2017-12,0.22
2018-01,0.27
2018-02,0.32
2018-03,0.27
2018-04,0.22
2018-05,0.32
2018-06,0.08
2018-07,0.28
2018-08,0.67
2018-09,0.85
2018-10,0.32
2018-11,0.21
2018-12,0.07
2019-01,0.32
2019-02,0.32
2019-03,0.69
2019-04,0.32
2019-05,0.56
2019-06,0.85
2019-07,0.32
2019-08,0.21
2019-09,0.1
2019-10,0.32
2019-11,0.21
2019-12,1.02
\ No newline at end of file
Date,sale
2010/01,20072.25
2010/02,20028.17
2010/03,19940.75
2010/04,20423.67
2010/05,20614.95
2010/06,20680.46
2010/07,20626.36
2010/08,20966.6
2010/09,20934.96
2010/10,21024.8
2010/11,21100.66
2010/12,21758.33
2011/01,21960.22
2011/02,22312.68
2011/03,22422.24
2011/04,22648.72
2011/05,22542.46
2011/06,20453.25
2011/07,31627.11
2011/08,30990.09
2011/09,31081.46
2011/10,31003.29
2011/11,30309.06
2011/12,29650.9
2012/01,29652.25
2012/02,29813.93
2012/03,29813.1
2012/04,29540.8
2012/05,30115.35
2012/06,30360.91
2012/07,30509.01
2012/08,30328.47
2012/09,31217.82
2012/10,30993.57
2012/11,31248.31
2012/12,31615.46
2013/01,31800.11
2013/02,31904.33
2013/03,31287.97
2013/04,31052.27
2013/05,31110.19
2013/06,31283.66
2013/07,31235.26
2013/08,31072.96
2013/09,31028.74
2013/10,31181.2
2013/11,31378.3
2013/12,31648.27
2014/01,31742.73
2014/02,31627.6
2014/03,32172.94
2014/04,32445.19
2014/05,32603.18
2014/06,20934.96
2014/07,21024.8
2014/08,21100.66
2014/09,21758.33
2014/10,21960.22
2014/11,22312.68
2014/12,22422.24
2015/01,22648.72
2015/02,22542.46
2015/03,22467.98
2015/04,22491.88
2015/05,22708.61
2015/06,22739.87
2015/07,22639.13
2015/08,22492.34
2015/09,23185.03
2015/10,23469.52
2015/11,23393.79
2015/12,23484.62
2016/01,22946.38
2016/02,22766.33
2016/03,22835.84
2016/04,22678.19
2016/05,22372.94
2016/06,22267.98
2016/07,22202.92
2016/08,22105.9
2016/09,22120.13
2016/10,22876.81
2016/11,22962.78
2016/12,22642.51
2017/01,22571.13
2017/02,23314.42
2017/03,23099.41
2017/04,23099.41
2017/05,23099.41
2017/06,23099.41
2017/07,23099.41
2017/08,23099.41
2017/09,23099.41
2017/10,23099.41
2017/11,23099.41
2017/12,23099.41
2018/01,23099.41
2018/02,23099.41
2018/03,23099.41
2018/04,23099.41
2018/05,23099.41
2018/06,23099.41
2018/07,23099.41
2018/08,28906.71
2018/09,28911.01
2018/10,29007.18
2018/11,29120.43
2018/12,29454.96
2019/01,29437.66
2019/02,29817.42
2019/03,29907.67
2019/04,30108.33
2019/05,30094.87
2019/06,30052.94
2019/07,30105.56
2019/08,30018.56
2019/09,30241.17
2019/10,31719.12
2019/11,31603.26
2019/12,31627.11
2020/01,30990.09
2020/02,31081.46
2020/03,31235.26
2020/04,31072.96
2020/05,31028.74
2020/06,31181.2
2020/07,31378.3
2020/08,31648.27
2020/09,31742.73
2020/10,31627.6
2020/11,32546.54
2020/12,33298.78
\ No newline at end of file
from pandas import read_csv
from pandas import to_datetime
from pandas import DataFrame
from prophet import Prophet
from matplotlib import pyplot
import json
import datetime
from prophet.serialize import model_to_json, model_from_json
def train_fbp(company_name):
# net profit
path = 'impact_of_company_financial/data/' + company_name + '_net_profit_margin.csv'
df = read_csv(path, header=0)
df.columns = ['ds', 'y']
df['ds'] = to_datetime(df['ds'])
model = Prophet()
model.fit(df)
future = list()
for i in range(1, 13):
date = '2022-%02d' % i
future.append([date])
future = DataFrame(future)
future.columns = ['ds']
future['ds'] = to_datetime(future['ds'])
forecast = model.predict(future)
print(forecast['yhat'][-7:])
with open('impact_of_company_financial/trained_models/' + company_name + '_net_profit_margin.json', 'w') as fout:
json.dump(model_to_json(model), fout)
# earning per share
path = 'data/' + company_name + '_earnings_per_share.csv'
df = read_csv(path, header=0)
df.columns = ['ds', 'y']
df['ds'] = to_datetime(df['ds'])
model = Prophet()
model.fit(df)
future = list()
for i in range(1, 13):
date = '2022-%02d' % i
future.append([date])
future = DataFrame(future)
future.columns = ['ds']
future['ds'] = to_datetime(future['ds'])
forecast = model.predict(future)
print(forecast['yhat'][-7:])
with open('trained_models/' + company_name + '_earnings_per_share.json', 'w') as fout:
json.dump(model_to_json(model), fout)
def forecast_fbp(company_name, no_of_months):
path_net_profit_margin = 'impact_of_company_financial/data/' + company_name + '_net_profit_margin.csv'
df_net_profit_margin = read_csv(path_net_profit_margin, header=0)
path_earnings_per_share = 'impact_of_company_financial/data/' + company_name + '_earnings_per_share.csv'
df_earnings_per_share = read_csv(path_earnings_per_share, header=0)
df_net_profit_margin.columns = ['ds', 'y']
df_net_profit_margin['ds'] = to_datetime(df_net_profit_margin['ds'])
df_earnings_per_share.columns = ['ds', 'y']
df_earnings_per_share['ds'] = to_datetime(df_earnings_per_share['ds'])
model_net_profit_margin = Prophet()
model_earnings_per_share = Prophet()
model_net_profit_margin.fit(df_net_profit_margin)
model_earnings_per_share.fit(df_earnings_per_share)
# with open('trained_models/' + str(company_name) + '_net_profit_margin.json', 'r') as fin:
# model_net_profit_margin = model_from_json(fin.read())
#
# with open('trained_models/' + str(company_name) + '_earnings_per_share.json', 'r') as fin:
# model_earnings_per_share = model_from_json(fin.read())
future = list()
future_dates = []
today = datetime.datetime.today()
for i in range(no_of_months):
today = today + datetime.timedelta(days=30)
future.append([today.strftime('%Y-%m')])
future_dates.append(today.strftime('%Y-%m'))
future = DataFrame(future)
future.columns = ['ds']
future['ds'] = to_datetime(future['ds'])
forecast_net_profit_margin = model_net_profit_margin.predict(future)
forecast_earnings_per_share = model_earnings_per_share.predict(future)
data_net_profit_margin = []
data_earnings_per_share = []
for i in forecast_net_profit_margin['yhat'][-no_of_months:]:
data_net_profit_margin.append(round(i, 2))
for i in forecast_earnings_per_share['yhat'][-no_of_months:]:
data_earnings_per_share.append(round(i, 2))
return data_net_profit_margin, data_earnings_per_share, future_dates
# train_fbp('ASIA_ASSET_FINANCE_PLC')
# x,y = forecast_fbp('ASIA_ASSET_FINANCE_PLC',5)
# print(x,y)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment