timemins = 5 # time in mins between every script execution / running print('\n# FINAL_ToDoPoint =', todopoint) print() print('1) BUYSELL_INSTRUMENT // BUY # IF POINT <', buymark, ' / SELL # IF POINT >', sellmark) print(' - > BUYSELL_POINT =', todopoint) current_number = len(instrument_id) list_add_instrument = fxfinal.buy_sell_list_add_instrument( todopoint, current_number, limit_buysell, buymark, sellmark) dict_buy_sell = fxfinal.final_dict_buy_sell_currency( list_add_instrument, todopoint, open_position, all_currencies, buymark, 541, sellmark, 531) if len(dict_buy_sell[0]) > 0: for k, v in dict_buy_sell[0].items(): fxfinal.buy_stock(k, v) if len(dict_buy_sell[-1]) > 0: for k, v in dict_buy_sell[-1].items(): fxfinal.sell_stock(k, v) print('2) CLOSE_POSITION // BECAUSE CHANGE_DIRECTION: BUY >', closebuypoint, '/ SELL <', closesellpoint) print(' - > OPEN_POSITION =', open_position) if len(open_position) > 0: for ko, vo in open_position.items(): id_elem = instrument_id[ko] buysell = fxfinal.direction_elementid(id_elem) directionpoint = tocloseone[ ko] # only work when all currencies in todopoint fxfinal.open_position_printstatus(ko, vo, buysell, directionpoint, closebuypoint, closesellpoint)
print( ' --- > # NOTHING TO ADD - NO Currency MEET the requirement for MACD_Forex_Trading' ) elif to_add_number > avail_number and avail_number > 0: print(' --- > Limit_Trader (', limit_buysell, ') nearly reach - Mean only', avail_number, 'Currrency will be Traded', '- > LIST =', list_add_instrument) else: print(' --- > TO_ADD =', len(list_add_instrument), '- > LIST =', list_add_instrument) if len(list_add_instrument) > 0: for curr in list_add_instrument: if todopoint[curr] < buymark and curr not in open_position: amount = 541 + all_currencies.index(curr) print(' ---- > TO BUY = (Currency)', curr, '(Amount)', amount) fxfinal.buy_stock(curr, amount) elif todopoint[curr] > sellmark and curr not in open_position: amount = 531 + all_currencies.index(curr) print(' ---- > TO SELL = (Currency)', curr, '(Amount)', amount) fxfinal.sell_stock(curr, amount) # print('2) CLOSE_POSITION // BECAUSE CHANGE_DIRECTION: BUY >', closebuypoint, '/ SELL <', closesellpoint, '// OR LOSS <', closeloss) print('2) CLOSE_POSITION // BECAUSE CHANGE_DIRECTION: BUY >', closebuypoint, '/ SELL <', closesellpoint) print(' - > OPEN_POSITION =', open_position) for ko, vo in open_position.items(): id_elem = instrument_id[ko] buysell = fxfinal.direction_elementid(id_elem) directionpoint = tocloseone[ ko] # only work when all currencies in todopoint print(' -- > ',