Update and rename Leo_Even_Odd.xml to LeoclassEven_Odd.xml#7
Open
Kingsleycoman254 wants to merge 1 commit intoDerivBots:mainfrom
Open
Update and rename Leo_Even_Odd.xml to LeoclassEven_Odd.xml#7Kingsleycoman254 wants to merge 1 commit intoDerivBots:mainfrom
Kingsleycoman254 wants to merge 1 commit intoDerivBots:mainfrom
Conversation
import requests # API endpoint URLs API_BASE_URL = "https://trade.deriv.com/api/" AUTH_ENDPOINT = API_BASE_URL + "oauth2/token" TRADE_ENDPOINT = API_BASE_URL + "trading/v3/order" # Your API credentials CLIENT_ID = "your_client_id" CLIENT_SECRET = "your_client_secret" GRANT_TYPE = "client_credentials" # Authenticate def authenticate(): data = { "grant_type": GRANT_TYPE, "client_id": CLIENT_ID, "client_secret": CLIENT_SECRET } response = requests.post(AUTH_ENDPOINT, data=data) return response.json() # Place trade def place_trade(token, symbol, amount, contract_type): headers = {"Authorization": f"Bearer {token}"} data = { "amount": amount, "symbol": symbol, "type": contract_type } response = requests.post(TRADE_ENDPOINT, headers=headers, json=data) return response.json() # Example usage if __name__ == "__main__": auth_response = authenticate() access_token = auth_response["access_token"] # Place trades using the access_token # Example: place_trade(access_token, "even", 100, "CALL")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
import requests
API endpoint URLs
API_BASE_URL = "https://trade.deriv.com/api/"
AUTH_ENDPOINT = API_BASE_URL + "oauth2/token"
TRADE_ENDPOINT = API_BASE_URL + "trading/v3/order"
Your API credentials
CLIENT_ID = "your_client_id"
CLIENT_SECRET = "your_client_secret"
GRANT_TYPE = "client_credentials"
Authenticate
def authenticate():
data = {
"grant_type": GRANT_TYPE,
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET
}
response = requests.post(AUTH_ENDPOINT, data=data)
return response.json()
Place trade
def place_trade(token, symbol, amount, contract_type):
headers = {"Authorization": f"Bearer {token}"}
data = {
"amount": amount,
"symbol": symbol,
"type": contract_type
}
response = requests.post(TRADE_ENDPOINT, headers=headers, json=data)
return response.json()
Example usage
if name == "main":
auth_response = authenticate()
access_token = auth_response["access_token"]
# Place trades using the access_token
# Example: place_trade(access_token, "even", 100, "CALL")