Client that connects to sandbox API. Relies on authentication information provided in api_config.json
()
| 41 | |
| 42 | @pytest.fixture(scope='module') |
| 43 | def client(): |
| 44 | """Client that connects to sandbox API. Relies on authentication information |
| 45 | provided in api_config.json""" |
| 46 | with open('api_config.json.example') as file: |
| 47 | api_config = json.load(file) |
| 48 | c = AuthenticatedClient( |
| 49 | api_url='https://api-public.sandbox.pro.coinbase.com', **api_config) |
| 50 | |
| 51 | # Set up account with deposits and orders. Do this by depositing from |
| 52 | # the Coinbase USD wallet, which has a fixed value of > $10,000. |
| 53 | # |
| 54 | # Only deposit if the balance is below some nominal amount. The |
| 55 | # exchange seems to freak out if you run up your account balance. |
| 56 | coinbase_accounts = c.get_coinbase_accounts() |
| 57 | account_info = [x for x in coinbase_accounts |
| 58 | if x['name'] == 'USD Wallet'][0] |
| 59 | account_usd = account_info['id'] |
| 60 | if float(account_info['balance']) < 70000: |
| 61 | c.coinbase_deposit(10000, 'USD', account_usd) |
| 62 | # Place some orders to generate history |
| 63 | c.place_limit_order('BTC-USD', 'buy', 1, 0.01) |
| 64 | c.place_limit_order('BTC-USD', 'buy', 2, 0.01) |
| 65 | c.place_limit_order('BTC-USD', 'buy', 3, 0.01) |
| 66 | |
| 67 | return c |
| 68 | |
| 69 | |
| 70 | @pytest.mark.usefixtures('dc') |
nothing calls this directly
no test coverage detected