Example #1
0
def test_sell_in_coin(symbol):
    test_buy(symbol) #get $10 of symbol
    num_units = inv.get_current_holdings(symbol)
    inv.sell_sell_sell(num_units, inv.get_gmt_time(), symbol)
    current_num_coin = inv.get_current_holdings(symbol)
    cumu_gain = inv.get_current_gain(symbol)
    if cumu_gain == 0:
        print(f"{bcolors.OKGREEN}Selling coin cumu_gain back to zero passed{bcolors.ENDC}")
    else:
        print(f"{bcolors.FAIL}Selling coin cumu_gain back to zero failed{bcolors.ENDC}")  
    if current_num_coin == 0:
        print(f"{bcolors.OKGREEN}Selling coin units back to zero passed{bcolors.ENDC}")
    else:
        print(f"{bcolors.FAIL}Selling coin units back to zero failed{bcolors.ENDC}")        
Example #2
0
def test_cumu_spend_since_zero(symbol):
    num_coin_units = inv.get_current_holdings(symbol)
    inv.sell_sell_sell(num_coin_units, inv.get_gmt_time(), symbol) #sell rest of coins
    ##current historic should not be zero
    cumu_gain = inv.get_current_gain(symbol)
    if cumu_gain != 0:
        print(f"{bcolors.OKGREEN}Selling coin cumu_gain back to zero passed{bcolors.ENDC}")
    else:
        print(f"{bcolors.FAIL}Selling coin cumu_gain back to zero failed (is collection turned on!!!){bcolors.ENDC}") 
    #should be zero
    cumu_gain_curr = inv.get_spend_since_zero(symbol)
    if cumu_gain_curr == 0:
        print(f"{bcolors.OKGREEN}Selling coin to zero cumu_gain_to_zero passed{bcolors.ENDC}")
    else:
        print(f"{bcolors.FAIL}Selling coin to zero cumu_gain_to_zero failed (is collection turned on!!!){bcolors.ENDC}") 
Example #3
0
def test_partial_sell_in_coin(symbol):
    inv.reset_investment_tables()
    test_buy(symbol) #get $10 of symbol
    num_coin_units = inv.get_current_holdings(symbol) / 2
    inv.sell_sell_sell(num_coin_units, inv.get_gmt_time(), symbol) #sell half coins
    current_num_coin = inv.get_current_holdings(symbol)
    cumu_gain = inv.get_current_gain(symbol)
    current_num_coin = inv.get_current_holdings(symbol)
    if current_num_coin == num_coin_units:
        print(f"{bcolors.OKGREEN}Selling half coin units passed{bcolors.ENDC}")
        ### now need to test for cumu_spend_since_zero
        time.sleep(20) #need to wait for market data to change price
        test_cumu_spend_since_zero(symbol)
    else:
        print(f"{bcolors.FAIL}Selling coin units back to zero failed{bcolors.ENDC}")   
Example #4
0
def main():
    while(True):
        action = input("waiting for input...")
        if action == 'buy':
            amount = inp.inputNum("amount? (in USD) $")
            coin = input("symbol? ")
            inv.buy_in_USD(amount, inv.get_gmt_time(), str.upper(coin))
        elif action == 'sell':
            amount = inp.inputNum("amount? ")
            coin = input("symbol? ")
            inv.sell_sell_sell(amount, inv.get_gmt_time(), str.upper(coin))
        elif action == 'report':
            report(input("type? "))
        elif action == 'restart':
            inv.reset_investment_tables()
        elif action == 'restart coins':
            inv.reset_coin_tables()
        elif action == 'help':
            help()
        elif action == 'exit':
            break
Example #5
0
def main_loop():
    list_of_coins = inv.get_all_stored_coins()
    list_to_not_buy = []
    while True:
        if get_connection_status() == 1:
            for item in list_of_coins:
                if going_up(item) > 0:
                    if item not in list_to_not_buy:
                        print("selling " + item)
                        num_coin = inv.get_current_holdings(item)
                        if num_coin > 0:
                            inv.sell_sell_sell(num_coin, inv.get_gmt_time(),
                                               item)
                        else:
                            print("no " + item + " to sell")
                elif going_up(item) == 0:
                    print("holding " + item)
                else:
                    if greater_than_buy(item) < 0:
                        current_money = inv.get_USD() / 2
                        num_coin_types = len(list_of_coins)
                        money_to_invest = current_money / num_coin_types
                        inv.buy_in_USD(money_to_invest, inv.get_gmt_time(),
                                       item)
                        print("Bought " + item)
                        if item in list_to_not_buy:
                            list_to_not_buy.remove(item)
                            print(item +
                                  " recovered, putting it back on the list")
                    else:
                        if item not in list_to_not_buy:
                            list_to_not_buy.append(item)
                            print("not buying anymore " + item)
                        print("holding " + item)
            time.sleep(20)
        else:
            print("no connection, sleeping for 30 sec")
            time.sleep(30)
Example #6
0
def main():
    num_coin_types = len(inv.get_all_stored_coins())
    usd_amount = inv.get_USD()
    usd_for_each_coin = usd_amount / num_coin_types
    while True:
        for coin in inv.get_all_stored_coins():
            choice = random.randint(0, 2)  # 0 = hold, 1 = buy, 2 = sell
            if choice == 0:
                print("Coin: " + coin + " Action: Hold")
            elif choice == 1:
                #try to buy random amount of coin
                print("Coin: " + coin + " Action: Buy")
                inv.buy_in_USD(float(inv.get_USD() / random.randint(1, 10)),
                               inv.get_gmt_time(), coin)
            elif choice == 2:
                #try to sell random amount of coin
                if inv.get_current_holdings(coin) > 0:
                    print("Coin: " + coin + " Action: Sell")
                    inv.sell_sell_sell(
                        float(inv.get_current_holdings(coin)) /
                        random.randint(1, 10), inv.get_gmt_time(), coin)
                else:
                    print("can't sell what we dont own")
        time.sleep(10)