def run_my_trader(): """ runs forever """ hour = 60 * 60 print(" [*] my_trader is running ") print(" [*] is exchange open " + str(cira.exchange_open())) while True: if cira.exchange_open(): one_instance() time.sleep(hour) # sleep time
def run_cassandra(): """ runs Cassandra forever """ hour = 60 * 60 wait = hour // 4 print(" [*] Cassandra Classic is running ") while True: if config_dict["DEBUG"]: print(" [*] is NASDAQ open " + str(cira.exchange_open())) if cira.exchange_open(): one_instance_cassandra() if config_dict["DEBUG"]: print(" [*] one instance has run ") time.sleep(wait)
def test_trade(): """ buy and sell testing """ stock = 'AMZN' cira.logging.LOGGING = False assert cira.is_tradable(stock) == True if cira.exchange_open(): cira.buy(1, stock) assert cira.owned_stocks() == [stock] cira.sell(1, stock) assert cira.owned_stocks() == []
def test_set_up(): """ Ensure that position is predictable for testing """ if cira.exchange_open(): cira.sell_list(cira.owned_stocks()) # clear portfolio assert cira.owned_stocks() == []