Added remaining trading system around portfolio in order to compare with OANDA.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import httplib
|
||||
import urllib
|
||||
|
||||
|
||||
class Execution(object):
|
||||
def __init__(self, domain, access_token, account_id):
|
||||
self.domain = domain
|
||||
self.access_token = access_token
|
||||
self.account_id = account_id
|
||||
self.conn = self.obtain_connection()
|
||||
|
||||
def obtain_connection(self):
|
||||
return httplib.HTTPSConnection(self.domain)
|
||||
|
||||
def execute_order(self, event):
|
||||
headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Authorization": "Bearer " + self.access_token
|
||||
}
|
||||
params = urllib.urlencode({
|
||||
"instrument" : event.instrument,
|
||||
"units" : event.units,
|
||||
"type" : event.order_type,
|
||||
"side" : event.side
|
||||
})
|
||||
self.conn.request(
|
||||
"POST",
|
||||
"/v1/accounts/%s/orders" % str(self.account_id),
|
||||
params, headers
|
||||
)
|
||||
response = self.conn.getresponse().read()
|
||||
print response
|
||||
|
||||
Reference in New Issue
Block a user