test_microsma.py
def update_portfolio(orders, last_price):
    '''add every coin bought to our portfolio for tracking/selling later'''
    if DEBUG: print(orders)
    for coin in orders:

        coins_bought[coin] = {
            'symbol': orders[coin][0]['symbol'],
            'orderid': orders[coin][0]['orderId'],
            'timestamp': orders[coin][0]['time'],
            'bought_at': last_price[coin]['price'],
            'volume': volume[coin],
            }

        # save the coins in a json file in the same directory
        with open(coins_bought_file_path, 'w') as file:
            json.dump(coins_bought, file, indent=4)
                           
        print(f'Order with id {orders[coin][0]["orderId"]} placed and saved to file')
add every coin bought to our portfolio for tracking/selling later
add every coin bought to our portfolio for tracking/selling later
add every coin bought to our portfolio for tracking / selling later
def update_portfolio(orders, last_price):
    if DEBUG: print(orders)
    for coin in orders:
        coins_bought[coin] = {
            'symbol': orders[coin][0]['symbol'],
            'orderid': orders[coin][0]['orderId'],
            'timestamp': orders[coin][0]['time'],
            'bought_at': last_price[coin]['price'],
            'volume': volume[coin],
            }
        with open(coins_bought_file_path, 'w') as file:
            json.dump(coins_bought, file, indent=4)
        print(f'Order with id {orders[coin][0]["orderId"]} placed and saved to file')
def update_portfolio ( orders , last_price ) : if DEBUG : print ( orders ) for coin in orders : coins_bought [ coin ] = { 'symbol' : orders [ coin ] [ 0 ] [ 'symbol' ] , 'orderid' : orders [ coin ] [ 0 ] [ 'orderId' ] , 'timestamp' : orders [ coin ] [ 0 ] [ 'time' ] , 'bought_at' : last_price [ coin ] [ 'price' ] , 'volume' : volume [ coin ] , } with open ( coins_bought_file_path , 'w' ) as file : json . dump ( coins_bought , file , indent = 4 ) print ( f'Order with id {orders[coin][0]["orderId"]} placed and saved to file' )
add every coin bought to our portfolio for tracking/selling later
add every coin bought to our portfolio for tracking / selling later
'''add every coin bought to our portfolio for tracking/selling later''' # save the coins in a json file in the same directory
orders
last_price