submit_transaction

Description

Performs a transaction crediting a quantity of a given security to the experiment's holdings.

Arguments

experiment_id : str

  • the experiment ID under which the transaction is to be submitted

symbol: str

  • the ticker symbol for the security

quantity: number

  • the number of units of the security to be credited to the account

value: number

  • the value of the security credited to the account

date: datetime

  • the simulated datetime at which the transaction is to be performed

unit_price: number

  • the price of one unit of the security

account_currency: str

  • the currrency of the account

type: str

  • transaction type. Defaults to 'algorithm'.

note: str

  • notes the user may wish to make to themself

api_key: str

  • a valid API key

Simple Example

transdat = pq.submit_transaction({
                                'experiment_id': 'test_market_order',
                                'symbol': 'USDT',
                                'quantity': 1000000,
                                'value': 1000000,
                                'date':'2020-04-01T10:00:00',
                                'unit_price': 1.0,
                                'account_currency': 'USDT',
                                'type': 'algorithm',
                                'note': "Initial Cash Deposit",
                                'api_key':api_key},remote=True)
print(transdat)

Simple Example Output

{'transaction_id': 't-f3d60b72-ea2d-4861-a6bf-addeb8f1be7d', 'quantity': '1000000', 'symbol': 'USDT'}

Failure Examples

# no symbol

transdat = pq.submit_transaction({
                                'experiment_id': eid,
                                #'symbol': 'USDT',
                                'quantity': 1000000,
                                'value': 1000000,
                                'date': '2020-04-01T10:00:00',
                                'unit_price': 1.0,
                                'account_currency': 'USDT',
                                'type': 'algorithm',
                                'note': "Initial Cash Deposit",
                                'api_key':api_key},remote=True)
print(transdat)

Failure Examples Output

  File "/mnt/dev/dev/FinancialAlgorithm/FinancialProcessQueries.py", line 1061, in do_input
    assert 'symbol' in transaction and not transaction['symbol'] == None

Traceback (most recent call last):
  File "/tmp/tmpvzf_jc0q.py", line 194, in process_record
  File "/mnt/dev/dev/paxdk/PaxFinancialAPI.py", line 268, in query
    return_dict =  self.query_debug(filter,source_id)
  File "/mnt/dev/dev/paxdk/PaxFinancialAPI.py", line 250, in query_debug
    res = self.query_objects[source_id].process(filter)
  File "/mnt/dev/dev/processingNetwork/ProcessingNetwork.py", line 159, in process
    feature = self.instanceMap[instanceName].process(feature,self.lastFeature)
  File "/mnt/dev/dev/processingNetwork/ProcessingNode.py", line 65, in process
    self.dependencies[k].process(feature)
  File "/mnt/dev/dev/processingNetwork/ProcessingNode.py", line 90, in process
    raise e
  File "/mnt/dev/dev/processingNetwork/ProcessingNode.py", line 83, in process
    feature[self.settings['name']] =  self.do_process(features,self.settings)
  File "/mnt/dev/dev/processingNetwork/ProcessingNode.py", line 173, in do_process
    raise e
  File "/mnt/dev/dev/processingNetwork/ProcessingNode.py", line 165, in do_process
    return self.do_input(features['input'],settings)
  File "/mnt/dev/dev/FinancialAlgorithm/FinancialProcessQueries.py", line 1061, in do_input
    assert 'symbol' in transaction and not transaction['symbol'] == None
AssertionError

Three Examples

# load with AAPL
transdat = pq.submit_transaction({
                                'experiment_id': eid,
                                'symbol': 'AAPL',
                                'quantity': 1000,
                                'value': 500*1000,
                                'date': '2020-04-01T10:00:00',
                                'unit_price': 500.0,
                                'account_currency': 'USDT',
                                'type': 'algorithm',
                                'note': "Initial Cash Deposit",
                                'api_key':api_key},remote=True)
print(transdat)


# no second or third examples at this time

Three Examples Output

 {'transaction_id': 't-6f581c14-7673-4b0a-8233-f794ef97c68d', 'quantity': '1000', 'symbol': 'AAPL'}