11from datetime import datetime
2- from ..enums import CurrencyType , OrderType , OrderSubType , Side
3- from ..utils import parse_date , str_to_currency_type , str_to_side , \
2+ from ..enums import OrderType , OrderSubType , Side , PairType , CurrencyType
3+ from ..utils import parse_date , str_to_currency_type , str_to_currency_pair_type , str_to_side , \
44 str_to_order_type
55from ..structs import MarketData
66from ..enums import TickType
@@ -13,19 +13,18 @@ def tickToData(jsn: dict) -> MarketData:
1313 price = float (jsn .get ('price' , 'nan' ))
1414 volume = float (jsn .get ('size' , 'nan' ))
1515 typ = GDAXHelpersMixin .strToTradeType (jsn .get ('type' ))
16- currency = str_to_currency_type (jsn .get ('product_id' ))
16+ currency_pair = str_to_currency_pair_type (jsn .get ('product_id' ))
1717
1818 order_type = str_to_order_type (jsn .get ('order_type' , '' ))
1919 side = str_to_side (jsn .get ('side' , '' ))
2020 remaining_volume = float (jsn .get ('remaining_size' , 'nan' ))
2121 reason = jsn .get ('reason' , '' )
2222 sequence = int (jsn .get ('sequence' ))
23-
2423 ret = MarketData (time = time ,
2524 volume = volume ,
2625 price = price ,
2726 type = typ ,
28- currency = currency ,
27+ currency_pair = currency_pair ,
2928 remaining = remaining_volume ,
3029 reason = reason ,
3130 side = side ,
@@ -55,7 +54,7 @@ def trade_req_to_params(req) -> dict:
5554 p = {}
5655 p ['price' ] = str (req .price )
5756 p ['size' ] = str (req .volume )
58- p ['product_id' ] = GDAXHelpersMixin .currency_to_string (req .currency )
57+ p ['product_id' ] = GDAXHelpersMixin .currency_pair_to_string (req .currency_pair )
5958 p ['type' ] = GDAXHelpersMixin .order_type_to_string (req .order_type )
6059
6160 if req .order_sub_type == OrderSubType .FILL_OR_KILL :
@@ -67,7 +66,40 @@ def trade_req_to_params(req) -> dict:
6766 @staticmethod
6867 def currency_to_string (cur : CurrencyType ) -> str :
6968 if cur == CurrencyType .BTC :
69+ return 'BTC'
70+ if cur == CurrencyType .ETH :
71+ return 'ETH'
72+ if cur == CurrencyType .LTC :
73+ return 'LTC'
74+ if cur == CurrencyType .BCH :
75+ return 'BCH'
76+ else :
77+ raise Exception ('Pair not recognized: %s' % str (cur ))
78+
79+ @staticmethod
80+ def currency_pair_to_string (cur : PairType ) -> str :
81+ if cur == PairType .BTCUSD :
7082 return 'BTC-USD'
83+ if cur == PairType .BTCETH :
84+ return 'BTC-ETH'
85+ if cur == PairType .BTCLTC :
86+ return 'BTC-LTC'
87+ if cur == PairType .BTCBCH :
88+ return 'BTC-BCH'
89+ if cur == PairType .ETHUSD :
90+ return 'ETH-USD'
91+ if cur == PairType .LTCUSD :
92+ return 'LTC-USD'
93+ if cur == PairType .BCHUSD :
94+ return 'BCH-USD'
95+ if cur == PairType .ETHBTC :
96+ return 'ETH-BTC'
97+ if cur == PairType .LTCBTC :
98+ return 'LTC-BTC'
99+ if cur == PairType .BCHBTC :
100+ return 'BCH-BTC'
101+ else :
102+ raise Exception ('Pair not recognized: %s' % str (cur ))
71103
72104 @staticmethod
73105 def order_type_to_string (typ : OrderType ) -> str :
@@ -96,13 +128,13 @@ def tickToData(jsn: dict) -> MarketData:
96128 remaining_volume = float (jsn .get ('remaining' , 'nan' ))
97129
98130 sequence = - 1
99- currency = str_to_currency_type ('BTC' )
131+ currency_pair = str_to_currency_type ('BTC' )
100132
101133 ret = MarketData (time = time ,
102134 volume = volume ,
103135 price = price ,
104136 type = typ ,
105- currency = currency ,
137+ currency_pair = currency_pair ,
106138 remaining = remaining_volume ,
107139 reason = reason ,
108140 side = side ,
@@ -136,7 +168,7 @@ def trade_req_to_params(req) -> dict:
136168 p = {}
137169 p ['price' ] = str (req .price )
138170 p ['size' ] = str (req .volume )
139- p ['product_id' ] = GeminiHelpersMixin .currency_to_string (req .currency )
171+ p ['product_id' ] = GeminiHelpersMixin .currency_pair_to_string (req .currency_pair )
140172 p ['type' ] = GeminiHelpersMixin .order_type_to_string (req .order_type )
141173
142174 if p ['type' ] == OrderType .MARKET :
@@ -152,9 +184,21 @@ def trade_req_to_params(req) -> dict:
152184 return p
153185
154186 @staticmethod
155- def currency_to_string (cur : CurrencyType ) -> str :
156- if cur == CurrencyType . BTC :
187+ def currency_pair_to_string (cur : PairType ) -> str :
188+ if cur == PairType . BTCUSD :
157189 return 'BTCUSD'
190+ if cur == PairType .ZECUSD :
191+ return 'ZECUSD'
192+ if cur == PairType .ZECBTC :
193+ return 'ZECBTC'
194+ if cur == PairType .ZECETH :
195+ return 'ZECETH'
196+ if cur == PairType .ETHBTC :
197+ return 'ETHBTC'
198+ if cur == PairType .ETHUSD :
199+ return 'ETHUSD'
200+ else :
201+ raise Exception ('Pair not recognized: %s' % str (cur ))
158202
159203 @staticmethod
160204 def order_type_to_string (typ : OrderType ) -> str :
0 commit comments