Skip to main content

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 .

  1. fetch real-time market data
  2. historical data
  3. 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

  1. fetch real-time market data execute trades (binance,REST)
  2. websocket support , hedging positions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crypto_api2a-0.1.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crypto_api2a-0.1.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file crypto_api2a-0.1.1.tar.gz.

File metadata

  • Download URL: crypto_api2a-0.1.1.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

Hashes for crypto_api2a-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e604dfbf87b1a0b1cf57448cbeb5490bf77b654ee7f682839ed6855852e26f1e
MD5 ae7469abf53b9f34c9085966eade9336
BLAKE2b-256 5fae47710b5062c87aaa44ad058f185249ea2ddbd6a90fe46707e1f71ba8ebb8

See more details on using hashes here.

File details

Details for the file crypto_api2a-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: crypto_api2a-0.1.1-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

Hashes for crypto_api2a-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fedd97a084682ef922f06ce8a915fa1c835a49ef2148fdde163045a618f0463b
MD5 e3dc43512fd2ceb54caa53bd714cb9ca
BLAKE2b-256 24ea2ac06388e570919a4868cf0381d6d44da3d2f8dcb447c3196dc69690665c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page