Skip to content

Commit 6fbf7fc

Browse files
authored
upgrade Earnings Calendar API to stable endpoint (#63)
* upgrade Earnings Calendar API to stable endpoint * upgrade all calendar apis to stable endpoints * update insider apis to stable channel
1 parent 57efe08 commit 6fbf7fc

File tree

3 files changed

+131
-66
lines changed

3 files changed

+131
-66
lines changed

fmpsdk/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,13 @@
7878
from .general import historical_chart, historical_price_full, quote
7979
from .insider_trading import (
8080
insider_trading,
81+
insider_trading_latest,
82+
insider_trading_by_reporting_name,
83+
insider_trading_transaction_types,
84+
insider_trading_statistics,
85+
acquisition_of_beneficial_ownership,
86+
8187
insider_trading_rss_feed,
82-
insider_trade_statistics,
8388
mapper_cik_company,
8489
mapper_cik_name,
8590
)

fmpsdk/calendar.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22
import logging
33

44
from .settings import DEFAULT_LIMIT
5-
from .url_methods import __return_json_v3, __return_json_v4
5+
from .url_methods import __return_json_v3, __return_json_v4, __return_json_stable
66

77

88
def earning_calendar(
99
apikey: str, from_date: str = None, to_date: str = None
1010
) -> typing.Optional[typing.List[typing.Dict]]:
1111
"""
12-
Query FMP /earning_calendar/ API.
12+
Query FMP /earnings-calendar/ API.
1313
1414
Note: Between the "from" and "to" parameters the maximum time interval can be 3 months.
1515
:param apikey: Your API key.
16-
:param from_date: 'YYYY:MM:DD'
17-
:param to_date: 'YYYY:MM:DD'
16+
:param from_date: 'YYYY-MM-DD'
17+
:param to_date: 'YYYY-MM-DD'
1818
:return: A list of dictionaries.
1919
"""
20-
path = f"earning_calendar"
20+
path = f"earnings-calendar"
2121
query_vars = {
2222
"apikey": apikey,
2323
}
2424
if from_date:
2525
query_vars["from"] = from_date
2626
if to_date:
2727
query_vars["to"] = to_date
28-
return __return_json_v3(path=path, query_vars=query_vars)
28+
return __return_json_stable(path=path, query_vars=query_vars)
2929

3030

3131
def historical_earning_calendar(
@@ -53,92 +53,93 @@ def ipo_calendar(
5353
apikey: str, from_date: str = None, to_date: str = None
5454
) -> typing.Optional[typing.List[typing.Dict]]:
5555
"""
56-
Query FMP /ipo_calendar/ API.
56+
Query FMP /ipos-calendar/ API.
5757
5858
Note: Between the "from" and "to" parameters the maximum time interval can be 3 months.
5959
:param apikey: Your API key.
60-
:param from_date: 'YYYY:MM:DD'
61-
:param to_date: 'YYYY:MM:DD'
60+
:param from_date: 'YYYY-MM-DD'
61+
:param to_date: 'YYYY-MM-DD'
6262
:return: A list of dictionaries.
6363
"""
64-
path = f"ipo_calendar"
64+
path = f"ipos-calendar"
6565
query_vars = {
6666
"apikey": apikey,
6767
}
6868
if from_date:
6969
query_vars["from"] = from_date
7070
if to_date:
7171
query_vars["to"] = to_date
72-
return __return_json_v3(path=path, query_vars=query_vars)
72+
return __return_json_stable(path=path, query_vars=query_vars)
7373

7474

7575
def stock_split_calendar(
7676
apikey: str, from_date: str = None, to_date: str = None
7777
) -> typing.Optional[typing.List[typing.Dict]]:
7878
"""
79-
Query FMP /stock_split_calendar/ API.
79+
Query FMP /splits-calendar/ API.
8080
8181
Note: Between the "from" and "to" parameters the maximum time interval can be 3 months.
8282
:param apikey: Your API key.
83-
:param from_date: 'YYYY:MM:DD'
84-
:param to_date: 'YYYY:MM:DD'
83+
:param from_date: 'YYYY-MM-DD'
84+
:param to_date: 'YYYY-MM-DD'
8585
:return: A list of dictionaries.
8686
"""
87-
path = f"stock_split_calendar"
87+
path = f"splits-calendar"
8888
query_vars = {
8989
"apikey": apikey,
9090
}
9191
if from_date:
9292
query_vars["from"] = from_date
9393
if to_date:
9494
query_vars["to"] = to_date
95-
return __return_json_v3(path=path, query_vars=query_vars)
95+
return __return_json_stable(path=path, query_vars=query_vars)
9696

9797

9898
def dividend_calendar(
9999
apikey: str, from_date: str = None, to_date: str = None
100100
) -> typing.Optional[typing.List[typing.Dict]]:
101101
"""
102-
Query FMP /stock_dividend_calendar/ API.
102+
Query FMP /dividends-calendar/ API.
103103
104104
Note: Between the "from" and "to" parameters the maximum time interval can be 3 months.
105105
:param apikey: Your API key.
106-
:param from_date: 'YYYY:MM:DD'
107-
:param to_date: 'YYYY:MM:DD'
106+
:param from_date: 'YYYY-MM-DD'
107+
:param to_date: 'YYYY-MM-DD'
108108
:return: A list of dictionaries.
109109
"""
110-
path = f"stock_dividend_calendar"
110+
path = f"dividends-calendar"
111111
query_vars = {
112112
"apikey": apikey,
113113
}
114114
if from_date:
115115
query_vars["from"] = from_date
116116
if to_date:
117117
query_vars["to"] = to_date
118-
return __return_json_v3(path=path, query_vars=query_vars)
118+
119+
return __return_json_stable(path=path, query_vars=query_vars)
119120

120121

121122
def economic_calendar(
122123
apikey: str, from_date: str = None, to_date: str = None
123124
) -> typing.Optional[typing.List[typing.Dict]]:
124125
"""
125-
Query FMP /economic_calendar/ API.
126+
Query FMP /economic-calendar/ API.
126127
127128
Note: Between the "from" and "to" parameters the maximum time interval can be 3 months.
128129
:param apikey: Your API key.
129-
:param from_date: 'YYYY:MM:DD'
130-
:param to_date: 'YYYY:MM:DD'
130+
:param from_date: 'YYYY-MM-DD'
131+
:param to_date: 'YYYY-MM-DD'
131132
:return: A list of dictionaries.
132133
"""
133-
path = f"economic_calendar"
134+
path = f"economic-calendar"
134135
query_vars = {
135136
"apikey": apikey,
136137
}
137138
if from_date:
138139
query_vars["from"] = from_date
139140
if to_date:
140141
query_vars["to"] = to_date
141-
return __return_json_v3(path=path, query_vars=query_vars)
142+
return __return_json_stable(path=path, query_vars=query_vars)
142143

143144

144145
def earning_calendar_confirmed(

fmpsdk/insider_trading.py

Lines changed: 98 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,129 @@
22
import typing
33

44
from .settings import DEFAULT_LIMIT
5-
from .url_methods import __return_json_v3, __return_json_v4
5+
from .url_methods import __return_json_v3, __return_json_v4, __return_json_stable
66

77

88
def insider_trading(
99
apikey: str,
1010
symbol: str = None,
11-
reporting_name: str = None,
11+
reportingCik: str = None,
12+
companyCik: str = None,
13+
transactionType: str = None,
14+
page: int = 0,
1215
limit: int = DEFAULT_LIMIT,
1316
) -> typing.Optional[typing.List[typing.Dict]]:
1417
"""
15-
Query FMP /insider-trading/ API.
18+
Query FMP /insider-trading/search API.
1619
1720
:param apikey: Your API key.
18-
:param symbol: Company ticker.
19-
:param reporting_name: Name of reporting person.
21+
:param symbol: Company ticker symbol.
22+
:param reportingCik: CIK of the reporting person.
23+
:param companyCik: CIK of the company.
24+
:param transactionType: Type of transaction (e.g., 'P-Purchase', 'S-Sale').
25+
:param page: Page number for pagination.
2026
:param limit: Number of rows to return.
21-
:return: A list of dictionaries.
27+
:return: A list of dictionaries containing insider trading data.
2228
"""
23-
path = f"insider-trading"
24-
query_vars = {"apikey": apikey, "limit": limit}
29+
path = f"insider-trading/search"
30+
query_vars = {"apikey": apikey, "page": page, "limit": limit}
2531
if symbol:
2632
query_vars["symbol"] = symbol
27-
if reporting_name:
28-
query_vars["reportingName"] = reporting_name
29-
return __return_json_v3(path=path, query_vars=query_vars)
33+
if reportingCik:
34+
query_vars["reportingCik"] = reportingCik
35+
if companyCik:
36+
query_vars["companyCik"] = companyCik
37+
if transactionType:
38+
query_vars["transactionType"] = transactionType
39+
return __return_json_stable(path=path, query_vars=query_vars)
40+
41+
42+
def insider_trading_latest(
43+
apikey: str,
44+
page: int = 0,
45+
limit: int = DEFAULT_LIMIT,
46+
) -> typing.Optional[typing.List[typing.Dict]]:
47+
"""
48+
Query FMP /insider-trading/latest API.
49+
50+
:param apikey: Your API key.
51+
:param page: Page number for pagination.
52+
:param limit: Number of rows to return.
53+
:return: A list of dictionaries containing latest insider trading data.
54+
"""
55+
path = f"insider-trading/latest"
56+
query_vars = {"apikey": apikey, "page": page, "limit": limit}
57+
return __return_json_stable(path=path, query_vars=query_vars)
3058

3159

32-
def insider_trade_statistics(
60+
def insider_trading_by_reporting_name(
3361
apikey: str,
34-
symbol: str,
62+
name: str = None,
3563
) -> typing.Optional[typing.List[typing.Dict]]:
3664
"""
37-
Query FMP /insider-roaster-statistic API.
65+
Query FMP /insider-trading/reporting-name API.
3866
39-
Get insider trading statistics for a specific company.
67+
:param apikey: Your API key.
68+
:param name: name of the reporting person.
69+
:return: A list of dictionaries containing reporting ciks.
70+
"""
71+
path = f"insider-trading/reporting-name"
72+
query_vars = {"apikey": apikey}
73+
if name:
74+
query_vars["name"] = name
75+
return __return_json_stable(path=path, query_vars=query_vars)
4076

41-
https://site.financialmodelingprep.com/developer/docs#insider-trade-statistics
4277

43-
Endpoint:
44-
https://financialmodelingprep.com/api/v4/insider-roaster-statistic?symbol=AAPL
78+
def insider_trading_transaction_types(
79+
apikey: str,
80+
) -> typing.Optional[typing.List[typing.Dict]]:
81+
"""
82+
Query FMP /insider-trading-transaction-type API.
83+
84+
:param apikey: Your API key.
85+
:return: A list of dictionaries containing all transaction types.
86+
"""
87+
path = f"insider-trading-transaction-type"
88+
query_vars = {"apikey": apikey}
89+
return __return_json_stable(path=path, query_vars=query_vars)
90+
91+
92+
def insider_trading_statistics(
93+
apikey: str,
94+
symbol: str = None,
95+
) -> typing.Optional[typing.List[typing.Dict]]:
96+
"""
97+
Query FMP /insider-trading/statistics API.
4598
4699
:param apikey: Your API key.
47100
:param symbol: Company ticker symbol.
48-
:return: A list of dictionaries containing insider trading statistics with fields:
49-
- symbol: The stock symbol
50-
- name: Name of the insider
51-
- position: Position in the company
52-
- totalBuy: Total number of buy transactions
53-
- totalBuyAmount: Total amount spent on buys
54-
- totalSell: Total number of sell transactions
55-
- totalSellAmount: Total amount from sells
56-
- totalTransactions: Total number of transactions
57-
- lastDate: Date of last transaction
58-
- lastPrice: Price of last transaction
59-
- lastAmount: Amount of last transaction
60-
- lastType: Type of last transaction (buy/sell)
61-
"""
62-
if not symbol:
63-
logging.warning("Symbol is required for insider trade statistics request.")
64-
return None
65-
66-
path = "insider-roaster-statistic"
67-
query_vars = {"apikey": apikey, "symbol": symbol}
68-
return __return_json_v4(path=path, query_vars=query_vars)
101+
:return: A list of dictionaries containing insider trading statistics.
102+
"""
103+
path = f"insider-trading/statistics"
104+
query_vars = {"apikey": apikey}
105+
if symbol:
106+
query_vars["symbol"] = symbol
107+
return __return_json_stable(path=path, query_vars=query_vars)
108+
109+
110+
def acquisition_of_beneficial_ownership(
111+
apikey: str,
112+
symbol: str = None,
113+
limit: int = DEFAULT_LIMIT,
114+
) -> typing.Optional[typing.List[typing.Dict]]:
115+
"""
116+
Query FMP /acquisition-of-beneficial-ownership API.
117+
118+
:param apikey: Your API key.
119+
:param symbol: Company ticker symbol.
120+
:param limit: Number of rows to return.
121+
:return: A list of dictionaries containing changes in stock ownership during acquisitions.
122+
"""
123+
path = f"acquisition-of-beneficial-ownership"
124+
query_vars = {"apikey": apikey, "limit": limit}
125+
if symbol:
126+
query_vars["symbol"] = symbol
127+
return __return_json_stable(path=path, query_vars=query_vars)
69128

70129

71130
def mapper_cik_name(

0 commit comments

Comments
 (0)