ChipaDocs /
Documentation /
PocketOptionAPI Async
Examples
Get Connection Stats
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 () Place a CALL Order
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 () Get Candles as DataFrame
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 () Get Candles (List)
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 () Check Win
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 () Get Active Orders
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 () Get Balance
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 () Check Order Result
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 ()