-
-
Save ptim/25d3531b62998ea188756e83f129ad53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_nonce(length=8): | |
"""Generate pseudorandom number.""" | |
return ''.join([str(random.randint(0, 9)) for i in range(length)]) | |
def trade(signal,volume,pair): | |
try: | |
trade = 'TRADE|OPEN|' + signal + '|' + pair + '|0|0|0|IcarusBot Trade|' + generate_nonce() + '|' + volume | |
s.send_string(trade, encoding='utf-8') | |
print("Waiting for metatrader to respond...") | |
logging.info("Waiting for metatrader to respond...") | |
m = s.recv() | |
print("Reply from server ", m) | |
except Exception as e: | |
print(e) | |
logging.info(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment