-
Notifications
You must be signed in to change notification settings - Fork 3
/
apiary.apib
226 lines (177 loc) · 6.55 KB
/
apiary.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
FORMAT: 1A
HOST: https://whispering-reef-73372.herokuapp.com
# Python Microservice Finance
Contains services for stock related calculations. That includes calculating the profit/loss from selling a stock through Maybank Investment,
calculating the minimum sell price to avoid losses, and calculation for minimum sell price for a target profit.
Additionally, it includes an endpoint to calculate Dividend Discount Model (DDM) to obtain a company's intrinsic value, given the current financial key data.
## Fundamentals Endpoint [/fundamentals/dividend-discount-model]
### Calculate Dividend Discount Model [POST]
You can calculate the intrinsic value of a company with this service. It takes a JSON
object containing the company financial status.
+ Request (application/json)
{
"interest_rate": 0.02,
"business_tax_rate": 0.3,
"stock_beta": 1.24,
"market_risk_free_premium": 0.055,
"risk_free_rate": 0.0176,
"market_value_of_debt": 246250000,
"total_market_value_of_debt_and_equity": 2766250000,
"market_value_of_equity": 2520000000,
"years": 10,
"long_term_growth_rate": 0.08,
"free_cash_flow": 112500000,
"discount_rate": 0.0794,
"perpetuity_growth_rate": 0.024,
"cash_and_cash_equivalent": 16000000,
"total_liabilities": 348000000,
"shares_outstanding": 43140000,
"current_value_per_share": 58.41
}
+ Response 201 (application/json)
+ Body
{
"we": 0.9109805693628559,
"wd": 0.08901943063714415,
"tv": 2090692922.1198013,
"wacc": 0.07940840488025305,
"dcf": [
[
121500000.00000001,
0.9264406151565685
],
[
131220000.00000001,
0.8582922134116812
],
[
141717600.00000003,
0.7951567661772106
],
[
153055008.00000003,
0.7366655236031228
],
[
165299408.64000008,
0.6824768608515127
],
[
178523361.33120006,
0.6322742827973993
],
[
192805230.2376961,
0.5857645755025008
],
[
208229648.6567118,
0.542676093665463
],
[
224888020.54924875,
0.5027571740461952
],
[
242879062.19318867,
0.46577466559773506
]
],
"rd": 0.013999999999999999,
"re": 0.0858,
"ivps": 66.92485106218392,
"npv": 1128445152.702813
}
## Calculator Endpoint [/api/v1/costs]
### Calculate Profit/Loss from Selling stocks [POST /api/v1/costs/profit]
You can calculate the profit or loss from selling the stocks you purchased. It takes a JSON
object containing the buy price, sell price and the units bought.
+ Request (application/json)
{
"buy_price": 1.43,
"sell_price": 1.51,
"units": 3500
}
+ Response 201 (application/json)
+ Body
{
"data": {
"buy_fee": 29.891,
"gross_buy_price": 5005,
"gross_sell_price": 5635,
"net_buy_price": 5034.891,
"net_sell_price": 5602.103,
"profit_or_losses": 567.2120000000004,
"sell_fee": 32.897
}
}
### Calculate Minimum Sell Price [POST /api/v1/costs/minimum-sell-price]
You can calculate the minimum sell price of the stocks you bought in order to avoid losses. It takes a JSON
object containing the buy price and the units bought.
+ Request (application/json)
{
"buy_price": 1.43,
"units": 3500
}
+ Response 201 (application/json)
+ Body
{
"data": 1.45
}
### Calculate Sell Price for Target Profit [POST /api/v1/costs/target-profit]
You can calculate the minimum sell price of the stocks you bought in order to achieve the minimum of the amount you want to profit. It takes a JSON
object containing the buy price, units bought and the target profit.
+ Request (application/json)
{
"buy_price": 1.43,
"units": 3500,
"target_profit": 1000
}
+ Response 201 (application/json)
+ Body
{
"data": 1.74
}
### Calculate Projected Values for a Given Sell Price [POST /api/v1/costs/lists]
You can view the list of the projected profits/losses from selling the stock at a given price. It takes a JSON
object containing the buy price, sell price, and units bought.
+ Request (application/json)
{
"buy_price": 1.43,
"sell_price": 1.51,
"units": 3500
}
+ Response 201 (application/json)
+ Body
{
"data": [
{
"profit_or_loss": -1555.5909999999994,
"sell_price": 1
},
{
"profit_or_loss": -1520.7679999999996,
"sell_price": 1.01
},
{
"profit_or_loss": -1485.9349999999995,
"sell_price": 1.02
},
{
"profit_or_loss": 5264.687,
"sell_price": 2.96
},
{
"profit_or_loss": 5299.52,
"sell_price": 2.9699999999999998
},
{
"profit_or_loss": 5334.353000000001,
"sell_price": 2.98
},
{
"profit_or_loss": 5369.186,
"sell_price": 2.99
}
]
}