Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit987aa3e

Browse files
committed
added trading with FXCM tutorial
1 parentdb8b668 commit987aa3e

File tree

5 files changed

+132
-1
lines changed

5 files changed

+132
-1
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
5353
-[How to Convert Text to Speech in Python](https://www.thepythoncode.com/article/convert-text-to-speech-in-python). ([code](machine-learning/text-to-speech))
5454
-[How to Perform Voice Gender Recognition using TensorFlow in Python](https://www.thepythoncode.com/article/gender-recognition-by-voice-using-tensorflow-in-python). ([code](https://github.com/x4nth055/gender-recognition-by-voice))
5555
-[Introduction to Finance and Technical Indicators with Python](https://www.thepythoncode.com/article/introduction-to-finance-and-technical-indicators-with-python). ([code](machine-learning/technical-indicators))
56-
56+
-[Algorithmic Trading with FXCM Broker in Python](https://www.thepythoncode.com/article/trading-with-fxcm-broker-using-fxcmpy-library-in-python). ([code](machine-learning/trading-with-fxcm))
5757

5858
-###[General Python Topics](https://www.thepythoncode.com/topic/general-python-topics)
5959
-[How to Make Facebook Messenger bot in Python](https://www.thepythoncode.com/article/make-bot-fbchat-python). ([code](general/messenger-bot))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#[Algorithmic Trading with FXCM Broker in Python](https://www.thepythoncode.com/article/trading-with-fxcm-broker-using-fxcmpy-library-in-python)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fxcmpy
2+
python-socketio
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"metadata": {
3+
"language_info": {
4+
"codemirror_mode": {
5+
"name":"ipython",
6+
"version":3
7+
},
8+
"file_extension":".py",
9+
"mimetype":"text/x-python",
10+
"name":"python",
11+
"nbconvert_exporter":"python",
12+
"pygments_lexer":"ipython3",
13+
"version":3
14+
},
15+
"orig_nbformat":2,
16+
"kernelspec": {
17+
"name":"python_defaultSpec_1596535581821",
18+
"display_name":"Python 3.6.6 64-bit"
19+
}
20+
},
21+
"nbformat":4,
22+
"nbformat_minor":2,
23+
"cells": [
24+
{
25+
"cell_type":"code",
26+
"execution_count":null,
27+
"metadata": {},
28+
"outputs": [],
29+
"source": [
30+
"from fxcmpy import fxcmpy\n",
31+
"\n",
32+
"# generate this once you create your demo account\n",
33+
"# this is fake token, just for demonstration\n",
34+
"ACCESS_TOKEN =\"8438834e8edaff70ca3db0088a8d6c5c37f51279\""
35+
]
36+
},
37+
{
38+
"cell_type":"code",
39+
"execution_count":null,
40+
"metadata": {
41+
"tags": []
42+
},
43+
"outputs": [],
44+
"source": [
45+
"try:\n",
46+
" fxcm_con = fxcmpy(access_token=ACCESS_TOKEN, server=\"demo\")\n",
47+
" print(\"Is connected:\", fxcm_con.is_connected())\n",
48+
"\n",
49+
"except Exception as e:\n",
50+
" print(e)"
51+
]
52+
},
53+
{
54+
"cell_type":"code",
55+
"execution_count":null,
56+
"metadata": {
57+
"tags": []
58+
},
59+
"outputs": [],
60+
"source": [
61+
"fxcm_con.open_trade(symbol=\"US30\",amount=1,is_buy=True,time_in_force=\"GTC\",order_type=\"AtMarket\")"
62+
]
63+
},
64+
{
65+
"cell_type":"code",
66+
"execution_count":null,
67+
"metadata": {
68+
"tags": []
69+
},
70+
"outputs": [],
71+
"source": [
72+
"trade_id = fxcm_con.get_open_trade_ids()[0]\n",
73+
"print(\"Closing trade:\", trade_id)\n",
74+
"fxcm_con.close_trade(trade_id=trade_id,amount=1)"
75+
]
76+
},
77+
{
78+
"cell_type":"code",
79+
"execution_count":null,
80+
"metadata": {
81+
"tags": []
82+
},
83+
"outputs": [],
84+
"source": [
85+
"fxcm_con.open_trade(symbol=\"US30\",amount=1,is_buy=True,time_in_force=\"GTC\",order_type=\"AtMarket\",is_in_pips=True,limit=15,stop=-50)"
86+
]
87+
},
88+
{
89+
"cell_type":"code",
90+
"execution_count":null,
91+
"metadata": {},
92+
"outputs": [],
93+
"source": [
94+
"fxcm_con.close()"
95+
]
96+
},
97+
{
98+
"cell_type":"code",
99+
"execution_count":null,
100+
"metadata": {},
101+
"outputs": [],
102+
"source": []
103+
}
104+
]
105+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
fromfxcmpyimportfxcmpy
2+
3+
# generate this once you create your demo account
4+
# this is fake token, just for demonstration
5+
ACCESS_TOKEN="8438834e8edaff70ca3db0088a8d6c5c37f51279"
6+
7+
try:
8+
fxcm_con=fxcmpy(access_token=ACCESS_TOKEN,server="demo")
9+
print("Is connected:",fxcm_con.is_connected())
10+
11+
exceptExceptionase:
12+
print(e)
13+
14+
15+
fxcm_con.open_trade(symbol="US30",amount=1,is_buy=True,time_in_force="GTC",order_type="AtMarket")
16+
17+
trade_id=fxcm_con.get_open_trade_ids()[0]
18+
print("Closing trade:",trade_id)
19+
fxcm_con.close_trade(trade_id=trade_id,amount=1)
20+
21+
fxcm_con.open_trade(symbol="US30",amount=1,is_buy=True,time_in_force="GTC",order_type="AtMarket",is_in_pips=True,limit=15,stop=-50)
22+
23+
fxcm_con.close()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp