Search Docs…

Search Docs…

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 

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": token, 

            "amount":"100", 

            "currency": "USD", 

            "externalTradeType": "options", 

            "externalTradeId": "8461378", 

            "hash": "b0fc7d839d7b98fc639b01d9c63382ea", 

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 

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":"00a46aa6d048692344effc477a0b6381", 

    "amount":"100", 

    "currency": "USD", 

    "externalTradeType": "options", 

    "externalTradeId": "8461387", 

    "hash": "b0fc7d839d7b98fc639b01d9c63382ea", 

    “data”: more data about trade 

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":"00a46aa6d048692344effc477a0b6381", 

    "amount":"100", 

    "currency": "USD", 

    "hash": "b0fc7d839d7b98fc639b01d9c63382ea", 


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