CryptoBot/api/fake.py
2021-01-31 01:15:56 -07:00

24 lines
765 B
Python

from pykrakenapi import KrakenAPI
import krakenex
class Fake:
def __init__(self):
self.krakenAPI = krakenex.API()
self.krakenAPI.load_key("kraken.key")
self.krakenWrapper = KrakenAPI(self.krakenAPI)
self.balances = {'XXBT': self.krakenWrapper.get_ticker_information(pair="XXBTZUSD")["c"][0][0] * 100, 'ZUSD': 0.0}
def buyOrder(self, amount, pair):
self.balances[0:3] += float(self.krakenWrapper.get_ticker_information(pair="XXBTZUSD")["c"][0][0]) * amount
self.balances[4:7] -= amount
def sellOrder(self, amount, pair):
self.balances[0:3] -= 1/float(self.krakenWrapper.get_ticker_information(pair="XXBTZUSD")["c"][0][0]) * amount
self.balances[4:7] += amount