import requests import json import os import time from archon.exchange.delta.delta_rest_client import create_order_format, cancel_order_format, round_by_tick_size from archon.exchange.delta.instruments import btc_march, btc_march_quanto, btc_june, product_names import archon.exchange.exchanges as exc from archon.plugins.aws_ses import AwsSes from archon.brokerservice.brokerservice import Brokerservice import archon.exchange.exchanges as exc brk = Brokerservice() user_email = "*****@*****.**" #os.environ["USER_EMAIL"] brk.activate_session(user_email) brk.set_client(exc.BINANCE) binance_client = brk.get_client(exc.BINANCE) market = "BATBTC" orderbook = binance_client.get_orderbook_symbol(market) print(orderbook)
""" basic trading """ import archon.exchange.exchanges as exc from archon.brokerservice.brokerservice import Brokerservice import archon.exchange.bitmex.bitmex as mex import time from util import * broker = Brokerservice() def setup_broker(): user_id = parse_toml("conf.toml")["user_id"] broker.set_apikeys_fromfile(user_id) broker.activate_session(user_id) broker.set_client(exc.BITMEX) return broker def top_book(): mex_client = broker.get_client(exc.BITMEX) book = mex_client.market_depth(mex.instrument_btc_perp) mex_bids, mex_asks = [b for b in book if b['side'] == 'Buy' ], [b for b in book if b['side'] == 'Sell'] print('***%s exchange***' % "BITMEX") topbid_mex = float(mex_bids[0]['price']) topask_mex = float(mex_asks[-1]['price']) mid_mex = (topbid_mex + topask_mex) / 2
import requests import json from archon.exchange.delta.delta_rest_client import create_order_format, cancel_order_format, round_by_tick_size from archon.exchange.delta.instruments import btc_march, btc_march_quanto, btc_june, product_names import archon.exchange.exchanges as exc from archon.plugins.aws_ses import AwsSes from archon.brokerservice.brokerservice import Brokerservice import archon.exchange.exchanges as exc import os brk = Brokerservice() user_email = "ben" #os.environ["USER_EMAIL"] brk.activate_session(user_email) brk.set_client(exc.DELTA) delta_client = brk.get_client(exc.DELTA) def show_book(product): book = delta_client.get_L2_orders(product) bids = book["buy_book"] asks = book["sell_book"] for a in asks[:5]: print(a) print('******') for b in bids[:5]: print(b) topbid = bids[0]
import requests import json import os from archon.exchange.delta.delta_rest_client import create_order_format, cancel_order_format, round_by_tick_size from archon.exchange.delta.instruments import btc_march, btc_march_quanto, btc_june, product_names import archon.exchange.exchanges as exc from archon.plugins.aws_ses import AwsSes from archon.brokerservice.brokerservice import Brokerservice import archon.exchange.exchanges as exc #brk = Brokerservice() abroker = Brokerservice() #setAuto=True) user_email = "*****@*****.**" #os.environ["USER_EMAIL"] abroker.set_apikeys_fromfile(user_id="ben") abroker.activate_session(user_id="ben") abroker.set_client(exc.DELTA) client = abroker.get_client(exc.DELTA) print (client) prd = client.get_products() print ("products ",prd) """ brk.activate_session(user_email)
""" find options of deribit """ from archon.exchange.deribit.Wrapper import DeribitWrapper from datetime import datetime import time import archon.exchange.exchanges as exc from archon.brokerservice.brokerservice import Brokerservice import archon.exchange.bitmex.bitmex as mex import time from util import * broker = Brokerservice() def setup_broker(): user_id = parse_toml("conf.toml")["user_id"] broker.set_apikeys_fromfile(user_id) broker.activate_session(user_id) broker.set_client(exc.DERIBIT) return broker if __name__ == '__main__': print("start....") setup_broker() deribit_client = broker.get_client(exc.DERIBIT) s = 'BTC-PERPETUAL'
import requests import json import os import time import archon.exchange.exchanges as exc from archon.brokerservice.brokerservice import Brokerservice import archon.exchange.exchanges as exc brk = Brokerservice() user_email = "*****@*****.**" #os.environ["USER_EMAIL"] brk.store_apikey(exc.BINANCE, "", "", user_id=user_email)
import datetime from archon.brokerservice.brokerservice import Brokerservice import archon.exchange.bitmex.bitmex as bitmex import archon.exchange.exchanges as exc import pandas as pd import numpy import matplotlib.pyplot as plt #from arctic import Arctic from boto3 import client import boto3 import requests import json import matplotlib.pyplot as plt brk = Brokerservice() user_email = "*****@*****.**" brk.activate_session(user_email) brk.set_client(exc.BITMEX) brk.set_client(exc.DELTA) bitmex_client = brk.get_client(exc.BITMEX) #candles = client.trades_candle("XBTUSD", bitmex.candle_1d) numdays = 500 def write_candles(candles): with open("history.csv", "w") as f: for c in candles: f.write(str(c) + "\n")