mirror of
https://git.wownero.com/lza_menace/totrader.git
synced 2024-08-15 00:33:13 +00:00
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
from os import getenv
|
|
from dotenv import load_dotenv
|
|
from requests import get as requests_get
|
|
from requests import post as requests_post
|
|
from requests.auth import HTTPBasicAuth
|
|
|
|
|
|
class TradeOgre(object):
|
|
def __init__(self):
|
|
load_dotenv('.env')
|
|
self.base = 'https://tradeogre.com/api/v1'
|
|
self.auth = HTTPBasicAuth(
|
|
getenv('TO_USER'),
|
|
getenv('TO_PASS')
|
|
)
|
|
|
|
def req(self, route, method='get', data={}):
|
|
url = self.base + route
|
|
if method == 'get':
|
|
r = requests_get(url, auth=self.auth)
|
|
else:
|
|
r = requests_post(url, auth=self.auth, data=data)
|
|
return r.json()
|
|
|
|
def get_trade_pair(self, pair):
|
|
route = f'/ticker/{pair}'
|
|
return self.req(route)
|
|
|
|
def get_balance(self, currency):
|
|
route = '/account/balance'
|
|
data = {'currency': currency}
|
|
return self.req(route, 'post', data)
|
|
|
|
def get_balances(self):
|
|
route = '/account/balances'
|
|
return self.req(route)
|
|
|
|
def submit_order(self, type, pair, quantity, price):
|
|
route = f'/order/{type}'
|
|
data = {'market': pair, 'quantity': quantity, 'price': price}
|
|
return self.req(route, 'post', data)
|
|
|
|
def get_order(self, uuid):
|
|
route = f'/account/order/{uuid}'
|
|
return self.req(route)
|