Skip to content

Commit

Permalink
update to limit orders
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonDane committed May 1, 2024
1 parent c28a619 commit 6f81029
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions public_invest_api/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ def get_portfolio(self):
timeout=self.timeout,
)
if portfolio.status_code != 200:
print("Portfolio request failed")
print(portfolio.text)
print(f"Portfolio request failed: {portfolio.text}")
return None
return portfolio.json()

Expand Down Expand Up @@ -236,8 +235,7 @@ def place_order(
timeout=self.timeout,
)
if preflight.status_code != 200:
print(preflight.text)
raise Exception("Preflight failed")
raise Exception(f"Preflight failed: {preflight.text}")
preflight = preflight.json()
# Build order endpoint
build_response = self.session.post(
Expand All @@ -247,7 +245,6 @@ def place_order(
timeout=self.timeout,
)
if build_response.status_code != 200:
print(build_response.text)
raise Exception(f"Build order failed: {build_response.text}")
build_response = build_response.json()
if build_response.get("orderId") is None:
Expand All @@ -261,12 +258,10 @@ def place_order(
timeout=self.timeout,
)
if submit_response.status_code != 200:
print(submit_response.text)
raise Exception("Submit order failed")
raise Exception(f"Submit order failed: {submit_response.text}")
submit_response = submit_response.json()
# Empty dict is success
if submit_response != {}:
print(f"Submit response: {submit_response}")
raise Exception(f"Order failed: {submit_response}")
sleep(1)
# Check if order was rejected
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="public_invest_api",
version="1.0.2",
version="1.0.3",
description="Unofficial Public.com Invest API written in Python Requests",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 6f81029

Please sign in to comment.