Exemple #1
0
def get_transactions_range(_from):
    env = yaml.safe_load(open('/seq/seq3/configs/env.yaml', 'r'))
    accountid = env['accountid_long']
    client = oandapyV20.API(access_token=env['client'])
    params = {"from": _from, "to": _from + 500, 'type': 'ORDER_FILL'}
    r = trans.TransactionIDRange(accountID=accountid, params=params)
    client.request(r)
    return r.response
Exemple #2
0
def TransactionsTransactionIDRange(access_token,
                                   accountID,
                                   params=None):  # check
    'Get a range of Transactions for an Account based on Transaction IDs.'
    r = transactions.TransactionIDRange(accountID=accountID, params=params)
    client = API(access_token=access_token)
    client.request(r)
    return readable_output(Munch(r.response)), Munch(r.response)
Exemple #3
0
def get_transactions_range(_from, account):
    client = 'client=oandapyV20.API(access_token=env['client'])'
    client = oandapyV20.API(access_token=client)
    params = {"from": _from,
          "to": _from + 500,
          'type': 'ORDER_FILL'}
    r = trans.TransactionIDRange(accountID=account, params=params)
    client.request(r)
    return r.response
    def gettransaction(self, first, last):
        trans = transactions.TransactionIDRange(
            accountID=os.getenv('ACCOUNT_ID'),
            params={
                "from": first,
                "to": last
            })
        trans = self.client.request(trans)

        return trans
 def test__transactions_idrange(self, mock_get):
     """get the transactions by an idrange."""
     tid = "_v3_accounts_transaction_idrange"
     resp, data, params = fetchTestData(responses, tid)
     r = transactions.TransactionIDRange(accountID, params=params)
     mock_get.register_uri('GET',
                           "{}/{}".format(api.api_url, r),
                           text=json.dumps(resp))
     result = api.request(r)
     self.assertTrue(resp == r.response)
Exemple #6
0
    def gettransaction(self, first, last):
        trans = transactions.TransactionIDRange(
            accountID=env_workaround().return_env("ACCOUNT_ID"),
            params={
                "from": first,
                "to": last
            },
        )
        trans = self.client.request(trans)

        return trans
Exemple #7
0
    def transactions_list(self, _from, _to):

        params = {"from": _from, "to": _to, "pageSize": 1000}

        r = transactions.TransactionList(accountID=self.account_id,
                                         params=params)
        request_data = self.send_request(r)

        transactions_ids = request_data["pages"]

        if transactions_ids:
            start = transactions_ids[0].split("from=")[-1].split("&")[0]
            end = transactions_ids[-1].split("to=")[-1]

            params = {"from": int(start), "to": int(end)}

            r = transactions.TransactionIDRange(accountID=self.account_id,
                                                params=params)
            request_data = self.send_request(r)

            return request_data

        else:
            return []
Exemple #8
0
def transaction_ID_range(accountID, token, start, end):
    params = create_transaction_ID_range_data(start, end)
    client = oandapyV20.API(access_token=token)
    r = trans.TransactionIDRange(accountID=accountID, params=params)
    request = client.request(r)
    return request
Exemple #9
0
import oandapyV20.endpoints.transactions as transactions
from oandapyV20 import API
api = API(access_token="your_oanda_token_here", environment="practice")
params = {
    "from": "2020-03-10T00:00:00.000000000Z",
    "to": "2020-03-10T23:59:59.999999999Z"
}
accountID = "101-004-6618803-001"
r = transactions.TransactionList(accountID, params=params)
rv = api.request(r)
pages = rv["pages"]

start = pages[0].split("from=")[-1].split("&")[0]
end = pages[-1].split("to=")[-1]

params = {"to": int(end), "from": int(start)}

r = transactions.TransactionIDRange(accountID, params=params)
rv = api.request(r)

import json

with open("activity.json", "w") as rrr:
    json.dump(rv, rrr, indent=5)