def get_precision_digits(self, finsec): client = oandapyV20.API(access_token=self.token) r = accounts.AccountInstruments(accountID=self.account_id) rv = client.request(r) for line in rv['instruments']: if line['name'] == finsec: return line['displayPrecision']
def request_acc_instruments(self): client = oandapyV20.API(access_token=self.token) r = accounts.AccountInstruments(accountID=self.account_id) return client.request(r)
""" FX API wrapper """ from datetime import datetime from decimal import Decimal import boto3 from oandapyV20 import oandapyV20 import oandapyV20.endpoints.positions as positions import oandapy import v20 account_id = '' oanda = oandapy.API(environment="practice", access_token="") client = oandapyV20.API('') dynamodb = boto3.resource('dynamodb', region_name='us-east-2') dynamoTable = dynamodb.Table('trade_stats') api = v20.Context('api-fxpractice.oanda.com', '443', token='') def buy_order(inst, units, ticker): """ Places a buy order for FX with Oanda API :param inst: Instrument to buy :param units: Units to buy :param ticker: Ticker representation in Dynamo DB """ now = datetime.now() now_min = str("%s:%s.%s" % (now.hour, now.minute, now.second)) response = api.order.market(account_id, instrument=inst, units=units)
""" FX API wrapper """ from datetime import datetime import boto3 from decimal import Decimal from oandapyV20 import oandapyV20 import oandapyV20.endpoints.positions as positions import oandapy import v20 account_id = '101-004-8286259-001' oanda = oandapy.API( environment="practice", access_token= "8b5e8381818c621dc3b47f742c0e33b8-c04c9c6a3a7f5a066dbec1da5b0de23d") client = oandapyV20.API( '8b5e8381818c621dc3b47f742c0e33b8-c04c9c6a3a7f5a066dbec1da5b0de23d') dynamodb = boto3.resource('dynamodb', region_name='us-east-2') dynamoTable = dynamodb.Table('trade_stats') api = v20.Context( 'api-fxpractice.oanda.com', '443', token='8b5e8381818c621dc3b47f742c0e33b8-c04c9c6a3a7f5a066dbec1da5b0de23d') def buy_order(inst, units, ticker): """ Places a buy order for FX with Oanda API """ now = datetime.now() now_min = str("%s:%s.%s" % (now.hour, now.minute, now.second)) response = api.order.market(account_id, instrument=inst, units=units)