Drop `OrderedDict` usage, not necessary in modern python

basic_buy_bot
Tyler Goodlet 2023-06-19 16:17:42 -04:00
parent 77db2fa7c8
commit fe902c017b
1 changed files with 10 additions and 13 deletions

View File

@ -22,10 +22,7 @@ Binance clients for http and ws APIs.
""" """
from __future__ import annotations from __future__ import annotations
from collections import ( from collections import ChainMap
OrderedDict,
ChainMap,
)
from contextlib import ( from contextlib import (
asynccontextmanager as acm, asynccontextmanager as acm,
) )
@ -234,7 +231,7 @@ class Client:
# 'futes_coin': self._dapi, # TODO # 'futes_coin': self._dapi, # TODO
} }
def _mk_sig(self, data: OrderedDict) -> str: def _mk_sig(self, data: dict) -> str:
# XXX: Info on security and authentification # XXX: Info on security and authentification
# https://binance-docs.github.io/apidocs/#endpoint-security-type # https://binance-docs.github.io/apidocs/#endpoint-security-type
@ -264,7 +261,7 @@ class Client:
async def _api( async def _api(
self, self,
method: str, method: str,
params: dict | OrderedDict, params: dict,
signed: bool = False, signed: bool = False,
action: str = 'get' action: str = 'get'
@ -292,7 +289,7 @@ class Client:
async def _fapi( async def _fapi(
self, self,
method: str, method: str,
params: dict | OrderedDict, params: dict,
signed: bool = False, signed: bool = False,
action: str = 'get', action: str = 'get',
testnet: bool = True, testnet: bool = True,
@ -336,7 +333,7 @@ class Client:
async def _sapi( async def _sapi(
self, self,
method: str, method: str,
params: dict | OrderedDict, params: dict,
signed: bool = False, signed: bool = False,
action: str = 'get' action: str = 'get'
@ -571,7 +568,7 @@ class Client:
for sym in self.watchlist: for sym in self.watchlist:
log.info(f'doing {sym}...') log.info(f'doing {sym}...')
params = OrderedDict([ params = dict([
('symbol', sym), ('symbol', sym),
('recvWindow', recv_window), ('recvWindow', recv_window),
('timestamp', binance_timestamp(now())) ('timestamp', binance_timestamp(now()))
@ -593,7 +590,7 @@ class Client:
# TODO: can't we drop this since normal dicts are # TODO: can't we drop this since normal dicts are
# ordered implicitly in mordern python? # ordered implicitly in mordern python?
params = OrderedDict([ params = dict([
('recvWindow', recv_window), ('recvWindow', recv_window),
('timestamp', binance_timestamp(now())) ('timestamp', binance_timestamp(now()))
]) ])
@ -609,7 +606,7 @@ class Client:
) -> list: ) -> list:
params = OrderedDict([ params = dict([
('recvWindow', recv_window), ('recvWindow', recv_window),
('timestamp', binance_timestamp(now())) ('timestamp', binance_timestamp(now()))
]) ])
@ -715,7 +712,7 @@ class Client:
''' '''
# lookup the binance-native symbol from search table # lookup the binance-native symbol from search table
bs_mktid: str = self._pairs[symbol.upper()].symbol bs_mktid: str = self._pairs[symbol.upper()].symbol
params: dict = OrderedDict([ params: dict = dict([
('symbol', bs_mktid), ('symbol', bs_mktid),
('side', side.upper()), ('side', side.upper()),
('type', 'LIMIT'), ('type', 'LIMIT'),
@ -771,7 +768,7 @@ class Client:
) -> None: ) -> None:
bs_mktid: str = self._pairs[symbol.upper()].symbol bs_mktid: str = self._pairs[symbol.upper()].symbol
params = OrderedDict([ params = dict([
('symbol', bs_mktid), ('symbol', bs_mktid),
# ('orderId', oid), # ('orderId', oid),
('origClientOrderId', oid), ('origClientOrderId', oid),