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

cryptoapi2-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

CryptoApi2-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file cryptoapi2-0.1.0.tar.gz.

File metadata

  • Download URL: cryptoapi2-0.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for cryptoapi2-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2e36b3790b2a1d83c74fde716b2241c553ca701d3a71ac7d1c37c26a8357be40
MD5 25d1b9a2c02ed155368c2d019318beb4
BLAKE2b-256 cb0a6c4ad77df08bb12ca71df661429c0f1957d90ca7e2c299c883a0eb136988

See more details on using hashes here.

File details

Details for the file CryptoApi2-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: CryptoApi2-0.1.0-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 CryptoApi2-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d73ae8a646916a27bd6d664753a303664b1fe3a207689b1bc9e7e70a9aae3782
MD5 154dd4c2ff564b306eefde4dab98ff09
BLAKE2b-256 8aa03d6bf7916f17bf6d17461e3270649bc5da174ceaa52f37ee89559cd6aea4

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