Created
July 5, 2018 13:07
-
-
Save slapglif/b84ce24d4dfe5002b0b2d30b655b60a1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) |
Thanks a lot for sharing.
Please in the future write a little description + imports.
I'm pro at trading but not at programming yet.
I have never seen his python syntax style before.
What is the random number used for?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
premium content