-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloc_bittrex_v3.py
More file actions
2277 lines (1912 loc) · 60.7 KB
/
loc_bittrex_v3.py
File metadata and controls
2277 lines (1912 loc) · 60.7 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Developed from the Original Work of Eric Somdahl @ https://raw.githubusercontent.com/ericsomdahl/python-bittrex/master/bittrex/bittrex.py
Many Clues Gleemed from Severino Mizael @ https://stackoverflow.com/questions/62139890/bittrex-rest-api-v3-python-post-orders-invalid-content-hash
See https://bittrex.github.io/api/v3
"""
################################################################################
# Imports #
################################################################################
import decimal
import hashlib
import hmac
import json
import requests
import sys
import time
import winsound
#import urllib.parse
################################################################################
# Local Imports #
################################################################################
from lib_secrets import secrets
try:
from urllib import urlencode
except ImportError:
from urllib.parse import urlencode
try:
from Crypto.Cipher import AES
except ImportError:
encrypted = False
else:
import getpass
import ast
import json
encrypted = True
################################################################################
# External Local Imports #
################################################################################
################################################################################
# Variables #
################################################################################
lib_display_lvl = 0
lib_debug_lvl = 0
TRADE_FEE = 0.0025
################################################################################
# Code #
################################################################################
#<=====>#
def beep(debug_lvl=lib_debug_lvl):
frequency = 2500 # Set Frequency To 2500 Hertz
duration = 1000 # Set Duration To 1000 ms == 1 second
winsound.Beep(frequency, duration)
#<=====>#
def dec(val):
if val is None:
val = 0
else:
val = decimal.Decimal(str(val))
return val
#<=====>#
def encrypt(api_key, api_secret, export=True, export_fn='settings/secrets.json'):
print('def encrypt')
cipher = AES.new(getpass.getpass(
'Input encryption password (string will not show)'))
api_key_n = cipher.encrypt(api_key)
api_secret_n = cipher.encrypt(api_secret)
api = {'key': str(api_key_n), 'secret': str(api_secret_n)}
if export:
with open(export_fn, 'w') as outfile:
json.dump(api, outfile)
return api
#<=====>#
def forex_pair(tp):
c1 = tp.split('-')[0]
c2 = tp.split('-')[1]
if tp == 'USD-BTC':
tp = 'BTC-USD'
mc = 'USD'
tc = 'BTC'
elif tp == 'BTC-USD':
tp = 'BTC-USD'
mc = 'USD'
tc = 'BTC'
elif tp == 'USDT-BTC':
tp = 'BTC-USDT'
mc = 'USDT'
tc = 'BTC'
elif tp == 'USDT-BTC':
tp = 'BTC-USDT'
mc = 'USDT'
tc = 'BTC'
elif tp == 'BTC-ETH':
tp = 'ETH-BTC'
mc = 'BTC'
tc = 'ETH'
elif tp == 'ETH-BTC':
tp = 'ETH-BTC'
mc = 'BTC'
tc = 'ETH'
elif c1 in ('USD','USDT','BTC','ETH'):
tp = c2 + '-' + c1
mc = c1
tc = c2
else:
mc = c2
tc = c1
return tp, mc, tc
#<=====>#
class Bittrex3(object):
#<=====>#
def __init__(self, api_key, api_secret, calls_per_second=1, debug_lvl=lib_debug_lvl):
self.debug_lvl = debug_lvl
self.api_key = str(api_key) if api_key is not None else ''
self.api_secret = str(api_secret) if api_secret is not None else ''
self.call_rate = 1.0 / calls_per_second
self.last_call = None
#<=====>#
def decrypt(self):
if self.debug_lvl == 1: print('def Bittrex.decrypt')
if encrypted:
cipher = AES.new(getpass.getpass(
'Input decryption password (string will not show)'))
try:
if isinstance(self.api_key, str):
self.api_key = ast.literal_eval(self.api_key)
if isinstance(self.api_secret, str):
self.api_secret = ast.literal_eval(self.api_secret)
except Exception:
pass
self.api_key = cipher.decrypt(self.api_key).decode()
self.api_secret = cipher.decrypt(self.api_secret).decode()
else:
raise ImportError('"pycrypto" module has to be installed')
#<=====>#
def wait(self):
if self.debug_lvl == 1: print('def Bittrex.wait')
if self.last_call is None:
self.last_call = time.time()
else:
now = time.time()
passed = now - self.last_call
if passed < self.call_rate:
if self.debug_lvl == 1: print("sleep...")
time.sleep(self.call_rate - passed)
self.last_call = time.time()
#<=====>#
def urlbuild(self, opts):
firstYN = 'Y'
retstr = ''
optskeylist = list(opts.keys())
if opts:
for optskey in optskeylist:
if firstYN == 'Y':
firstYN = 'N'
retstr += '?'+ optskey + '=' + opts[optskey]
else:
retstr += '&'+ optskey + '=' + opts[optskey]
return retstr
#<=====>#
def fixpair(self, pair):
c1 = pair.split('-')[0]
c2 = pair.split('-')[1]
if pair == 'USD-BTC':
pair = 'BTC-USD'
elif pair == 'BTC-USD':
pair = 'BTC-USD'
elif pair == 'USDT-BTC':
pair = 'BTC-USDT'
elif pair == 'USDT-BTC':
pair = 'BTC-USDT'
elif pair == 'BTC-ETH':
pair = 'ETH-BTC'
elif pair == 'ETH-BTC':
pair = 'ETH-BTC'
elif c1 in ('USD','USDT','BTC','ETH'):
pair = c2 + '-' + c1
return pair
#<=====>#
def _public_api_query(self, sub_path=None, options=None):
"""
Queries Bittrex
:param request_url: fully-formed URL to request
:type options: dict
:return: JSON response from Bittrex
:rtype : dict
"""
if not options: options = {}
request_url = 'https://api.bittrex.com/v3{path}?'
request_url = request_url.format(path=sub_path)
request_url += urlencode(options)
try:
apisign = hmac.new(self.api_secret.encode(), request_url.encode(), hashlib.sha512).hexdigest()
self.wait()
except Exception:
error_handler("unknown", [], True)
logger.exception(Exception)
exit()
r = requests.get(request_url, headers={"apisign": apisign}, timeout=10)
resp = {}
resp["success"] = True
resp["message"] = "''"
resp["result"] = {}
resp["status_code"] = r.status_code
if r.status_code in (200,201,202,204):
resp["success"] = True
else:
resp["success"] = False
try:
data = r.json()
resp["result"] = data
except Exception:
print(r)
print(Exception)
exit()
return resp
#<=====>#
def _private_api_query(self, http_meth, sub_path, options=None):
api_key = self.api_key
api_timestamp = str(int(time.time() * 1000))
payload = ''
if http_meth == 'GET':
if options and options != '':
# request_url = "https://api.bittrex.com/v3" + str(sub_path) + str('?') + str(urllib.parse.urlencode(options))
request_url = "https://api.bittrex.com/v3" + str(sub_path) + self.urlbuild(options)
else:
request_url = "https://api.bittrex.com/v3" + str(sub_path)
elif http_meth == "HEAD":
request_url = "https://api.bittrex.com/v3" + str(sub_path)
payload = ''
elif http_meth == "POST":
request_url = "https://api.bittrex.com/v3" + str(sub_path)
payload = json.dumps(options)
elif http_meth == "DELETE":
if options:
delete_key = list(options.values())[0]
else:
delete_key = ''
request_url = "https://api.bittrex.com/v3" + str(sub_path) + str('/') + delete_key
payload = ''
else:
request_url = "https://api.bittrex.com/v3" + str(sub_path)
payload = ''
contentHash = hashlib.sha512(payload.encode()).hexdigest()
pre_sign = api_timestamp + request_url + http_meth + contentHash
signature = hmac.new(self.api_secret.encode(), pre_sign.encode(), hashlib.sha512).hexdigest()
headers = {
'Api-Key': api_key,
'Api-Timestamp': api_timestamp,
'Api-Content-Hash': contentHash,
'Api-Signature': signature,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
if http_meth == 'GET':
r = requests.get(url = request_url, params = payload, headers = headers)
if http_meth == 'HEAD':
r = requests.get(url = request_url, params = payload, headers = headers)
elif http_meth == "POST":
r = requests.post(url = request_url, data=json.dumps(options), headers = headers)
elif http_meth == "DELETE":
r = requests.delete(url = request_url, headers = headers)
else:
r = requests.get(url = request_url, params = payload, headers = headers)
# Property/Method Description
# --------------------------------------------------------------------------------------------------------------------------------
# apparent_encoding Returns the apparent encoding
# close() Closes the connection to the server
# content Returns the content of the response, in bytes
# cookies Returns a CookieJar object with the cookies sent back from the server
# elapsed Returns a timedelta object with the time elapsed from sending the request to the arrival of the response
# encoding Returns the encoding used to decode r.text
# headers Returns a dictionary of response headers
# history Returns a list of response objects holding the history of request (url)
# is_permanent_redirect Returns True if the response is the permanent redirected url, otherwise False
# is_redirect Returns True if the response was redirected, otherwise False
# iter_content() Iterates over the response
# iter_lines() Iterates over the lines of the response
# json() Returns a JSON object of the result (if the result was written in JSON format, if not it raises an error)
# links Returns the header links
# next Returns a PreparedRequest object for the next request in a redirection
# ok Returns True if status_code is less than 200, otherwise False
# raise_for_status() If an error occur, this method returns a HTTPError object
# reason Returns a text corresponding to the status code
# request Returns the request object that requested this response
# status_code Returns a number that indicates the status (200 is OK, 404 is Not Found)
# text Returns the content of the response, in unicode
# url Returns the URL of the response
resp = {}
resp["success"] = True
resp["message"] = "''"
resp["result"] = {}
resp["status_code"] = r.status_code
if r.status_code in (200,201,202,204):
# if r.status_code ==200: print('200 - OK')
# if r.status_code ==201: print('201 - Created')
# if r.status_code ==202: print('202 - Accepted')
# if r.status_code ==203: print('204 - No Contest')
resp["success"] = True
else:
if r.status_code ==400:
print('400 - Bad Request - The request was malformed, often due to a missing or invalid parameter. See the error code and response data for more details.')
if r.status_code ==401:
print('401 - Unauthorized - The request failed to authenticate (example: a valid api key was not included in your request header)')
if r.status_code ==403 and 'address' not in request_url:
print('request_url : ' + request_url)
print('403 - Forbidden - The provided api key is not authorized to perform the requested operation (example: attempting to trade with an api key not authorized to make trades)')
if r.status_code ==404:
print('404 - Not Found - The requested resource does not exist.')
if r.status_code ==409:
print('409 - Conflict - The request parameters were valid but the request failed due to an operational error. (example: INSUFFICIENT_FUNDS)')
if r.status_code ==429:
print('429 - Too Many Requests - Too many requests hit the API too quickly. Please make sure to implement exponential backoff with your requests.')
if r.status_code ==501:
print('501 - Not Implemented - The service requested has not yet been implemented.')
if r.status_code ==503:
print('503 - Service Unavailable - The request parameters were valid but the request failed because the resource is temporarily unavailable (example: CURRENCY_OFFLINE)')
resp["success"] = False
# print(r)
try:
data = r.json()
resp["result"] = data
except Exception:
print(r)
print(Exception)
exit()
return resp
# HTTP Status Codes
# Status Code Description
# 200 (OK)
# 201 (Created)
# 202 (Accepted)
# 204 (No Content)
# 400 - Bad Request The request was malformed, often due to a missing or invalid parameter. See the error code and response data for more details.
# 401 - Unauthorized The request failed to authenticate (example: a valid api key was not included in your request header)
# 403 - Forbidden The provided api key is not authorized to perform the requested operation (example: attempting to trade with an api key not authorized to make trades)
# 404 - Not Found The requested resource does not exist.
# 409 - Conflict The request parameters were valid but the request failed due to an operational error. (example: INSUFFICIENT_FUNDS)
# 429 - Too Many Requests Too many requests hit the API too quickly. Please make sure to implement exponential backoff with your requests.
# 501 - Not Implemented The service requested has not yet been implemented.
# 503 - Service Unavailable The request parameters were valid but the request failed because the resource is temporarily unavailable (example: CURRENCY_OFFLINE)
#<=====>#
### Works
def pub_get_ping_v3(self):
"""
Pings the service
3.0 GET https://api.bittrex.com/v3/ping
Example Response:
{'success': True,
'message': '',
'result': [
{
"serverTime": "integer (int64)"
}
]
}
"""
return self._public_api_query(sub_path = '/ping')
#<=====>#
### Works
def pub_get_currencies_v3(self, currencySymbol=None):
"""
List currencies.
3.0 GET https://api.bittrex.com/v3/currencies
3.0 GET https://api.bittrex.com/v3/currencies/{currencySymbol}
Parameters
currencySymbol: string
optional
in path
symbol of the currency to retrieve the deposit address for
Example Response:
{'success': True,
'message': '',
'result': [
{
"symbol": "string",
"name": "string",
"coinType": "string",
"status": "string",
"minConfirmations": "integer (int32)",
"notice": "string",
"txFee": "number (double)",
"logoUrl": "string",
"prohibitedIn": [
"string"
]
},
....
]
}
"""
if currencySymbol == None:
path = '/currencies'
else:
path = '/currencies/' + currencySymbol
return self._public_api_query(sub_path = path)
#<=====>#
### Works
def pub_get_markets_v3(self, marketSymbol=None):
"""
List markets.
Retrieve information for a specific market.
3.0 GET https://api.bittrex.com/v3/markets
3.0 GET https://api.bittrex.com/v3/markets/{marketSymbol}
Example Response:
{'success': True,
'message': '',
'result': [
{
"symbol": "string",
"baseCurrencySymbol": "string",
"quoteCurrencySymbol": "string",
"minTradeSize": "number (double)",
"precision": "integer (int32)",
"status": "string",
"createdAt": "string (date-time)",
"notice": "string",
"prohibitedIn": [
"string"
]
},
....
]
}
"""
if marketSymbol == None:
path = '/markets'
else:
path = '/markets/' + marketSymbol
return self._public_api_query(sub_path = path)
#<=====>#
### Works
def pub_get_markets_summaries_v3(self, marketSymbol=None):
"""
List summaries of the last 24 hours of activity for all markets.
Retrieve summary of the last 24 hours of activity for a specific market.
3.0 GET https://api.bittrex.com/v3/markets/summaries
3.0 GET https://api.bittrex.com/v3/markets/{marketSymbol}/summary
Example Response:
{'success': True,
'message': '',
'result': [
{
"symbol": "string",
"high": "number (double)",
"low": "number (double)",
"volume": "number (double)",
"quoteVolume": "number (double)",
"percentChange": "number (double)",
"updatedAt": "string (date-time)"
},
....
]
}
"""
if marketSymbol == None:
path = '/markets/summaries'
else:
path = '/markets/' + marketSymbol + '/summary'
return self._public_api_query(sub_path = path)
#<=====>#
### Works
def pub_get_markets_tickers_v3(self, marketSymbol=None):
"""
List tickers for all markets.
Retrieve the ticker for a specific market.
3.0 GET https://api.bittrex.com/v3/markets/tickers
3.0 GET https://api.bittrex.com/v3/markets/{marketSymbol}/ticker
Example Response:
{'success': True,
'message': '',
'result': [
{
"symbol": "string",
"lastTradeRate": "number (double)",
"bidRate": "number (double)",
"askRate": "number (double)"
},
....
]
}
"""
if marketSymbol == None:
path = '/markets/tickers'
else:
path = '/markets/' + marketSymbol + '/ticker'
return self._public_api_query(sub_path = path)
#<=====>#
### Works
def pub_get_markets_orderbook_v3(self, marketSymbol, depth):
"""
Retrieve the order book for a specific market.
3.0 GET https://api.bittrex.com/v3/markets/{marketSymbol}/orderbook
Parameters
marketSymbol: string
required
in path
symbol of market to retrieve order book for
depth: integer (int32)
in query
maximum depth of order book to return (optional, allowed values are [1, 25,
500], default is 25)
Example Response:
{'success': True,
'message': '',
'result': [
{
"bid": [
{
"quantity": "number (double)",
"rate": "number (double)"
},
....
],
"ask": [
{
"quantity": "number (double)",
"rate": "number (double)"
},
....
]
}
]
}
"""
path = '/markets/' + marketSymbol + '/orderbook'
return self._public_api_query(
sub_path = path
, options={
'depth' : depth
}
)
#<=====>#
### Works
def pub_get_markets_trades_v3(self, marketSymbol):
"""
Retrieve the recent trades for a specific market.
3.0 GET https://api.bittrex.com/v3/markets/{marketSymbol}/trades
Parameters
marketSymbol: string
required
in path
symbol of market to retrieve order book for
Example Response:
{'success': True,
'message': '',
'result': [
{
"id": "string (uuid)",
"executedAt": "string (date-time)",
"quantity": "number (double)",
"rate": "number (double)",
"takerSide": "string"
}
]
}
"""
path = '/markets/' + marketSymbol + '/trade'
return self._public_api_query(sub_path = path)
#<=====>#
### Works
def pub_get_markets_candles_v3(self, marketSymbol, candleInterval, yyyy = None, mm = None, dd = None):
"""
Retrieve recent candles for a specific market and candle interval. The
maximum age of the returned candles depends on the interval as follows:
(MINUTE_1: 1 day, MINUTE_5: 1 day, HOUR_1: 31 days, DAY_1: 366 days).
Candles for intervals without any trading activity are omitted.
3.0 GET https://api.bittrex.com/v3/markets/{marketSymbol}/candles/{candleInterval}/recent
3.0 GET https://api.bittrex.com/v3/markets/{marketSymbol}/candles/{candleInterval}/historical/{year}/{month}/{day}
Parameters
marketSymbol: string
required
in path
symbol of market to retrieve order book for
Example Response:
{'success': True,
'message': '',
'result': [
{
"startsAt": "string (date-time)",
"open": "number (double)",
"high": "number (double)",
"low": "number (double)",
"close": "number (double)",
"volume": "number (double)",
"quoteVolume": "number (double)"
},
....
]
}
"""
if yyyy == None or mm == None or dd == None:
path = '/markets/' + marketSymbol + '/candles/' + candleInterval + '/recent'
else:
path = '/markets/' + marketSymbol + '/candles/' + candleInterval + '/historical/' + yyyy + '/' + mm + '/' + dd
return self._public_api_query(sub_path = path)
#<=====>#
### Works
def prv_get_account_v3(self):
"""
Retrieve information for the account associated with the request.
For now, it only echoes the subaccount if one was specified in the header,
which can be used to verify that one is operating on the intended account.
More fields will be added later.
3.0 GET https://api.bittrex.com/v3/account
Example:
{'success': True,
'message': '',
'result': [
{
"subaccountId": "string (uuid)",
"accountId": "string (uuid)"
}
]
}
"""
return self._private_api_query(
http_meth = 'GET',
sub_path = '/account'
)
#<=====>#
### Works
def prv_get_account_volume_v3(self):
"""
Get 30 day volume for account
3.0 GET https://api.bittrex.com/v3/account/volume
Example Response:
{'success': True,
'message': '',
'result': [
{
"updated": "string (date-time)",
"volume30days": "number (double)"
}
]
}
"""
return self._private_api_query(
http_meth = 'GET',
sub_path = '/account/volume'
)
#<=====>#
### Works
def prv_get_addresses_v3(self, currencySymbol=None):
"""
List deposit addresses that have been requested or provisioned.
3.0 GET https://api.bittrex.com/v3/addresses
Example Response:
{'success': True,
'message': '',
'result': [
{
"status": "string",
"currencySymbol": "string",
"cryptoAddress": "string",
"cryptoAddressTag": "string"
}
]
}
"""
if currencySymbol == None:
path = '/addresses'
else:
path = '/addresses/' + currencySymbol
return self._private_api_query(
http_meth = 'GET',
sub_path = path
)
#<=====>#
### Works
def prv_post_addresses_v3(self, currencySymbol=None):
"""
Request provisioning of a deposit address for a currency for which no address has been requested or provisioned.
3.0 POST https://api.bittrex.com/v3/addresses
Parameters
currencySymbol: string
in body
Example Response:
{'success': True,
'message': '',
'result': [
{
"status": "string",
"currencySymbol": "string",
"cryptoAddress": "string",
"cryptoAddressTag": "string"
}
]
}
"""
opts = {}
if currencySymbol:
opts['currencySymbol'] = currencySymbol
return self._private_api_query(
http_meth = 'POST',
# sub_path = '/addresses/' + currencySymbol,
sub_path = '/addresses',
options=opts
)
#<=====>#
### Works
def prv_get_balances_v3(self, currencySymbol=None):
"""
3.0 GET https://api.bittrex.com/v3/balances
List account balances across available currencies. Returns a Balance entry
for each currency for which there is either a balance or an address.
3.0 GET https://api.bittrex.com/v3/balances/{currencySymbol}
List account balances across available currencies. Returns a Balance entry
for each currency for which there is either a balance or an address.
Example Response:
{'success': True,
'message': '',
'result': [
{
"currencySymbol": "string",
"total": "number (double)",
"available": "number (double)",
"updatedAt": "string (date-time)"
},
...
]
}
"""
if currencySymbol == None:
path = '/balances'
else:
path = '/balances/' + currencySymbol
return self._private_api_query(
http_meth = 'GET',
sub_path = path
)
#<=====>#
### Works
def prv_get_deposits_open_v3(self, status=None, currencySymbol=None):
"""
List open deposits. Results are sorted in inverse order of UpdatedAt, and are
limited to the first 1000.
3.0 GET https://api.bittrex.com/v3/deposits/open
Example Response:
{'success': True,
'message': '',
'result': [
{
"id": "string (uuid)",
"currencySymbol": "string",
"quantity": "number (double)",
"cryptoAddress": "string",
"cryptoAddressTag": "string",
"txId": "string",
"confirmations": "integer (int32)",
"updatedAt": "string (date-time)",
"completedAt": "string (date-time)",
"status": "string",
"source": "string"
},
....
]
}
"""
opts = {}
if status:
opts['status'] = status
if status:
opts['currencySymbol'] = currencySymbol
return self._private_api_query(
http_meth = 'GET',
sub_path = '/deposits/open',
options=opts
)
#<=====>#
### Works
def prv_get_deposits_closed_v3(self, status=None, currencySymbol=None, nextPageToken=None, prevPageToken=None, pageSize=None, startDate=None, endDate=None):
"""
List closed deposits. StartDate and EndDate filters apply to the CompletedAt
field. Pagination and the sort order of the results are in inverse order of
the CompletedAt field.
3.0 GET https://api.bittrex.com/v3/deposits/closed
Parameters
status: string COMPLETED, ORPHANED, INVALIDATED
in query
filter by deposit status (optional)
currencySymbol: string
in query
filter by currency (optional)
nextPageToken: string
in query
The unique identifier of the item that the resulting query result should
start after, in the sort order of the given endpoint. Used for traversing
a paginated set in the forward direction.
(Optional. May only be specified if PreviousPageToken is not specified.)
previousPageToken: string
in query
The unique identifier of the item that the resulting query result should
end before, in the sort order of the given endpoint. Used for traversing
a paginated set in the reverse direction.
(Optional. May only be specified if NextPageToken is not specified.)
pageSize: integer (int32)
in query
maximum number of items to retrieve -- default 100, minimum 1, maximum 200 (optional)
startDate: string (date-time)
in query
(optional) Filters out results before this timestamp. In ISO 8601 format
(e.g., "2019-01-02T16:23:45Z"). Precision beyond one second is not
supported. Use pagination parameters for more precise filtering.
endDate: string (date-time)
in query
(optional) Filters out result after this timestamp. Uses the same format
as StartDate. Either, both, or neither of StartDate and EndDate can be
set. The only constraint on the pair is that, if both are set, then
EndDate cannot be before StartDate.
Example Response:
{'success': True,
'message': '',
'result': [
{
"id": "string (uuid)",
"currencySymbol": "string",