Exemple #1
0
 def __init__(self, environment, acces_token, account_number):
     self.account_number = account_number
     self.environment = environment
     self.acces_token = acces_token
     self.oanda = oandapy.APIv20(environment=self.environment,
                                 access_token=self.acces_token)
Exemple #2
0
    acces_token = "ecd553338b9feac1bb350924e61329b7-0d7431f8a1a13bddd6d5880b7e2a3eea"
else:
    account = "001-004-2840244-004"
    environment = "live"
    acces_token = "db81a15dc77b29865aac7878a7cb9270-6cceda947c717f9471b5472cb2c2adbd"

daily_risk_limit = 0.10

#Starting balance
if args.st_bal == None:
    raise Exception("Starting balance was not given! Use starting balance.")
else:
    risk_ammount = float(args.st_bal) * daily_risk_limit

# Creating an Oanda object
oanda = oandapy.APIv20(environment=environment, access_token=acces_token)

a = oanda.account.get_account(account_id=account).as_dict()

# Account balance data
daily_opening_balance = float(a["account"]["balance"])
nav = float(a["account"]["NAV"])
unrealized_pnl = float(a["account"]["unrealizedPL"])
unrealized_return = round(unrealized_pnl / daily_opening_balance, 3)

print("-----------------------------------")
print("          TRADE EXECUTION          ")
print("-----------------------------------")
print("Environment:", environment)
print("Opening Balance:", float(args.st_bal))
print("Daily Risk Ammount:", risk_ammount)
Exemple #3
0
import configparser
import oandapy as opy
import pandas as pd
import json
import oandapyV20
import oandapyV20.endpoints.accounts as accounts
from exampleauth import exampleauth

config = configparser.ConfigParser()
config.read('../config/oanda.cfg')

oanda = opy.APIv20(environment='practice',
                access_token=config['oanda']['access_token'])

data = oanda.get_history(instrument='EUR_USD',  # our instrument
                         start='2016-12-08',  # start data
                         end='2016-12-10',  # end date
                         granularity='M1')

print(data)
Exemple #4
0
 def __init__(self, environment, acces_token, account_number):
     self.account_number = account_number
     self.oanda = oandapy.APIv20(environment=environment,
                                 access_token=acces_token)
     print("Oanda instance creation is successful")