ejtraderLabs / ejtraderCT

The best Python Ctrader FIX API Perfect for HFT
MIT License
61 stars 21 forks source link

Real time quote do not work #7

Closed QIzxqzy closed 1 year ago

QIzxqzy commented 1 year ago

Its not working or it is me who is stupid)

my code:

from ejtraderCT import Ctrader
import logging

SERVER = 'h18.p.ctrader.com'
BROKER = 'demo.roboforex'
LOGIN = '6183532'
PASSWORD = 'damian999'
CURRENCY = 'EUR'

def auth():
    logging.getLogger().setLevel(logging.INFO)
    api = Ctrader(SERVER, BROKER, LOGIN, PASSWORD, CURRENCY)
    return api

client = auth()
client.subscribe('EURUSD')

quote = client.quote('EURUSD')
print(quote)

feedback:

INFO:root:Quote logged on - client_id 1
INFO:root:Trade logged on - client_id 1
Symbol not Subscribed

if I'm doing it this way:

client.subscribe("EURUSD", "GBPUSD")
quote = client.quote()
print(quote)

do not get real time quotes anyway:

INFO:root:Quote logged on - client_id 1
INFO:root:Trade logged on - client_id 1
{}

getting just an empty {}

traderpedroso commented 1 year ago

Its not working or it is me who is stupid)

my code:

from ejtraderCT import Ctrader
import logging

SERVER = 'h18.p.ctrader.com'
BROKER = 'demo.roboforex'
LOGIN = '6183532'
PASSWORD = 'damian999'
CURRENCY = 'EUR'

def auth():
    logging.getLogger().setLevel(logging.INFO)
    api = Ctrader(SERVER, BROKER, LOGIN, PASSWORD, CURRENCY)
    return api

client = auth()
client.subscribe('EURUSD')

quote = client.quote('EURUSD')
print(quote)

feedback:

INFO:root:Quote logged on - client_id 1
INFO:root:Trade logged on - client_id 1
Symbol not Subscribed

if I'm doing it this way:

client.subscribe("EURUSD", "GBPUSD")
quote = client.quote()
print(quote)

do not get real time quotes anyway:

INFO:root:Quote logged on - client_id 1
INFO:root:Trade logged on - client_id 1
{}

getting just an empty {}

Sorry for later response add time sleep for subscribe the symbol

from ejtraderCT import Ctrader
import logging
import time

SERVER = 'h18.p.ctrader.com'
BROKER = 'demo.roboforex'
LOGIN = '6183532'
PASSWORD = 'damian999'
CURRENCY = 'EUR'

def auth():
    logging.getLogger().setLevel(logging.INFO)
    api = Ctrader(SERVER, BROKER, LOGIN, PASSWORD, CURRENCY)
    return api

client = auth()

client.subscribe("EURUSD")
time.sleep(3)

while True:
    print(client.quote('EURUSD'))