order_calc_profit

Belirtilen alım-satım işlemi için hesap para birimi cinsinden kârı geri döndürür.

order_calc_profit(
   action,          // emir tipi (ORDER_TYPE_BUY veya ORDER_TYPE_SELL)
   symbol,          // sembol adı
   volume,          // hacim
   price_open,      // açılış fiyatı
   price_close      // kapanış fiyatı
   );

Parametreler

action

[in]  Emir tipi iki ORDER_TYPE sayım değerinden biri olabilir: ORDER_TYPE_BUY veya ORDER_TYPE_SELL. Gerekli adsız parametre.

symbol

[in]  Finansal enstrüman adı. Gerekli adsız parametre.

volume

[in]  İşlem hacmi. Gerekli adsız parametre.

price_open

[in]  Açılış fiyatı. Gerekli adsız parametre.

price_close

[in]  Kapanış fiyatı. Gerekli adsız parametre.

Geri dönüş değeri

Başarılı olursa gerçek değer, aksi takdirde None geri döner. Hataya ilişkin bilgiler last_error() kullanılarak elde edilebilir.

Not

Fonksiyon, mevcut hesapta ve mevcut alım-satım ortamında bir alım-satım işleminin sonucunun hesaplanmasına olanak sağlar. Fonksiyon, OrderCalcProfit'e benzerdir.

Örnek:

import MetaTrader5 as mt5
# MetaTrader 5 paketi ile ilgili verileri görüntüle
print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)
 
# MetaTrader 5 terminaline bağlantı kur
if not mt5.initialize():
    print("initialize() failed, error code =",mt5.last_error())
    quit()
 
# hesap para birimini elde et
account_currency=mt5.account_info().currency
print("Account сurrency:",account_currency)
 
# sembol listesini oluştur
symbols = ("EURUSD","GBPUSD","USDJPY")
print("Symbols to check margin:", symbols)
# alış ve satış için karı hesapla
lot=1.0
distance=300
for symbol in symbols:
    symbol_info=mt5.symbol_info(symbol)
    if symbol_info is None:
        print(symbol,"not found, skipped")
        continue
    if not symbol_info.visible:
        print(symbol, "is not visible, trying to switch on")
        if not mt5.symbol_select(symbol,True):
            print("symbol_select({}}) failed, skipped",symbol)
            continue
    point=mt5.symbol_info(symbol).point
    symbol_tick=mt5.symbol_info_tick(symbol)
    ask=symbol_tick.ask
    bid=symbol_tick.bid
    buy_profit=mt5.order_calc_profit(mt5.ORDER_TYPE_BUY,symbol,lot,ask,ask+distance*point)
    if buy_profit!=None:
        print("   buy {} {} lot: profit on {} points => {} {}".format(symbol,lot,distance,buy_profit,account_currency));
    else:
        print("order_calc_profit(ORDER_TYPE_BUY) failed, error code =",mt5.last_error())
    sell_profit=mt5.order_calc_profit(mt5.ORDER_TYPE_SELL,symbol,lot,bid,bid-distance*point)
    if sell_profit!=None:
        print("   sell {} {} lots: profit on {} points => {} {}".format(symbol,lot,distance,sell_profit,account_currency));
    else:
        print("order_calc_profit(ORDER_TYPE_SELL) failed, error code =",mt5.last_error())
    print()
 
# MetaTrader 5 terminaline olan bağlantıyı kapat
mt5.shutdown()
 
 
Sonuç:
MetaTrader5 package author:  MetaQuotes Software Corp.
MetaTrader5 package version:  5.0.29
 
Account сurrency: USD
Symbols to check margin: ('EURUSD', 'GBPUSD', 'USDJPY')
   buy EURUSD 1.0 lot: profit on 300 points => 300.0 USD
   sell EURUSD 1.0 lot: profit on 300 points => 300.0 USD
 
   buy GBPUSD 1.0 lot: profit on 300 points => 300.0 USD
   sell GBPUSD 1.0 lot: profit on 300 points => 300.0 USD
 
   buy USDJPY 1.0 lot: profit on 300 points => 276.54 USD
   sell USDJPY 1.0 lot: profit on 300 points => 278.09 USD

Ayrıca bakınız

order_calc_margin, order_check