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
1 change: 1 addition & 0 deletions stake/asx/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class TradeType(str, Enum):

MARKET = "MARKET_TO_LIMIT"
LIMIT = "LIMIT"
STOP = "STOP"
9 changes: 0 additions & 9 deletions stake/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ class NYSEUrl(BaseModel):
)
users: str = urljoin(STAKE_URL, "user", allow_fragments=True)

# deprecated, use update_watchlist instead
watchlist_modify: str = urljoin(
STAKE_URL, "instruments/addRemoveInstrumentWatchlist", allow_fragments=True
)
# deprecated, use read_watchlist instead
watchlist: str = urljoin(
STAKE_URL, "products/productsWatchlist/{userId}", 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 = (
Expand Down
68 changes: 6 additions & 62 deletions stake/watchlist.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import uuid
from datetime import datetime
from typing import List, Optional, Union
from warnings import warn

from pydantic import BaseModel, ConfigDict, Field

Expand Down Expand Up @@ -42,6 +41,7 @@ class CreateWatchlistRequest(BaseModel):
"""This is used to create a new watchlist."""

name: str
tickers: List[str] | None = None


class UpdateWatchlistRequest(BaseModel):
Expand Down Expand Up @@ -98,59 +98,6 @@ async def _modify_watchlist(

return WatchlistResponse(symbol=request.symbol, watching=data["watching"])

async def add(self, request: AddToWatchlistRequest) -> WatchlistResponse:
"""Adds a symbol to the watchlist.

Args:
request (AddToWatchlistRequest): The request containing the symbol.

Returns:
WatchlistResponse: The result of the watchlist modification.
"""
warn(
"This method is deprecated, please use `add_to_watchlist` instead.",
DeprecationWarning,
stacklevel=2,
)

return await self._modify_watchlist(request)

async def remove(self, request: RemoveFromWatchlistRequest) -> WatchlistResponse:
"""Removes a symbol from the watchlist.

Args:
request (RemoveFromWatchlistRequest): The request containing the symbol

Returns:
WatchlistResponse: The result of the watchlist modification.
"""
warn(
"This method is deprecated, please use `remove_from_watchlist` instead.",
DeprecationWarning,
stacklevel=2,
)

return await self._modify_watchlist(request)

async def list(self) -> List[WatchlistProduct]:
"""Lists all the contents of your watchlist.

Returns:
List[WatchlistProduct]: The list of items in your watchlist.
"""
warn(
"This method is deprecated, please use `watchlist` instead.",
DeprecationWarning,
stacklevel=2,
)

watchlist = await self._client.get(
self._client.exchange.watchlist.format(userId=self._client.user.id)
)
return [
WatchlistProduct(**watched) for watched in watchlist["instrumentsWatchList"]
]

async def watchlist(self, request: GetWatchlistRequest) -> Watchlist:
"""Retrieves a watchlist by id.

Expand Down Expand Up @@ -188,14 +135,11 @@ async def create_watchlist(
watchlist_id = response.get("newWatchlistId", None)
assert watchlist_id, "Could not get a new watchlist"

return next(
(
Watchlist(**watchlist_data)
for watchlist_data in response["watchlists"]
if watchlist_data["watchlistId"] == watchlist_id
),
None,
)
if request.tickers:
return await self.add_to_watchlist(
request=UpdateWatchlistRequest(id=watchlist_id, tickers=request.tickers)
)
return await self.watchlist(request=GetWatchlistRequest(id=watchlist_id))

async def add_to_watchlist(self, request: UpdateWatchlistRequest) -> Watchlist:
"""Updates a watchlist by adding symbols to it."""
Expand Down
66 changes: 33 additions & 33 deletions tests/cassettes/test_watchlist/test_add_to_watchlist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,25 @@ interactions:
string:
'{"canTradeOnUnsettledFunds": false, "cpfValue": null, "emailVerified":
true, "hasFunded": true, "hasTraded": true, "userId": "7c9bbfae-0000-47b7-0000-0e66d868c2cf",
"username": "rita19", "emailAddress": "torresbenjamin@gmail.com", "dw_AccountId":
"1cf93550-8eb4-4c32-a229-826cf8c1be59", "dw_AccountNumber": "w4-1267174s",
"macAccountNumber": "H1-7641957H", "status": null, "macStatus": "BASIC_USER",
"dwStatus": null, "truliooStatus": "APPROVED", "truliooStatusWithWatchlist":
null, "firstName": "Tammy", "lastName": "Alexander", "phoneNumber": "9011530005",
"signUpPhase": 0, "ackSignedWhen": "2021-05-18", "createdDate": 1574303699770,
"stakeApprovedDate": null, "accountType": "INDIVIDUAL", "masterAccountId":
null, "referralCode": "L7-2127933N", "referredByCode": null, "regionIdentifier":
"username": "michael29", "emailAddress": "reevesmegan@gilmore-wright.biz",
"dw_AccountId": "1cf93550-8eb4-4c32-a229-826cf8c1be59", "dw_AccountNumber":
"z0-0593879b", "macAccountNumber": "d9-0481457G", "status": null, "macStatus":
"BASIC_USER", "dwStatus": null, "truliooStatus": "APPROVED", "truliooStatusWithWatchlist":
null, "firstName": "Rita", "middleName": null, "lastName": "Jones", "phoneNumber":
"(640)242-4270x965", "signUpPhase": 0, "ackSignedWhen": "2023-10-01", "createdDate":
1574303699770, "stakeApprovedDate": null, "accountType": "INDIVIDUAL", "masterAccountId":
null, "referralCode": "W2-6612029X", "referredByCode": null, "regionIdentifier":
"AUS", "assetSummary": null, "fundingStatistics": null, "tradingStatistics":
null, "w8File": [], "rewardJourneyTimestamp": null, "rewardJourneyStatus":
null, "userProfile": {"residentialAddress": null, "postalAddress": null},
"ledgerBalance": 0.0, "investorAccreditations": null, "proscoreStatus": null,
"fxSpeed": "Regular", "facilitaStatus": null, "dateOfBirth": null, "upToDateDetails2021":
"ledgerBalance": 0.0, "fxSpeed": "Regular", "dateOfBirth": null, "upToDateDetails2021":
"NO_REQUIREMENTS", "stakeKycStatus": "KYC_APPROVED", "awxMigrationDocsRequired":
null, "documentsStatus": "NO_ACTION", "mfaenabled": false}'
null, "documentsStatus": "NO_ACTION", "accountStatus": "OPEN", "mfaenabled":
false}'
headers: {}
status:
code: 200
message: OK
url: https://global-prd-api.hellostake.com/api/user
- request:
body: null
headers:
Expand All @@ -45,31 +44,33 @@ interactions:
response:
body:
string:
'{"products": [{"id": "b738ff53-b576-4f09-822e-91128def0560", "instrumentTypeID":
null, "symbol": "SPOT", "description": "Spotify Technology SA a Luxembourg-based
company, which offers digital music-streaming services. The Company enables
users to discover new releases, which includes the latest singles and albums;
playlists, which includes ready-made playlists put together by music fans
and experts, and over millions of songs so that users can play their favorites,
discover new tracks and build a personalized collection. Users can either
select Spotify Free, which includes only shuffle play or Spotify Premium,
which encompasses a range of features, such as shuffle play, advertisement
free, unlimited skips, listen offline, play any track and high quality audio.
The Company operates through a number of subsidiaries, including Spotify LTD
and is present in over 20 countries.", "category": "Stock", "currencyID":
null, "urlImage": "https://drivewealth.imgix.net/symbols/spot.png?fit=fillmax&w=125&h=125&bg=FFFFFF",
"sector": null, "name": "Spotify Technology SA", "dailyReturn": -3.32, "dailyReturnPercentage":
-1.57, "lastTraded": 207.55, "monthlyReturn": 0.0, "yearlyReturnPercentage":
92.8, "yearlyReturnValue": 131.68, "popularity": 9470.0, "watched": 8075,
"news": 0, "bought": 9479, "viewed": 23400, "productType": "Instrument", "exchange":
null, "status": "ACTIVE", "type": "EQUITY", "encodedName": "spotify-technology-sa-spot",
"period": "YEAR RETURN", "inceptionDate": 1522713600000, "instrumentTags":
'{"products": [{"id": "1cf93550-8eb4-4c32-a229-826cf8c1be59", "stakeInstrumentId":
"732309e2-71df-41c8-89ac-6bdc2b09356a", "instrumentTypeID": null, "symbol":
"SPOT", "description": "Spotify Technology SA a Luxembourg-based company,
which offers digital music-streaming services. The Company enables users to
discover new releases, which includes the latest singles and albums; playlists,
which includes ready-made playlists put together by music fans and experts,
and over millions of songs so that users can play their favorites, discover
new tracks and build a personalized collection. Users can either select Spotify
Free, which includes only shuffle play or Spotify Premium, which encompasses
a range of features, such as shuffle play, advertisement free, unlimited skips,
listen offline, play any track and high quality audio. The Company operates
through a number of subsidiaries, including Spotify LTD and is present in
over 20 countries.", "category": "Stock", "currencyID": null, "urlImage":
"https://drivewealth.imgix.net/symbols/spot.png?fit=fillmax&w=125&h=125&bg=FFFFFF",
"sector": null, "name": "Spotify Technology SA", "prePostMarketDailyReturn":
-0.87, "prePostMarketDailyReturnPercentage": -0.13, "dailyReturn": -5.56,
"dailyReturnPercentage": -0.81, "lastTraded": 682.24, "monthlyReturn": 0.0,
"yearlyReturnPercentage": 92.8, "yearlyReturnValue": 131.68, "popularity":
9470.0, "watched": 8806, "news": 0, "bought": 14189, "viewed": 26300, "productType":
"Instrument", "exchange": null, "status": "ACTIVE", "type": "EQUITY", "encodedName":
"spotify-technology-sa-spot", "period": "YEAR RETURN", "extendedHoursNotionalStatus":
"ACTIVE", "inceptionDate": 1522713600000, "marketCap": 121400901583, "instrumentTags":
[], "childInstruments": []}]}'
headers: {}
status:
code: 200
message: OK
url: https://global-prd-api.hellostake.com/api/products/searchProduct?symbol=SPOT&page=1&max=1
- request:
body: null
headers:
Expand All @@ -88,5 +89,4 @@ interactions:
status:
code: 202
message: Accepted
url: https://global-prd-api.hellostake.com/api/instruments/addRemoveInstrumentWatchlist
version: 1
Loading
Loading