You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cannot find the v20.functions documents beside cURL RESTful endpoints.But I preferred use v20.functions to trade.If I were wrong, please tell me.
I trial and error to summarize some:
import v20
#Place a market order:Market BUY EURUSD 10000 with stop loss 0.99332 and take profit 1.04718
ctx=v20.Context(
account_id, #just like 101-011-8XXXXX6-001
token='xxxxxxxxxxxxxxxxxxxxx', # get from Oanda website
)
response=ctx.order.market(
account_id,
instrument='EUR_USD',
units=10000,
type='MARKET',
side='BUY',
stopLossOnFill=v20.transaction.StopLossDetails(price=0.99332), # stop loss price
takeProfitOnFill=v20.transaction.TakeProfitDetails(price=1.04718). # take profit price
)
if response.status==201 and response.reason=='Created': # if success to place order
print(response.body['orderFillTransaction']) # check the response.body['orderFillTransaction']
print('id:',response.body['orderFillTransaction'].id) # print the order id
beside id, there's some information of order fulfillment.
I cannot find the v20.functions documents beside cURL RESTful endpoints.But I preferred use v20.functions to trade.If I were wrong, please tell me.
I trial and error to summarize some:
import v20
#Place a market order:Market BUY EURUSD 10000 with stop loss 0.99332 and take profit 1.04718
ctx=v20.Context(
account_id, #just like 101-011-8XXXXX6-001
token='xxxxxxxxxxxxxxxxxxxxx', # get from Oanda website
)
response=ctx.order.market(
account_id,
instrument='EUR_USD',
units=10000,
type='MARKET',
side='BUY',
stopLossOnFill=v20.transaction.StopLossDetails(price=0.99332), # stop loss price
takeProfitOnFill=v20.transaction.TakeProfitDetails(price=1.04718). # take profit price
)
if response.status==201 and response.reason=='Created': # if success to place order
print(response.body['orderFillTransaction']) # check the response.body['orderFillTransaction']
print('id:',response.body['orderFillTransaction'].id) # print the order id
beside id, there's some information of order fulfillment.
print('instrument:',response.body['orderFillTransaction'].instrument)
print('type:',response.body['orderFillTransaction'].type)
print('price:',response.body['orderFillTransaction'].price)
print('orderID:',response.body['orderFillTransaction'].orderID)
print('batchID:',response.body['orderFillTransaction'].batchID)
print('requestID:',response.body['orderFillTransaction'].requestID)
print('units:',response.body['orderFillTransaction'].units)
print('requestedUnits:',response.body['orderFillTransaction'].requestedUnits)
print('commission:',response.body['orderFillTransaction'].commission)
print('accountBalance:',response.body['orderFillTransaction'].accountBalance)
print('time:',response.body['orderFillTransaction'].time)
print('reason:',response.body['orderFillTransaction'].reason)
Hope to know more who trade by Oanda v20 API.
And hope more details of documents about the v20.
The text was updated successfully, but these errors were encountered: