Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
limx0 committed Feb 22, 2024
1 parent 3d54cec commit 5bff0d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions nautilus_trader/adapters/betfair/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ async def connection_account_state(self) -> None:
account_detail=account_details,
account_funds=account_funds,
event_id=UUID4(),
reported=True,
ts_event=timestamp,
ts_init=timestamp,
)
Expand Down
6 changes: 4 additions & 2 deletions nautilus_trader/adapters/betfair/parsing/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# -------------------------------------------------------------------------------------------------

import hashlib
from functools import lru_cache

import msgspec
from betfair_parser.spec.common import Handicap
from betfair_parser.spec.common import MarketId
from betfair_parser.spec.common import SelectionId
Expand All @@ -27,7 +28,8 @@


def hash_market_trade(timestamp: int, price: float, volume: float) -> str:
return f"{str(timestamp)[:-6]}{price}{volume!s}"
data = (timestamp, price, volume)
return hashlib.shake_256(msgspec.json.encode(data)).hexdigest(18)


@lru_cache
Expand Down
3 changes: 2 additions & 1 deletion nautilus_trader/adapters/betfair/parsing/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ def betfair_account_to_account_state(
event_id,
ts_event,
ts_init,
reported,
account_id="001",
) -> AccountState:
currency = Currency.from_str(account_detail.currency_code)
Expand All @@ -307,7 +308,7 @@ def betfair_account_to_account_state(
account_id=AccountId(f"{BETFAIR_VENUE.value}-{account_id}"),
account_type=AccountType.BETTING,
base_currency=currency,
reported=False,
reported=reported,
balances=[
AccountBalance(
total=Money(balance, currency),
Expand Down

0 comments on commit 5bff0d1

Please sign in to comment.