Automate your trading
Your Language
Your Rules
Turn your trading ideas into action with the GMI Edge API - code and automate your trading bots in any language you choose, including Python, C, C++ to C#, and beyond.

Benefits of Trading Bots vs. Manual Trading

24/7 Market Action
Bots never sleep — capture opportunities day and night, even while you rest.

Emotion-Free Trading
Remove fear and greed; bots execute your plan with zero hesitation.

Instant Reaction to Market Events
Automatically respond to price spikes, news, or volatility — faster than any human.

Scalability
Manage complex strategies or high-frequency trading at a scale that’s impossible manually.
How It Works

Register or Log In to GMI Members Area

Get your GMI EDGE Trading Account Credentials

Read the documentation and start writing your trading strategy

Launch your trading bot and watch it trade for you
Features

Multi-Language Freedom
Build your bot in any programming language—Python, C++, C#, Java, JavaScript, Go, and more. No restrictions.

Unlimited Automation Potential
No limits on the number or complexity of bots—scale up from simple bots to advanced multi-asset, multi-account strategies.

Cross-Platform Compatibility
Use the API from Windows, Mac, Linux, or even cloud servers—run your bots wherever you like.

Transparent, Modern Architecture
No hidden layers or proprietary script languages. Your code talks directly to our API for complete transparency and flexibility.
FAQ






Example of code for Trading Bot
import yaml
import httpx
import sys
import ssl
from datetime import datetime, timedelta
import time
def read_config(filename):
with open(filename, "r") as file:
return yaml.safe_load(file)
def check_response(response):
if response.status_code == httpx.codes.OK:
return
error_body = response.json()
error_code = error_body["Code"]
error_message = error_body["Error"]
print(f"[{error_code}] {error_message}")
sys.exit(-1)
def report_position(position):
order_id = position["OrderId"]
amount = position["Amount"]
symbol = position["Symbol"]
order_side = position["OrderSide"]
order_status = position["OrderStatus"]
print(f"#{order_id} {symbol} {amount} {order_side} {order_status}")
def time_to_seconds(time_text):
t = datetime.strptime(time_text, "%M:%S")
delta = timedelta(minutes=t.minute, seconds=t.second)
return delta.total_seconds()
def find_position_profit(orders_state, order_id):
pos_state = next(
order for order in orders_state if order["OrderId"] == order_id
)
return pos_state["Profit"]
if __name__ == "__main__":
print("Reading bot configuration...")
config = read_config("bot-config.yaml")
api_url = config["api-url"]
account = config["account"]
password = config["password"]
symbols = config["symbols"]
pause1 = config["pause1"]
pause1_sec = time_to_seconds(pause1)
pause2 = config["pause2"]
pause2_sec = time_to_seconds(pause2)
print("Done.")
print(f"Connecting to account {account} via {api_url}...")
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context.load_default_certs()
http = httpx.Client(verify=ssl_context)
login_response = http.post(
api_url + "/login", json={"BotId": account, "Password": password}
)
check_response(login_response)
print("Connected.")
access_token = login_response.json()["AccessToken"]
auth_headers = {"Authorization": "Bearer " + access_token}
try:
while True:
print("Checking my open positions...")
open_pos_response = http.get(
api_url + "/positionlist", headers=auth_headers
)
check_response(open_pos_response)
all_positions = open_pos_response.json()["Orders"]
my_positions = [
p for p in all_positions if p["OrderSource"] == "TRADING_API"
]
if len(my_positions) == 0:
print("No open positions.")
else:
for position in my_positions:
report_position(position)
print("Closing my open positions...")
for position in my_positions:
order_id = position["OrderId"]
close_pos_response = http.post(
api_url + "/closeposition",
json={"OrderId": order_id},
headers=auth_headers,
)
check_response(close_pos_response)
print("Closed.")
for symbol in symbols:
print(f"Checking symbol {symbol}...")
syminfo_response = http.post(
api_url + "/symbolinfo",
json={"Symbol": symbol},
headers=auth_headers,
)
check_response(syminfo_response)
min_lots = syminfo_response.json()["MinTradeAmount"]
lot_size = syminfo_response.json()["ContractSize"]
min_amount = min_lots * lot_size
print(f"Minimum tradable amount for {symbol}: {min_amount}")
print("Opening positions")
pos_ids = []
for symbol in symbols:
buy_pos_response = http.post(
api_url + "/sendorder",
json={
"Symbol": symbol,
"OrderSide": "BUY",
"OrderType": "MARKET",
"Amount": min_amount,
},
headers=auth_headers,
)
check_response(buy_pos_response)
report_position(buy_pos_response.json())
buy_pos_id = buy_pos_response.json()["OrderId"]
sell_pos_response = http.post(
api_url + "/sendorder",
json={
"Symbol": symbol,
"OrderSide": "SELL",
"OrderType": "MARKET",
"Amount": min_amount,
},
headers=auth_headers,
)
check_response(sell_pos_response)
report_position(sell_pos_response.json())
sell_pos_id = sell_pos_response.json()["OrderId"]
pos_ids.append((buy_pos_id, sell_pos_id))
print(f"Wait {pause1}...")
time.sleep(pause1_sec)
print("Checking profit and loss...")
account_state_response = http.get(
api_url + "/accountstate", headers=auth_headers
)
check_response(account_state_response)
balance = account_state_response.json()["AccountState"]["Balance"]
print(f"Account balance: {balance}")
orders_state = account_state_response.json()["OrderStates"]
to_close = []
for buy_pos_id, sell_pos_id in pos_ids:
buy_pos_profit = find_position_profit(orders_state, buy_pos_id)
sell_pos_profit = find_position_profit(
orders_state, sell_pos_id
)
print(f"#{buy_pos_id} PROFIT {buy_pos_profit}")
print(f"#{sell_pos_id} PROFIT {sell_pos_profit}")
if buy_pos_profit <= sell_pos_profit:
to_close.append(buy_pos_id)
else:
to_close.append(sell_pos_id)
print("Close less profitable position in each pair...")
for order_id in to_close:
print(f"Closing #{order_id}...")
close_response = http.post(
api_url + "/closeposition",
json={"OrderId": order_id},
headers=auth_headers,
)
check_response(close_response)
print("Done.")
Explanation
The described code defines the sequence of actions for Trading Bot:
- 1. Connect to Trading API for a specific account
- 2. Select target symbols
- 3. Identify all bot-opened positions for these symbols
- 4. Close all existing bot-initiated positions on selected symbols
- 5. Open 2 opposing positions for one symbol:
- BUY position
- SELL position
- 6. After 1 minute: Close the losing position (based on current PnL)
- 7. After 1 minute: Repeat entire cycle from Step 1
Our new GMI Edge Trading Platform!
Designed to empower your trading experience, Edge Platform brings a new era of possibilities to the world of forex trading.
Automate your trading. Your Language. Your Rules.
Turn your trading ideas into action with the GMI Edge API - code and automate your trading bots in any language you choose, including Python, C, C++ to C#, and beyond.