-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto-script.py
More file actions
117 lines (102 loc) · 4.59 KB
/
auto-script.py
File metadata and controls
117 lines (102 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 23 19:57:14 2019
@author: ben94
"""
import cbpro
import time
""" Paste your cbpro API keys into the below variables """
cbpro_apikey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
cbpro_secret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
cbpro_passphrase = 'your_passphrase'
""" Paste your bank account id into the funding_id variable.
Input the deposit amount that should be requested every time this function
is run. The account id should be in quotes, the deposit amount should not.
The deposit will initiate you run (or test) the function unless you set
the initiate_deposit_when_run variable to False.
Minimum coinbase deposit is $10. Remember deposits on coinbase can take
10 days, so purchases may fail the first time this runs unless you already
have USD in your coinbase pro account.
"""
initiate_deposit_when_run = True
funding_id = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
deposit_amount = 100.00
"""Now tell the function which and how much of each crypto to buy.
Set True/False for each variable and set the amount of each to buy.
The default will buy $10 of bitcoin and nothing else."""
buys = {}
buys['BTC-USD'] = {'buy': True, 'amount': 30.00}
buys['ETH-USD'] = {'buy': True, 'amount': 10.00}
buys['SHIB-USD'] = {'buy': True, 'amount': 10.00}
buys['QNT-USD'] = {'buy': True, 'amount': 10.00}
buys['DOGE-USD'] = {'buy': True, 'amount': 10.00}
buys['LINK-USD'] = {'buy': True, 'amount': 10.00}
buys['SOL-USD'] = {'buy': True, 'amount': 10.00}
buys['XLM-USD'] = {'buy': True, 'amount': 10.00}
buys['LTC-USD'] = {'buy': False, 'amount': 0.00}
"""You can have the purchases you just made immediately withdrawn to your
own wallets. Set the True/False variable and input your wallet on the
address line. """
withdraws = {}
withdraws['BTC-USD'] = {'withdraw': False,
'address': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'base': 'BTC'}
withdraws['ETH-USD'] = {'withdraw': False,
'address': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'base': 'ETH'}
withdraws['SHIB-USD'] = {'withdraw': False,
'address': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'base': 'SHIB'}
withdraws['QNT-USD'] = {'withdraw': False,
'address': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'base': 'QNT'}
withdraws['LINK-USD'] = {'withdraw': False,
'address': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'base': 'LINK'}
withdraws['SOL-USD'] = {'withdraw': False,
'address': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'base': 'SOL'}
withdraws['DOGE-USD'] = {'withdraw': False,
'address': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'base': 'DOGE'}
withdraws['XLM-USD'] = {'withdraw': False,
'address': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'base': 'XLM'}
withdraws['LTC-USD'] = {'withdraw': False,
'address': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'base': 'LTC'}
""" Don't modify anything under this line """
cbpro_api = cbpro.AuthenticatedClient(cbpro_apikey,
cbpro_secret,
cbpro_passphrase)
print(cbpro_api)
def automated_purchase():
# Initiate a deposit ACH from your bank
if initiate_deposit_when_run:
dep_request = cbpro_api.deposit(amount=deposit_amount,
currency='USD',
payment_method_id=funding_id)
time.sleep(2)
print(dep_request)
# make purchases
for key in buys.keys():
if buys[key]['buy'] is True:
order = cbpro_api.place_market_order(product_id=key,
side='buy',
funds=buys[key]['amount'])
time.sleep(2)
print(order)
order_details = cbpro_api.get_order(order['id'])
print(order_details)
qty = float(order_details['filled_size'])
withdraws[key]['qty'] = qty
for key in withdraws.keys():
if withdraws[key]['withdraw'] is True:
withdraw = cbpro_api.crypto_withdraw(amount=withdraws[key]['qty'],
currency=withdraws[key]['base'],
crypto_address=withdraws[key]['address'])
def main():
automated_purchase()
if __name__ == "__main__":
main()