forked from ChipaDevTeam/PocketOptionAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.html
More file actions
140 lines (132 loc) · 5.52 KB
/
examples.html
File metadata and controls
140 lines (132 loc) · 5.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Examples - PocketOptionAPI Async Docs</title>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">
</head>
<body>
<header>
<h1>PocketOptionAPI Async</h1>
<nav>
<a href="index.html">Home</a>
<a href="quickstart.html">Quickstart</a>
<a href="api.html">API Reference</a>
<a href="examples.html">Examples</a>
<a href="faq.html">FAQ</a>
</nav>
</header>
<main>
<h2>Examples</h2>
<div class="card">
<h3>Get Connection Stats</h3>
<pre><code>from pocketoptionapi_async import AsyncPocketOptionClient
async def main():
SSID = input("Enter your SSID: ")
client = AsyncPocketOptionClient(SSID, is_demo=True, enable_logging=False)
await client.connect()
stats = await client.get_connection_stats()
print(f"Connection Stats: {stats}")
await client.disconnect()
</code></pre>
<h3>Place a CALL Order</h3>
<pre><code>from pocketoptionapi_async import AsyncPocketOptionClient, OrderDirection
async def main():
SSID = input("Enter your SSID: ")
client = AsyncPocketOptionClient(SSID, is_demo=True, enable_logging=False)
await client.connect()
amount = float(input("Enter the amount to invest: "))
symbol = input("Enter the symbol (e.g., 'EURUSD_otc'): ")
direction = OrderDirection.CALL
order = await client.place_order(asset=symbol, amount=amount, direction=direction, duration=60)
print(f"Order placed successfully: {order.order_id}, amount: {order.amount}, direction: {order.direction}, duration: {order.duration}")
await client.disconnect()
</code></pre>
<h3>Get Candles as DataFrame</h3>
<pre><code>from pocketoptionapi_async import AsyncPocketOptionClient
async def main():
SSID = input("Enter your SSID: ")
client = AsyncPocketOptionClient(SSID, is_demo=True, enable_logging=False)
await client.connect()
candles_df = await client.get_candles_dataframe(asset='EURUSD_otc', timeframe=60)
print(candles_df)
await client.disconnect()
</code></pre>
<h3>Get Candles (List)</h3>
<pre><code>from pocketoptionapi_async import AsyncPocketOptionClient
async def main():
SSID = input("Enter your SSID: ")
client = AsyncPocketOptionClient(SSID, is_demo=True, enable_logging=False)
await client.connect()
candles = await client.get_candles(asset='EURUSD_otc', timeframe=60)
for candle in candles:
print(f"open: {candle.open}, close: {candle.close}, high: {candle.high}, low: {candle.low}, volume: {candle.volume}, timestamp: {candle.timestamp}")
await client.disconnect()
</code></pre>
<h3>Check Win</h3>
<pre><code>from pocketoptionapi_async import AsyncPocketOptionClient, OrderDirection
async def main():
SSID = input("Enter your SSID: ")
client = AsyncPocketOptionClient(SSID, is_demo=True, enable_logging=False)
await client.connect()
amount = float(input("Enter the amount to invest: "))
symbol = input("Enter the symbol (e.g., 'EURUSD_otc'): ")
direction = OrderDirection.PUT
order = await client.place_order(asset=symbol, amount=amount, direction=direction, duration=5)
check_win = await client.check_win(order.order_id)
print(f"Order placed successfully: {order}")
print(f"Check win result: {check_win}")
await client.disconnect()
</code></pre>
<h3>Get Active Orders</h3>
<pre><code>from pocketoptionapi_async import AsyncPocketOptionClient
async def main():
SSID = input("Enter your SSID: ")
client = AsyncPocketOptionClient(SSID, is_demo=True, enable_logging=False)
await client.connect()
orders = await client.get_active_orders()
if orders:
print("Active Orders:")
for order in orders:
print(f"Order ID: {order['id']}, Amount: {order['amount']}, Status: {order['status']}")
else:
print("No active orders found.")
await client.disconnect()
</code></pre>
<h3>Get Balance</h3>
<pre><code>from pocketoptionapi_async import AsyncPocketOptionClient
async def main():
SSID = input("Enter your SSID: ")
client = AsyncPocketOptionClient(SSID, is_demo=True, enable_logging=False)
await client.connect()
balance = await client.get_balance()
print(f"Your balance is: {balance.balance}, currency: {balance.currency}")
await client.disconnect()
</code></pre>
<h3>Check Order Result</h3>
<pre><code>from pocketoptionapi_async import AsyncPocketOptionClient, OrderDirection
async def main():
SSID = input("Enter your SSID: ")
client = AsyncPocketOptionClient(SSID, is_demo=True, enable_logging=False)
await client.connect()
amount = float(input("Enter the amount to invest: "))
symbol = input("Enter the symbol (e.g., 'EURUSD_otc'): ")
direction = OrderDirection.PUT
order = await client.place_order(asset=symbol, amount=amount, direction=direction, duration=5)
result = await client.check_order_result(order.order_id)
if result:
print(f"Order placed successfully: {result}")
else:
print("Order result is None, please check the order status manually.")
await client.disconnect()
</code></pre>
</div>
<div class="advert">
Want a custom trading bot? <a href="https://shop.chipatrade.com/products/create-your-bot?variant=42924637487206" target="_blank">Let us build it for you!</a>
</div>
</main>
</body>
<script src="codeblock.js"></script>
</html>