- Account Information "not possible fix limitation"
- Market Position buy and sell
- Peding orders limit and stop
- Partial close
- Stop loss & Take profit
- Modify Orders
- Modify position
- real time bid & ask
pip install ejtraderCT -U
git clone https://github.com/ejtraderLabs/ejtraderCT
cd ejtraderCT
python setup.py install
from ejtraderCT import Ctrader
import time
import logging
from datetime import datetime
logging.getLogger().setLevel(logging.INFO)
server="h8.p.c-trader.cn" # Host name
broker="icmarkets"
account="3152339"
password="393214"
currency="EUR"
api = Ctrader(server,broker,account,password,currency)
api.subscribe("EURUSD", "GBPUSD")
quote = api.quote()
print(quote)
# Output
{'EURUSD': {'bid': 1.02616, 'ask': 1.02618}, 'GBPUSD': {'bid': 1.21358, 'ask': 1.21362}}
quote = api.quote("EURUSD")
print(quote)
# Output
{'bid': 1.02612, 'ask': 1.02614}
# Buy position
symbol = "EURUSD"
volume = 0.01 # position size
stoploss = 1.18
takeprofit = 1.19
api.buy(symbol, volume, stoploss, takeprofit)
# sell position
symbol = "EURUSD"
volume = 0.01 # position size
stoploss = 1.19
takeprofit = 1.18
api.sell(symbol, volume, stoploss, takeprofit)
# Buy limit order
symbol = "EURUSD"
volume = 0.01 # position size
stoploss = 1.17
takeprofit = 1.19
price = 1.18 # entry price
api.buyLimit(symbol, volume, stoploss, takeprofit, price)
# Sell limit order
symbol = "EURUSD"
volume = 0.01 # position size
stoploss = 1.23
takeprofit = 1.17
price = 1.22 # entry price
api.sellLimit(symbol, volume, stoploss, takeprofit, price)
# Buy stop order
symbol = "EURUSD"
volume = 0.01 # position size
stoploss = 1.20
takeprofit = 1.24
price = 1.22 # entry price
api.buyStop(symbol, volume, stoploss, takeprofit, price)
# Sell stop order
symbol = "EURUSD"
volume = 0.01 # position size
stoploss = 1.19
takeprofit = 1.17
price = 1.18 # entry price
api.sellStop(symbol, volume, stoploss, takeprofit, price)
positions = api.positions()
print(positions)
orders = api.orders()
print(orders)
orders = api.orders()
for order in orders:
api.orderCancelById(order['ord_id'])
for position in positions:
api.positionCloseById(position['pos_id'], position['amount'])
api.cancel_all()
api.close_all()
id = "position id "
stoploss = "stop loss price""
takeprofit "stop gain price"
api.positionModify(id, stoploss, takeprofit)
id = "order id "
stoploss = "stop loss price""
takeprofit= "stop gain price"
price = "limit or stop entry price"
api.orderModify(id, stoploss, takeprofit, price)
@HarukaMa @douglasbarros