CryptoAPI is a powerful Python library designed to simplify interaction with various cryptocurrency APIs. (Binance REST and WebSockets)
Project description
CryptoApi
CryptoAPI is a powerful Python library designed to simplify interaction with various cryptocurrency APIs.
It offers a user-friendly typed interface to .
- fetch real-time market data
- historical data
- execute trades.
Key Features:
- Real-time Data: Access to real-time market data, including prices, volumes, and order books.
- Historical Data: Retrieve historical price and trading data.
- WebSockets: Establish persistent connections for live updates and event-driven programming.
- REST API: Interact with RESTful APIs for flexible data retrieval with typed responses and parameters.
- Asynchronous Support: Efficiently handle multiple API requests concurrently.
- Error Handling: Robust error handling and informative error messages. -**Typed API -Responeses of requests are returned as pydantic types
** EXAMPLE app.py ** import numpy as np from binance_client.BinanceAuth import BinanceAuth from binance_client.BinanceFuturesClient import BinanceFuturesClient from binance_client.BinanceTrader import BinanceTrader
api_key=os.environ['BINANCE_API_KEY'] # you can store your credintials in environment variables
api_secret=os.environ['BINANCE_API_SECRET']
auth_data=BinanceAuth(api_key,api_secret) #pass your binance credintials
symbols = ["BTCUSDT", "ADAUSDT"] # choose symbols
trader=BinanceTrader(auth_data,symbols,is_paper_trading=True) # create BinanceTrader so you have access to trading functionality
def run_test_cases(trader: BinanceTrader):
def log_hedge(row:TicketRow): #function which reacts to price changes
print(row)
prices_dict=row.prices
keys=trader.symbols
betas=[1,-1]
order_dict=row.prices.copy()
sum=0.0
for i in range(0,len(keys) -1) :
key=keys[i]
price=np.log(prices_dict[key])* abs(betas[i])
order_dict[key]=price
sum+=price
for i in range(0,len(keys) -1) :
v=order_dict[key]
v/=sum
v= v if betas[i]>1 else -v
order_dict[key]=v
print("order_dict")
print(order_dict)
return trader.modify_order(order_dict)
def getBetas()->tuple[float,float]:{
1,-1
}
trader.setSingleOnNextUpdate(log_hedge)
trader.run()
You have just written a simple function that reacts to prices, of course you can refine it, e.g. calculate beta coefficients from regression and add additional explaination variables eg.inflation .
After entering the quantity in modify_order, the difference from the current orders is converted into market orders.
Stages of development
- fetch real-time market data execute trades (binance,REST)
- websocket support , hedging positions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crypto_api2a-0.1.2.tar.gz.
File metadata
- Download URL: crypto_api2a-0.1.2.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e44f509f3ac3bab5f0d1757b45af04ebfc4e1448d79225e239b420313397ef3
|
|
| MD5 |
25513801063868e146dd36a624b9d322
|
|
| BLAKE2b-256 |
b4d90a066cfecc8dad9c84a59df340526adad2398b05948557defa9fc1a7f653
|
File details
Details for the file crypto_api2a-0.1.2-py3-none-any.whl.
File metadata
- Download URL: crypto_api2a-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ade9eec9539f21493a12d7eb272c40d6fed8d0a85dd5b659492ab9135b885354
|
|
| MD5 |
fbea5c5d73ac78cb17e9cfa0df5ea182
|
|
| BLAKE2b-256 |
3fd0766b232d2f2c3712f2fe7da40f56d65a24cedce01aad338ef23df5125b0a
|