Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Transaction:
- start_time=None
- def __init__(self,currency,stop_loss,volume):
- self.currency=currency
- self.stop_loss=stop_loss
- self.volume=volume
- self.profitability=None
- def realise(self): #Series of instructions to realise transaction for each Capital way it will be different
- self.transaction_starttime=datetime.datetime.now()
- raise NotImplementedError("Transaction class is only a template. Subclass must implement abstract method")
- def stop(self): #stop transaction in case if profitability changes to an unwanted value parameter stop_loss
- raise NotImplementedError("Transaction class is only a template. Subclass must implement abstract method")
- def prof_watchdog(self): #check if transaction is still profitable on each realising step
- if self.profitability>=self.stop_loss:
- return True
- else:
- return False
- def conclude(self): #Update Balance and transaction history to json file
- duration_time=json.loads(open("UserDedicatedJsonData/TransactionsTime.json", "r").read())
- duration_time[self.__str__()][len(duration_time[self.__str__()])+1]=datetime.timedelta(datetime.datetime.now(),self.transaction_starttime)
- with open('UserDedicatedJsonData/TransactionsTime.json', 'w+') as outfile:
- json.dump(duration_time, outfile)
- self.transaction_starttime=0
- raise NotImplementedError("Transaction class is only a template. Subclass must implement abstract method")
- def update_prof(self):
- raise NotImplementedError("Transaction class is only a template. Subclass must implement abstract method")
- def get_profitability(self):
- return self.profitability
- class KrakenBitbayTransaction(Transaction):
- def __init__(self,currency,stop_loss,volume):
- Transaction.__init__(self,currency,stop_loss,volume)
- self.profitability=Count_Circuit_Profitability.count_kraken_bitbay(self.volume,self.currency)
- def __str__(self):
- return "KrakenBitbayTransaction"+str(self.currency)
- def realise(self): #TODO this method is still as pseudocode
- currency_balance=KrakenPrivateMethods.KrakenPrivateAPI.getBalance()['$currency']
- KrakenPrivateMethods.KrakenPrivateAPI.AddBuyOrder(self,
- str(self.currency)+"EUR",HTTP_GET_DATA.kraken_BTCEUR,KrakenPrivateMethods.KrakenPrivateAPI.getBalance())
- def update_prof(self):
- self.profitability=Count_Circuit_Profitability.count_kraken_bitbay(self.volume,self.currency)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement