1
- from poloniex .constants import POLONIEX_BUY_ORDER , POLONIEX_NUM_OF_DEAL_RETRY , POLONIEX_DEAL_TIMEOUT
1
+ from poloniex .constants import POLONIEX_BUY_ORDER
2
+ from poloniex .rest_api import generate_body , send_post_request_with_logging
2
3
3
4
from data_access .classes .post_request_details import PostRequestDetails
4
- from data_access .internet import send_post_request_with_header
5
- from data_access .memory_cache import generate_nonce
6
5
7
6
from debug_utils import print_to_console , LOG_ALL_MARKET_RELATED_CRAP , get_logging_level
8
7
9
8
from utils .file_utils import log_to_file
10
9
from utils .key_utils import signed_body
11
- from utils .string_utils import float_to_str
12
10
13
11
14
12
def add_buy_order_poloniex_url (key , pair_name , price , amount ):
15
- body = {
16
- "command" : "buy" ,
17
- "currencyPair" : pair_name ,
18
- "rate" : float_to_str (price ),
19
- "amount" : float_to_str (amount ),
20
- "nonce" : generate_nonce ()
21
- }
13
+ body = generate_body (pair_name , price , amount , "buy" )
22
14
23
15
headers = {"Key" : key .api_key , "Sign" : signed_body (body , key .secret )}
24
16
# https://poloniex.com/tradingApi
@@ -38,13 +30,7 @@ def add_buy_order_poloniex(key, pair_name, price, amount):
38
30
39
31
post_details = add_buy_order_poloniex_url (key , pair_name , price , amount )
40
32
41
- err_msg = "add_buy_order poloniex called for {pair} for amount = {amount} with price {price}" .format (pair = pair_name , amount = amount , price = price )
33
+ err_msg = "add_buy_order poloniex called for {pair} for amount = {amount} with price {price}" .format (
34
+ pair = pair_name , amount = amount , price = price )
42
35
43
- res = send_post_request_with_header (post_details , err_msg ,
44
- max_tries = POLONIEX_NUM_OF_DEAL_RETRY , timeout = POLONIEX_DEAL_TIMEOUT )
45
-
46
- if get_logging_level () >= LOG_ALL_MARKET_RELATED_CRAP :
47
- print_to_console (res , LOG_ALL_MARKET_RELATED_CRAP )
48
- log_to_file (res , "market_utils.log" )
49
-
50
- return res
36
+ return send_post_request_with_logging (post_details , err_msg )
0 commit comments