MCPcopy Create free account
hub / github.com/sammchardy/python-binance / create

Method create

binance/async_client.py:71–118  ·  view source on GitHub ↗
(
        cls,
        api_key: Optional[str] = None,
        api_secret: Optional[str] = None,
        requests_params: Optional[Dict[str, Any]] = None,
        tld: str = "com",
        base_endpoint: str = BaseClient.BASE_ENDPOINT_DEFAULT,
        testnet: bool = False,
        demo: bool = False,
        loop=None,
        session_params: Optional[Dict[str, Any]] = None,
        private_key: Optional[Union[str, Path]] = None,
        private_key_pass: Optional[str] = None,
        https_proxy: Optional[str] = None,
        time_unit: Optional[str] = None,
        verbose: bool = False,
    )

Source from the content-addressed store, hash-verified

69
70 @classmethod
71 async def create(
72 cls,
73 api_key: Optional[str] = None,
74 api_secret: Optional[str] = None,
75 requests_params: Optional[Dict[str, Any]] = None,
76 tld: str = "com",
77 base_endpoint: str = BaseClient.BASE_ENDPOINT_DEFAULT,
78 testnet: bool = False,
79 demo: bool = False,
80 loop=None,
81 session_params: Optional[Dict[str, Any]] = None,
82 private_key: Optional[Union[str, Path]] = None,
83 private_key_pass: Optional[str] = None,
84 https_proxy: Optional[str] = None,
85 time_unit: Optional[str] = None,
86 verbose: bool = False,
87 ):
88 self = cls(
89 api_key,
90 api_secret,
91 requests_params,
92 tld,
93 base_endpoint,
94 testnet,
95 demo,
96 loop,
97 session_params,
98 private_key,
99 private_key_pass,
100 https_proxy,
101 time_unit,
102 verbose
103 )
104 self.https_proxy = https_proxy # move this to the constructor
105
106 try:
107 await self.ping()
108
109 # calculate timestamp offset between local and binance server
110 res = await self.get_server_time()
111 self.timestamp_offset = res["serverTime"] - int(time.time() * 1000)
112
113 return self
114 except Exception:
115 # If ping throw an exception, the current self must be cleaned
116 # else, we can receive a "asyncio:Unclosed client session"
117 await self.close_connection()
118 raise
119
120 def _init_session(self) -> aiohttp.ClientSession:
121 session = aiohttp.ClientSession(

Callers 7

socket_listenerMethod · 0.80
test_ticker_socketFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
async_client_exampleFunction · 0.80
websocket_exampleFunction · 0.80
combined_exampleFunction · 0.80

Calls 3

pingMethod · 0.95
get_server_timeMethod · 0.95
close_connectionMethod · 0.95

Tested by 1

test_ticker_socketFunction · 0.64