Tutorials
Wallet/Trade Actions
Wallet/Trade Actions
Once user context and security context have been established via the Launch Sequence ( Steps 1, 2, 3), the user can perform trade actions that will affect his wallet, his balance..
opentrade options/1000x
The open-trade wallet action is a request to the External Wallet Provider to reserve or hold funds from the user’s wallet against a trade that is being opened. The open-trade call is made by the TS platform to the External Wallet Provider.
The request payload to the open-trade call is as follows (json):
Token: wallet access token from step 2
Amount: Amount that you need to hold or reserve from your user’s balance
Currency: Currency code
externalTradeType: gametype being played
externalTradeId: trade ID, register number of the trade in Tradesmarter’s system
hash: secure message digest for message authentications – See “Message Digest” further down for more info.
Your response should be as follows:
Payload: {"balance":"2180","currency":"USD","status":"Ok"}
Balance: new balance after trade opening
opentrade - Tap
Tap-only fields in data[0]:
tStart/tEnd— ISO-8601 UTC, ms precision.tEnd − tStartequals the tap size the user selected (2 / 4 / 8 s).pMin/pMax— the cell's price band.pMax − pMinis the σ-adaptive cell height TS chose for the instrument; partner treats it as opaque.payoutRatio— profit multiplier the user saw on screen at tap time. Locked; subsequent grid movement does not change this number.
Response: same as Options — { "balance": "990", "currency": "USD", "status": "Ok" }.
closetrade
With a trade open, the user can now close the trade manually or have the trade closed automatically (expire). The closetrade wallet action is a request to the External Wallet Provider to release funds from the user’s wallet against the trade that was made. The close-trade call update the External Wallet provide with information about the trade.
The request to the close-trade call is as follows:
Token: the token identifying the connection from step 2
Amount: The win amount . If the amount == 0 then it is a losing trade. If the amount > 0 then it is a winning trade. In more detail,
"in the money" outcome - winAPI amount is stake+payout.
"out of the money" outcome - winAPI amount is 0.
"at the money" outcome - winAPI amount is stake.
Data more data about trade, e.g.
"tradeID":"10189550",
"userID":"819335", (userID in our system)
"stake":"1.0000000000",
"payout":"90", (Payout percentage)
"rebate": "0", (optional discount )
"instrumentID": "139", (Id of the instrument traded)
"expiryPrice": "103336.623",
"pnl": "-1", (Profit or Loss)
"returnedAmount": "0" Amount returned to user’s balance. Always use Amount to update balance.}
Your response should be as follows:
Payload: {"balance":"2180","currency":"USD","status":"Ok"}
Balance: new balance after trade opening
getbalance
Before a trade is open in the TS system, your endpoint get-balance will be called. You must reply to this request with the current balance. TS will check if the balance is sufficient for the trade or not, and allow, respectively cancel the trade. This call will happen before you receive the open-trade call.
The payload to the getbalance API is as follows:
Token: the token identifying the connection from step 2
Amount: Amount needed for trade/bet
Your response should be as follows to approve trade:
Payload: {"balance":"2180","currency":"USD","status":"Ok"}
Balance: new balance after trade opening