ejtraderLabs / ejtraderCT

The best Python Ctrader FIX API Perfect for HFT
MIT License
59 stars 20 forks source link

AttributeError: 'Ctrader' object has no attribute 'api' #5

Closed savasturkoglu1 closed 2 years ago

savasturkoglu1 commented 2 years ago

when i try get history with this method; history = api.history("GBPUSD", "H1", int(datetime.datetime.now().timestamp()) - 10000) i got error; AttributeError: 'Ctrader' object has no attribute 'api' there is no api defination in the class

traderpedroso commented 2 years ago

envoriment python version its been tested only on python 3.7! but there is no api class you need to define it!

could be any name your won't

example

ctrader = Ctrader(FIX_SERVER,FIX_BROKER,FIX_LOGIN,FIX_PASSWORD,FIX_CURRENCY)

ctrader.buy("EURUSD", 0.01, 1.18, 1.19)

follow full example on readme

from ejtraderCT import Ctrader

FIX_SERVER="h8.p.c-trader.cn"
FIX_BROKER="icmarkets"
FIX_LOGIN="3152339"
FIX_PASSWORD="393214"
FIX_CURRENCY="EUR"

# api defined here
api = Ctrader(FIX_SERVER,FIX_BROKER,FIX_LOGIN,FIX_PASSWORD,FIX_CURRENCY)

api.buy("EURUSD", 0.01, 1.18, 1.19)
savasturkoglu1 commented 2 years ago

@traderpedroso ye I know that I can connect the server that way. But when i call history method so this Method in ctrader.py:

def history(self, symbol, chartTF, fromDate):
        return json.loads(json.dumps(self.api.Command(action="HISTORY", actionType="DATA", symbol=symbol, chartTF=chartTF, fromDate=fromDate)))

i got this error

AttributeError: 'Ctrader' object has no attribute 'api'

coz there is no api defination in the class what mean -api- in ctrader.py ?

traderpedroso commented 2 years ago

@traderpedroso ye I know that I can connect the server that way. But when i call history method so this Method in ctrader.py:

def history(self, symbol, chartTF, fromDate):
        return json.loads(json.dumps(self.api.Command(action="HISTORY", actionType="DATA", symbol=symbol, chartTF=chartTF, fromDate=fromDate)))

i got this error

AttributeError: 'Ctrader' object has no attribute 'api'

coz there is no api defination in the class what mean -api- in ctrader.py ?

sorry its not implemented yet on readme saying its future function