CryptoBot/api/fake.py

25 lines
751 B
Python
Raw Normal View History

2021-01-31 03:15:56 -05:00
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)
2021-01-31 16:17:25 -05:00
self.balances = {'XXDG': self.krakenWrapper.get_ticker_information(pair="XDGUSD")["c"][0][0] * 100, 'ZUSD': 0.0}
2021-01-31 03:15:56 -05:00
def buyOrder(self, amount, pair):
2021-01-31 16:17:25 -05:00
self.balances[0:3] += float(self.krakenWrapper.get_ticker_information(pair=pair)["c"][0][0]) * amount
2021-01-31 03:15:56 -05:00
self.balances[4:7] -= amount
def sellOrder(self, amount, pair):
2021-01-31 16:17:25 -05:00
self.balances[0:3] -= 1/float(self.krakenWrapper.get_ticker_information(pair=pair)["c"][0][0]) * amount
2021-01-31 03:15:56 -05:00
self.balances[4:7] += amount