Ctrader Fix API
Project description
ToDo
- SL and TP
- Thread Save
- real time bid & ask
Python Ctrader Fix API
Installation
Tested on python 3.7 and 3.8
pip install ejtraderCT -U
or
python setup.py install
import
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)
You can create market or pending order with the commands.
Market Orders
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)
Positions
positions = api.positions()
print(positions)
for position in positions:
api.positionCloseById(position['pos_id'], position['amount'])
positions = api.positions()
print(positions)
Orders Manipulation
Corders = api.orders()
print(orders)
for order in orders:
api.orderCancelById(order['ord_id'])
orders = api.orders()
print(orders)
cancel all Orders
api.cancel_all()
close all positions
api.close_all()
Future add comming soon
Modify pending orders
api.modify()
Real time Data and history
history = api.history("GBPUSD", "M5", int(datetime.now().timestamp()) - 10000)
# print(history)
Account information
accountInfo = api.accountInfo()
print(accountInfo)
print(accountInfo['broker'])
print(accountInfo['balance'])
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.1.tar.gz
(25.0 kB
view hashes)
Built Distribution
ejtraderCT-1.0.1-py3-none-any.whl
(24.2 kB
view hashes)
Close
Hashes for ejtraderCT-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78866e91af1d1297fce191da2f4ac68839e2336a2e124f614560996f8be1e377 |
|
MD5 | 575b842c885eb2c69de8ca10563125d7 |
|
BLAKE2b-256 | 90aad6ad8e829c8393bd614fda60ff6624a5442f22c475e16f5a30961f4542e5 |