Added remaining trading system around portfolio in order to compare with OANDA.

This commit is contained in:
Michael Halls-Moore
2015-02-03 13:33:33 +00:00
parent dbc973567a
commit b0b19d603d
13 changed files with 255 additions and 15 deletions
View File
+33
View File
@@ -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