def createOpClient(opClient=opClient): if opClient is not None: return opClient opClient = oandapy.API(**Clients['oandapy']) return opClient
def __init__(self, granularity="M5", instrument="EUR_USD"): ''' Load the data from a oanda ''' self.oanda = oandapy.API(environment="practice", access_token="e53fd8cfdb5f5e58c15f0936ece50939-4431fd4def9be7d92abb7ede43738eb4") self.instrument = instrument self.granularity = granularity
def __init__(self, leverage, account): self.leverage = leverage self.account = account self.orders = [] self.profit = 0 # variables to analyze fx_data ''' All of the OCHL data uses the bid prices ''' self.open = [None] * 100 self.close = [None] * 100 self.high = [None] * 100 self.low = [None] * 100 self.volume = [None] * 100 self.oanda = oandapy.API( environment="practice", access_token= "e53fd8cfdb5f5e58c15f0936ece50939-4431fd4def9be7d92abb7ede43738eb4" ) self.accountID = 6774427
def __init__(self, currency_pair=None, access_token=None, *args, **kwargs): """ script : str Algoscript that contains initialize and handle_data function definition. """ # just one pair for now self.currency_pair = currency_pair self.oanda_client = oandapy.API( environment="practice", access_token= "b47aa58922aeae119bcc4de139f7ea1e-27de2d1074bb442b4ad2fe0d637dec22" ) self.algoscript = kwargs.pop('script', None) self.data = self.oanda_client.get_prices( instruments=self.currency_pair) self.account_id = 3922748 self.history_data = self.oanda_client.get_history( instrument=self.currency_pair, granularity="S5", count=500, candleFormat="midpoint") if self.algoscript is not None: self.ns = {} exec(self.algoscript, self.ns) if 'initialize' not in self.ns: raise ValueError('You must define an initialze function.') if 'handle_data' not in self.ns: raise ValueError('You must define a handle_data function.') self._initialize = self.ns['initialize'] self._handle_data = self.ns['handle_data']
mysql_connector = MysqlConnector() now = datetime.now() start_time = "2017-01-04 07:00:00" end_time = "2018-05-19 00:00:00" end_time = datetime.strptime(end_time, "%Y-%m-%d %H:%M:%S") start_time = datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S") sql_file = open("%s_record.sql" % instrument, "w") while start_time < end_time: if decideMarket(start_time): start_ftime = start_time - timedelta(hours=9) start_ftime = start_ftime.strftime("%Y-%m-%dT%H:%M:%S") oanda = oandapy.API(environment=env, access_token=token) response = {} try : response = oanda.get_history( instrument=instrument, start=start_ftime, granularity="S5" ) except ValueError as e: print(e) if len(response) > 0: instrument = response["instrument"] candles = response["candles"] for candle in candles: time = candle["time"]
cmd_subfolder = os.path.realpath( os.path.abspath(os.path.join(os.path.split(inspect.getfile(inspect.currentframe()))[0], '..', module_folder))) if cmd_subfolder not in sys.path: sys.path.insert(0, cmd_subfolder) insertModule('Constants') insertModule('DataProviderAccess') insertModule('Passwords') import Passwords import Constants # import Constants.Constants as Constants OANDA = oandapy.API(environment="live", access_token=Passwords.accessTokenOanda) accounts = OANDA.get_accounts() accounts['accounts'][0]['accountId'] M1 = 'M1' M2 = 'M2' M3 = 'M3' M4 = 'M5' M15 = 'M15' M30 = 'M30' H1 = 'H1' D = 'D' W = 'W' granularities = ['M1', 'M2', 'M3', 'M4', 'M15', 'M30', 'H1', 'D', 'W']
Created on Tue Sep 26 11:08:08 2017 @author: Guanwen """ from oandapy import oandapy import numpy as np import time import pandas as pd domain = "https://api-fxtrade.oanda.com/" token = 'c3c619b83a1f631c1f2f6ce18b8304ed-f0c89f28c64d1e0561b07b9fd3f00903' account_id = '5640873' filename = 'KF_Params.csv' oanda = oandapy.API(environment="practice", access_token=token) positions = False inti_params = pd.DataFrame.from_csv(filename) G0 = np.matrix(np.eye(2)) W0 = np.matrix(np.eye(2)) * 0.00000001 Vdelta = 0.98 C0 = np.matrix([[0.7843, -0.6350], [-0.6350, 0.5147]]) * 0.0001 m0 = np.matrix([0.5625, 0.3403]).T d0 = 1.2675e-05 n0 = 50 S0 = d0 / n0 while (True):
def __init__(self, env, account_id, token, units): self.oanda = oandapy.API(environment=env, access_token=token) self.account_id = account_id self.units = units
''' Created on 24/11/2014 @author: s103451 ''' from oandapy import oandapy import json oanda = oandapy.API( environment="practice", access_token= "e53fd8cfdb5f5e58c15f0936ece50939-4431fd4def9be7d92abb7ede43738eb4") # accountId = 6774427 #print json.dumps(oanda.get_account(6774427), indent=1) fxData = oanda.get_history(instrument="EUR_USD", count=2) print json.dumps(fxData, indent=1)
''' Created on 09/12/2014 @author: Sabrije ''' import json import talib import numpy as np from oandapy import oandapy import math oandaAC = oandapy.API( environment="practice", access_token= "657af47e3c2b562c6baae594e407a961-60cf041ddb3bc253b4c23acb23794f1e") #print json.dumps(oandaAC.get_accounts(), indent=1) accountId = oandaAC.get_accounts() print accountId["accounts"][0]["accountId"]