Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In order to successfully issue requests to the Stake platform you will need to a

## Using an existing Session-Token

You can retrieve one of these `Stake-Session-Token` by using the developer tools in your browser (Network tab) and inspecting some of the request headers sent to some of the `https://global-prd-api.hellostake.com/` host. (For example, click on the wishlist of dashboard links to see some session-token authenticated requests)
You can retrieve one of these `Stake-Session-Token` by using the developer tools in your browser (Network tab) and inspecting some of the request headers sent to some of the `https://api2.prd.hellostake.com/` host. (For example, click on the wishlist of dashboard links to see some session-token authenticated requests)

They are usually valid for 30 days (be sure to enable that checkbox on login) and seem to get refreshed before expiry so you should be good to use them directly.

Expand Down
2,532 changes: 1,386 additions & 1,146 deletions poetry.lock

Large diffs are not rendered by default.

106 changes: 61 additions & 45 deletions stake/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,78 +9,90 @@
class NYSEUrl(BaseModel):
"""Contains all the visited stake urls for the NYSE."""

STAKE_URL: str = "https://global-prd-api.hellostake.com/api/"
STAKE_URL: str = "https://api2.prd.hellostake.com/"
account_balance: str = urljoin(
STAKE_URL, "cma/getAccountBalance", allow_fragments=True
STAKE_URL, "api/cma/getAccountBalance", allow_fragments=True
)
account_transactions: str = urljoin(
STAKE_URL, "users/accounts/accountTransactions", allow_fragments=True
STAKE_URL, "api/users/accounts/accountTransactions", allow_fragments=True
)
brokerage: str = urljoin(
STAKE_URL, "orders/brokerage?orderAmount={orderAmount}", allow_fragments=True
STAKE_URL,
"api/orders/brokerage?orderAmount={orderAmount}",
allow_fragments=True,
)
cancel_order: str = urljoin(
STAKE_URL, "orders/cancelOrder/{orderId}", allow_fragments=True
STAKE_URL, "api/orders/cancelOrder/{orderId}", allow_fragments=True
)
cash_available: str = urljoin(
STAKE_URL, "users/accounts/cashAvailableForWithdrawal", allow_fragments=True
STAKE_URL, "api/users/accounts/cashAvailableForWithdrawal", allow_fragments=True
)
create_session: str = urljoin(
STAKE_URL, "sessions/v2/createSession", allow_fragments=True
STAKE_URL, "api/sessions/v2/createSession", allow_fragments=True
)
equity_positions: str = urljoin(
STAKE_URL, "users/accounts/v2/equityPositions", allow_fragments=True
STAKE_URL, "api/users/accounts/v2/equityPositions", allow_fragments=True
)
fund_details: str = urljoin(STAKE_URL, "api/fund/details", allow_fragments=True)
market_status: str = urljoin(
STAKE_URL, "api/utils/marketStatus", allow_fragments=True
)
orders: str = urljoin(
STAKE_URL, "api/users/accounts/v2/orders", allow_fragments=True
)
fund_details: str = urljoin(STAKE_URL, "fund/details", allow_fragments=True)
market_status: str = urljoin(STAKE_URL, "utils/marketStatus", allow_fragments=True)
orders: str = urljoin(STAKE_URL, "users/accounts/v2/orders", allow_fragments=True)
products_suggestions: str = urljoin(
STAKE_URL, "products/getProductSuggestions/{keyword}", allow_fragments=True
STAKE_URL, "api/products/getProductSuggestions/{keyword}", allow_fragments=True
)
quick_buy: str = urljoin(
STAKE_URL, "purchaseorders/v2/quickBuy", allow_fragments=True
STAKE_URL, "api/purchaseorders/v2/quickBuy", allow_fragments=True
)
quotes: str = urljoin(
STAKE_URL, "quotes/marketData/{symbols}", allow_fragments=True
STAKE_URL, "api/quotes/marketData/{symbols}", allow_fragments=True
)
rate: str = urljoin(STAKE_URL, "wallet/rate", allow_fragments=True)
rate: str = urljoin(STAKE_URL, "api/wallet/rate", allow_fragments=True)
ratings: str = urljoin(
STAKE_URL,
"data/calendar/ratings?tickers={symbols}&pageSize={limit}",
"api/data/calendar/ratings?tickers={symbols}&pageSize={limit}",
allow_fragments=True,
)
sell_orders: str = urljoin(STAKE_URL, "sellorders", allow_fragments=True)
sell_orders: str = urljoin(STAKE_URL, "api/sellorders", allow_fragments=True)
symbol: str = urljoin(
STAKE_URL,
"products/searchProduct?symbol={symbol}&page=1&max=1",
"api/products/searchProduct?symbol={symbol}&page=1&max=1",
allow_fragments=True,
)
transaction_history: str = urljoin(
STAKE_URL, "users/accounts/transactionHistory", allow_fragments=True
STAKE_URL, "api/users/accounts/transactionHistory", allow_fragments=True
)
transaction_details: str = urljoin(
STAKE_URL,
(
"users/accounts/transactionDetails?"
"api/users/accounts/transactionDetails?"
"reference={reference}&referenceType={reference_type}"
),
allow_fragments=True,
)
transactions: str = urljoin(
STAKE_URL, "users/accounts/transactions", allow_fragments=True
STAKE_URL, "api/users/accounts/transactions", allow_fragments=True
)
users: str = urljoin(STAKE_URL, "user", allow_fragments=True)
users: str = urljoin(STAKE_URL, "api/user", allow_fragments=True)

watchlists: str = "https://api.prd.stakeover.io/us/instrument/watchlists"
create_watchlist: str = "https://api.prd.stakeover.io/us/instrument/watchlist"
read_watchlist: str = (
"https://api.prd.stakeover.io/us/instrument/watchlist/{watchlist_id}"
watchlists: str = urljoin(
STAKE_URL, "us/instrument/watchlists", allow_fragments=True
)
create_watchlist: str = urljoin(
STAKE_URL, "us/instrument/watchlist", allow_fragments=True
)
read_watchlist: str = urljoin(
STAKE_URL, "us/instrument/watchlist/{watchlist_id}", allow_fragments=True
)
update_watchlist: str = urljoin(
STAKE_URL, "us/instrument/watchlist/{watchlist_id}/items", allow_fragments=True
)
update_watchlist: str = read_watchlist + "/items"

statement: str = urljoin(
STAKE_URL,
"data/fundamentals/{symbol}/statements?startDate={date}",
"api/data/fundamentals/{symbol}/statements?startDate={date}",
allow_fragments=True,
)

Expand All @@ -91,59 +103,63 @@ class NYSEUrl(BaseModel):
class ASXUrl(BaseModel):
"""Contains all the visited stake urls for the ASX."""

ASX_STAKE_URL: str = "https://global-prd-api.hellostake.com/api/asx/"
ASX_STAKE_URL: str = "https://api2.prd.hellostake.com/"
brokerage: str = urljoin(
ASX_STAKE_URL,
"orders/brokerage?orderAmount={orderAmount}",
"api/asx/orders/brokerage?orderAmount={orderAmount}",
allow_fragments=True,
)
cash_available: str = urljoin(ASX_STAKE_URL, "cash", allow_fragments=True)
cash_available: str = urljoin(ASX_STAKE_URL, "api/asx/cash", allow_fragments=True)
cancel_order: str = urljoin(
ASX_STAKE_URL, "orders/{orderId}/cancel", allow_fragments=True
ASX_STAKE_URL, "api/asx/orders/{orderId}/cancel", allow_fragments=True
)
equity_positions: str = urljoin(
ASX_STAKE_URL, "instrument/equityPositions", allow_fragments=True
ASX_STAKE_URL, "api/asx/instrument/equityPositions", allow_fragments=True
)
market_status: str = urljoin(
ASX_STAKE_URL, "instrument/quoteTwo/ASX", allow_fragments=True
ASX_STAKE_URL, "api/asx/instrument/quoteTwo/ASX", allow_fragments=True
)

orders: str = urljoin(ASX_STAKE_URL, "orders", allow_fragments=True)
orders: str = urljoin(ASX_STAKE_URL, "api/asx/orders", allow_fragments=True)

products_suggestions: str = urljoin(
ASX_STAKE_URL,
"instrument/search?searchKey={keyword}",
"api/asx/instrument/search?searchKey={keyword}",
allow_fragments=True,
)

symbol: str = urljoin(
ASX_STAKE_URL,
"instrument/singleQuote/{symbol}",
"api/asx/instrument/singleQuote/{symbol}",
allow_fragments=True,
)

trade_activity: str = urljoin(
ASX_STAKE_URL, "orders/tradeActivity", allow_fragments=True
ASX_STAKE_URL, "api/asx/orders/tradeActivity", allow_fragments=True
)
watchlists: str = urljoin(
ASX_STAKE_URL, "instrument/v2/watchlists", allow_fragments=True
ASX_STAKE_URL, "api/asx/instrument/v2/watchlists", allow_fragments=True
)
create_watchlist: str = urljoin(
ASX_STAKE_URL, "instrument/v2/watchlist", allow_fragments=True
ASX_STAKE_URL, "api/asx/instrument/v2/watchlist", allow_fragments=True
)
read_watchlist: str = urljoin(
ASX_STAKE_URL, "instrument/v2/watchlist/{watchlist_id}", allow_fragments=True
ASX_STAKE_URL,
"api/asx/instrument/v2/watchlist/{watchlist_id}",
allow_fragments=True,
)
update_watchlist: str = urljoin(
ASX_STAKE_URL,
"instrument/v2/watchlist/{watchlist_id}/items",
"api/asx/instrument/v2/watchlist/{watchlist_id}/items",
allow_fragments=True,
)
instrument_from_symbol: str = urljoin(
ASX_STAKE_URL, "instrument/view/{symbol}", allow_fragments=True
ASX_STAKE_URL, "api/asx/instrument/view/{symbol}", allow_fragments=True
)
transactions: str = urljoin(
ASX_STAKE_URL, "api/asx/transactions", allow_fragments=True
)
transactions: str = urljoin(ASX_STAKE_URL, "transactions", allow_fragments=True)
users: str = "https://global-prd-api.hellostake.com/api/user"
users: str = urljoin(ASX_STAKE_URL, "api/user", allow_fragments=True)


ASX = ASXUrl()
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://global-prd-api.hellostake.com/api/user
uri: https://api2.prd.hellostake.com/api/user
response:
body:
string:
Expand All @@ -33,7 +33,7 @@ interactions:
status:
code: 200
message: OK
url: https://global-prd-api.hellostake.com/api/user
url: https://api2.prd.hellostake.com/api/user
- request:
body: null
headers:
Expand All @@ -42,7 +42,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://global-prd-api.hellostake.com/api/users/accounts/v2/equityPositions
uri: https://api2.prd.hellostake.com/api/users/accounts/v2/equityPositions
response:
body:
string:
Expand Down Expand Up @@ -112,5 +112,5 @@ interactions:
status:
code: 200
message: OK
url: https://global-prd-api.hellostake.com/api/users/accounts/v2/equityPositions
url: https://api2.prd.hellostake.com/api/users/accounts/v2/equityPositions
version: 1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://global-prd-api.hellostake.com/api/user
uri: https://api2.prd.hellostake.com/api/user
response:
body:
string:
Expand All @@ -33,7 +33,7 @@ interactions:
status:
code: 200
message: OK
url: https://global-prd-api.hellostake.com/api/user
url: https://api2.prd.hellostake.com/api/user
- request:
body: null
headers:
Expand All @@ -42,7 +42,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://global-prd-api.hellostake.com/api/asx/instrument/equityPositions
uri: https://api2.prd.hellostake.com/api/asx/instrument/equityPositions
response:
body:
string:
Expand Down Expand Up @@ -81,5 +81,5 @@ interactions:
status:
code: 200
message: OK
url: https://global-prd-api.hellostake.com/api/asx/instrument/equityPositions
url: https://api2.prd.hellostake.com/api/asx/instrument/equityPositions
version: 1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://global-prd-api.hellostake.com/api/user
uri: https://api2.prd.hellostake.com/api/user
response:
body:
string:
Expand Down Expand Up @@ -40,7 +40,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://global-prd-api.hellostake.com/api/users/accounts/cashAvailableForWithdrawal
uri: https://api2.prd.hellostake.com/api/users/accounts/cashAvailableForWithdrawal
response:
body:
string:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://global-prd-api.hellostake.com/api/user
uri: https://api2.prd.hellostake.com/api/user
response:
body:
string:
Expand Down Expand Up @@ -40,7 +40,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://global-prd-api.hellostake.com/api/asx/cash
uri: https://api2.prd.hellostake.com/api/asx/cash
response:
body:
string:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://global-prd-api.hellostake.com/api/user
uri: https://api2.prd.hellostake.com/api/user
response:
body:
string:
Expand All @@ -33,7 +33,7 @@ interactions:
status:
code: 200
message: OK
url: https://global-prd-api.hellostake.com/api/user
url: https://api2.prd.hellostake.com/api/user
- request:
body: null
headers:
Expand All @@ -42,13 +42,13 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://global-prd-api.hellostake.com/api/fund/details
uri: https://api2.prd.hellostake.com/api/fund/details
response:
body:
string: '{"fundsInFlight": []}'
headers: {}
status:
code: 200
message: OK
url: https://global-prd-api.hellostake.com/api/fund/details
url: https://api2.prd.hellostake.com/api/fund/details
version: 1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://global-prd-api.hellostake.com/api/user
uri: https://api2.prd.hellostake.com/api/user
response:
body:
string:
Expand All @@ -33,7 +33,7 @@ interactions:
status:
code: 200
message: OK
url: https://global-prd-api.hellostake.com/api/user
url: https://api2.prd.hellostake.com/api/user
- request:
body: null
headers:
Expand All @@ -42,13 +42,13 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://global-prd-api.hellostake.com/api/asx/transactions?status=PENDING&status=AWAITING_APPROVAL&size=100&page=0
uri: https://api2.prd.hellostake.com/api/asx/transactions?status=PENDING&status=AWAITING_APPROVAL&size=100&page=0
response:
body:
string: '{"items": [], "hasNext": false, "page": 0, "totalItems": 0}'
headers: {}
status:
code: 200
message: OK
url: https://global-prd-api.hellostake.com/api/asx/transactions?status=PENDING&status=AWAITING_APPROVAL&size=100&page=0
url: https://api2.prd.hellostake.com/api/asx/transactions?status=PENDING&status=AWAITING_APPROVAL&size=100&page=0
version: 1
Loading
Loading