Ctrader Fix API
Project description
Python Ctrader Fix API
Installation
Tested on python 3.7 to 3.9
pip install ejtraderCT -U
Or install from source
git clone https://github.com/ejtraderLabs/ejtraderCT
cd ejtraderCT
python setup.py install
Import librarys
from ejtraderCT import Ctrader
import time
import logging
from datetime import datetime
logging.getLogger().setLevel(logging.INFO)
Fix login account and details
SERVER="h8.p.c-trader.cn"
BROKER="icmarkets"
LOGIN="3152339"
PASSWORD="393214"
CURRENCY="EUR"
api = Ctrader(SERVER,BROKER,LOGIN,PASSWORD,CURRENCY)
Real time quote
Subscribe to symbol
api.symbolSubscribe("EURUSD", "GBPUSD")
All symbols quote list
quote = api.quote()
print(quote)
# Output
{'EURUSD': {'bid': 1.02616, 'ask': 1.02618}, 'GBPUSD': {'bid': 1.21358, 'ask': 1.21362}}
Single symbol quote
quote = api.quote("EURUSD")
print(quote)
# Output
{'bid': 1.02612, 'ask': 1.02614}
Market position and pending order.
Market Position
api.buy("EURUSD", 0.01, 1.18, 1.19)
api.sell("EURUSD", 0.01, 1.19, 1.18)
Limit Orders
api.buyLimit("EURUSD", 0.01, 1.17, 1.19, 1.18)
api.sellLimit("EURUSD", 0.01, 1.23, 1.17, 1.22)
Stop Orders
api.buyStop("EURUSD", 0.01, 1.20, 1.24, 1.22)
api.sellStop("EURUSD", 0.01, 1.19, 1.17, 1.18)
List Positions
positions = api.positions()
print(positions)
List limit and stop Orders
orders = api.orders()
print(orders)
Cancle order by id
orders = api.orders()
for order in orders:
api.orderCancelById(order['ord_id'])
Close position by id
for position in positions:
api.positionCloseById(position['pos_id'], position['amount'])
cancel all Orders
api.cancel_all()
close all positions
api.close_all()
ToDo
- Account Information
- SL and TP
- Modify Orders
- Modify position
- real time bid & ask
Thanks for
@HarukaMa @douglasbarros
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ejtraderCT-1.0.4.tar.gz
(27.4 kB
view hashes)
Built Distribution
ejtraderCT-1.0.4-py3-none-any.whl
(26.5 kB
view hashes)
Close
Hashes for ejtraderCT-1.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1182138a422be703b111d9b84b26482a269f228b599f980a9c0642812a9e984 |
|
MD5 | 8afa7609716c274e8818a4b4ef16acb7 |
|
BLAKE2b-256 | f28fbcbdf08506823024fd7859f941b8d9ad9aa5140e8f637bc1111ab381d83c |