Skip to content

Get start

document version

9/15 v0.3 !!!Start New!!

add multi real time candle sample add stop real time candle add get_asset_data

Debug Mode ON

import logging 
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)

Login

Maybe Olymptrade login fail, because Olymptrade try to anti robot,sometime login fail

from olymptradeapi.stable_api import Olymptrade 
account=Olymptrade(email,password)
_,r=account.connect()

Get Balance

get_balance

from olymptradeapi.stable_api import Olymptrade 
account=Olymptrade(email,password)
_,r=account.connect()
balance=account.get_balance()
print(balance)

Get Asset Data

from olymptradeapi.stable_api import Olymptrade 
account=Olymptrade(email,password)
_,r=account.connect()
print(account.get_asset_data())

Buy

from olymptradeapi.stable_api import Olymptrade 
account=Olymptrade(email,password)
_,r=account.connect()
asset="EURUSD"
amount=12
dir="up"#"down"
pos=0
duration=60#sec
d=account.buy(asset,amount,dir,pos,duration)
print(d) 

Check Win

from olymptradeapi.stable_api import Olymptrade 
account=Olymptrade(email,password)
_,r=account.connect()
asset="EURUSD"
amount=12
dir="up"#"down"
pos=0
duration=60#sec
d=account.buy(asset,amount,dir,pos,duration)
order_id=d["id"]
profit=account.check_win(order_id)
print(profit)
 

Change Balance

Default ACCOUNT_MODE is "PRACTICE"

from olymptradeapi.stable_api import Olymptrade 
account=Olymptrade(email,password)
ACCOUNT_MODE="REAL"#"PRACTICE"
account.change_balance(ACCOUNT_MODE)

REAL TIME CANDLE

Each connect only accept 2 realtime candle stream

from olymptradeapi.stable_api import Olymptrade 
#import logging 
#logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
account=Olymptrade(email,password)
_,r=account.connect()
goal="EURUSD"
sub_uid=account.start_candles_stream(goal,60)
while True: 
    c,d=account.get_realtime_candles(goal,60)
    print(c,d)
account.start_candles_stream(sub_uid)

Multi Real Time Candle Stream

from olymptradeapi.stable_api import Olymptrade 
#import logging 
#logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
account=Olymptrade(email,password)
_,r=account.connect()

account2=Olymptrade(email,password)
_,r=account2.connect()

sub_uid_EURUSD=account.start_candles_stream("EURUSD",60)
sub_uid_GBPUSD=account.start_candles_stream("GBPUSD",60)

sub_uid_USDJPY=account2.start_candles_stream("USDJPY",60)
 
while True: 
    print(account.get_realtime_candles("EURUSD",60))

    print(account2.get_realtime_candles("USDJPY",60))
 
account.start_candles_stream(sub_uid_EURUSD)
account.start_candles_stream(sub_uid_GBPUSD)

account2.start_candles_stream(sub_uid_USDJPY)