get_market_transaction_data

Description

Retrieves all transactions for an algorithm.

Arguments

  • api_key
  • experiment_id

What should be tested is this: 1. an order should be submitted for a running and empty experiment_id 2. the transactions should be inspected. It should be verified that status='filled' orders are reflected with perfect accuracy in transactions

Simple Example

eid = 'test_market_order-'+str(uuid.uuid1())

## 1  Put some cash into this EID
transdat = pq.submit_transaction({
                                'experiment_id': eid,
                                'symbol': 'USDT',
                                'quantity': 1000000,
                                'value': 1000000,
                                'date':datetime.datetime.utcnow()-datetime.timedelta(days=1),
                                'unit_price': 1.0,
                                'account_currency': 'USDT',
                                'type': 'algorithm',
                                'note': "Initial Cash Deposit",
                                #'do_not_update_holdings':True,
                                'api_key':api_key},remote=True)
print(transdat )

from_symbol = 'USDT'
to_symbol = 'BTC'
to_quantity = 0.1
order_type = 'BUY'
#purchase_date = datetime.datetime.utcnow()-datetime.timedelta(days=1)
purchase_date = datetime.datetime(2020,4,1,10)
limit_date = purchase_date + datetime.timedelta(days=1)

dat = pq.submit_single_market_order({'from_symbol':from_symbol,
                            'to_symbol': to_symbol,
                            'to_quantity': to_quantity,
                            'experiment_id':eid,
                            'type': order_type,
                            'purchase_date':purchase_date,
                            'tag':"test submit",
                            #'limit_value': None,
                            'limit_date': limit_date,
                            'symbol_discovery':'BINANCE',                 
                            #'market_price':None,
                            #'avg_fill_price':None,
                            #'market_status':None,
                            #'status':'simulated',
                            #'transaction_fee':min([proceeds*0.005,0.01*proceeds])*2,
                            #'transaction_ids':transaction_ids}
                              })    
print(dat)



dat = pq.manage_experiment({'api_key':api_key,
                                    'current_date':purchase_date+datetime.timedelta(hours=1),
                                    'base_symbol':'USDT',
                                    'symbol_discovery':'BINANCE',
                                    'experiment_id':eid,},remote=True)
print(dat)

q = {'experiment_id':eid}
dat = pq.find_algorithm_single_orders(q,remote=True)
print(dat)

dat = pq.get_market_transaction_data({'api_key':api_key,'experiment_id':eid},remote=True)
print(dat)

holdings = {}
for tran in dat:
    if tran['symbol'] in holdings.keys():
        holdings[tran['symbol']] += tran['quantity']         
    else:
        holdings[tran['symbol']] = tran['quantity']

print(holdings)        
dat = pq.get_approx_holdings({'api_key':api_key,'experiment_id':eid},remote=True)
print(dat)

Simple Example Output

Failure Examples

only core case because it's a simple endpoint

Failure Examples Output

Three Examples

only core case because it's a simple endpoint

Three Examples Output