CryptoMathTrade is a Python library that assists in trading, serializing, deserializing, and interacting with exchange APIs.

Examples:

Get orderbook from Binance on BTCUSDT pair:

from CryptoMathTrade.exchange.bitget import Market

depth = Market().get_depth('BTCUSDT', 1)
print(depth)  # data=OrderBook(asks=[Order(price=Decimal('64658.42'), volume=Decimal('0.001255'))], bids=[Order(price=Decimal('64658.41'), volume=Decimal('0.004610'))]) response_object=<Response [200]>

Serializing Order object:

from CryptoMathTrade.types import Order

order_list = [{'price': 10, 'volume': 1}, {'price': 11, 'volume': 1}]

orders = [Order(**order) for order in order_list]
print(orders)  # [Order(price=Decimal('10'), volume=Decimal('1')), Order(price=Decimal('11'), volume=Decimal('1'))]

Trade by amount:

from CryptoMathTrade.trader import trade_by_amount
from CryptoMathTrade.types import Order

order_list = [{'price': 10, 'volume': 2}]
orders = [Order(**order) for order in order_list]

deals = trade_by_amount(orders, 5)
print(deals)  # deals=[Deal(price=Decimal('10'), volume=Decimal('0.5'))]

tech

Types

Exchanges