Skip to content

It seems no document about the v20.functions #30

Description

@david03kimo

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions