|
2 | 2 | import typing |
3 | 3 |
|
4 | 4 | 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 |
6 | 6 |
|
7 | 7 |
|
8 | 8 | def insider_trading( |
9 | 9 | apikey: str, |
10 | 10 | symbol: str = None, |
11 | | - reporting_name: str = None, |
| 11 | + reportingCik: str = None, |
| 12 | + companyCik: str = None, |
| 13 | + transactionType: str = None, |
| 14 | + page: int = 0, |
12 | 15 | limit: int = DEFAULT_LIMIT, |
13 | 16 | ) -> typing.Optional[typing.List[typing.Dict]]: |
14 | 17 | """ |
15 | | - Query FMP /insider-trading/ API. |
| 18 | + Query FMP /insider-trading/search API. |
16 | 19 |
|
17 | 20 | :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. |
20 | 26 | :param limit: Number of rows to return. |
21 | | - :return: A list of dictionaries. |
| 27 | + :return: A list of dictionaries containing insider trading data. |
22 | 28 | """ |
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} |
25 | 31 | if symbol: |
26 | 32 | 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) |
30 | 58 |
|
31 | 59 |
|
32 | | -def insider_trade_statistics( |
| 60 | +def insider_trading_by_reporting_name( |
33 | 61 | apikey: str, |
34 | | - symbol: str, |
| 62 | + name: str = None, |
35 | 63 | ) -> typing.Optional[typing.List[typing.Dict]]: |
36 | 64 | """ |
37 | | - Query FMP /insider-roaster-statistic API. |
| 65 | + Query FMP /insider-trading/reporting-name API. |
38 | 66 |
|
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) |
40 | 76 |
|
41 | | - https://site.financialmodelingprep.com/developer/docs#insider-trade-statistics |
42 | 77 |
|
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. |
45 | 98 |
|
46 | 99 | :param apikey: Your API key. |
47 | 100 | :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) |
69 | 128 |
|
70 | 129 |
|
71 | 130 | def mapper_cik_name( |
|
0 commit comments