-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]try to add fmp senate trading data api #6957
base: develop
Are you sure you want to change the base?
[Feature]try to add fmp senate trading data api #6957
Conversation
|
@mmistroni take a look please. |
sr - but beware i m not OBB :)
pls give me couple of days as i m busy w work :(
- also can you point me to your repo and branch so i can hv a look? - sorry for being lazy
…On Wed, Nov 27, 2024 at 8:18 AM 邱承 ***@***.***> wrote:
@mmistroni <https://github.com/mmistroni> take a look please.
—
Reply to this email directly, view it on GitHub
<#6957 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACPNCDUGPBMZZZ643GCGQK32CV54TAVCNFSM6AAAAABSINNVOGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBTGIYDSNJTG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, this is great!
I'm asking for a few minor changes, and to please translate all code comments into English.
Thanks very much!
symbol: Optional[str] = Field( | ||
default=None, description=QUERY_DESCRIPTIONS.get("symbol", "") | ||
) | ||
chamber: Literal["house", "senate", "all"] = Field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a default value here, let's go with "all".
|
||
@field_validator("symbol", mode="before", check_fields=False) | ||
@classmethod | ||
def to_upper(cls, v: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we can lose the Type annotations so it's def to_upper(cls, v):
And then we need to allow NoneType, so it becomes, return v.upper() if v else None
api_key = credentials.get("fmp_api_key") if credentials else "" | ||
|
||
async def get_one(url): | ||
# 指定要移除的键 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a docstring here instead of a comment. Something like, """Get data for one URL.""" is sufficient.
async def get_one(url): | ||
# 指定要移除的键 | ||
keys_to_remove = [ | ||
"comment", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query: FMPGovernmentTradesQueryParams, data: List[Dict], **kwargs: Any | ||
) -> List[FMPGovernmentTradesData]: | ||
"""Return the transformed data.""" | ||
return [FMPGovernmentTradesData(**d) for d in data] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this stage, we should sort the data by date because the gather
process will be appending as they come.
There's also some empty strings being passed in a few fields. None
is preferred for Optional[str]
because evaluating for None is more consistent than checking truthiness. For example, it's not uncommon to receive "''"
, which would pass truthiness.
Example of empty strings, "owner="
FMPGovernmentTradesData(symbol=AMZN, date=2024-11-22, transaction_date=2024-11-20, representative=Marjorie Taylor Greene, link=https://disclosures-clerk.house.gov/public_disc/ptr-pdfs/2024/20026257.pdf, owner=, asset_type=None, asset_description=Amazon.com Inc, type=Purchase, amount=$1,001 - $15,000, comment=None)
params limit only functions when there is no parameter symbol | ||
""" | ||
params = { | ||
"chamber": "all", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we will be capturing the requests. If we can minimize the amount of data received in the HTTP request, this will help reduce the overall footprint of the testing suite. A limit of 1 should be adequate as the purpose for these tests is to check the fetching mechanism and the typing.
Capturing the test cassettes is rather peculiar, so don't worry about that. I'll deal with that, you've done great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deeleeramone Thanks for your correction, I alreadey improved my codes.
try to add fmp senate trading data api
2. What?:
attempted to integrate the Senate API