Opublikowano:
Aktualizacja:
Handel algorytmiczny polega na automatycznym zawieraniu transakcji na platformie transakcyjnej brokera. Platforma taka musi posiadać interfejs komunikacyjny API, za pomocą którego nasz program realizuje transakcje kupna lub sprzedaży. Przykładowym brokerem posiadającym API jest broker XTB (https://www.xtb.com). Broker udostępnia interfejs komunikacyjny o nazwie xAPI, którego dokumentacja interfejsu znajduje się pod adresem: http://developers.xstore.pro/documentation.
Poniżej znajduje się przykładowy test interfejsu xAPI na koncie demo.
Na początku uruchamiamy funkcję my_connect()*, która inicjuje połączenie z xAPI.
my_connect()
Możemy sprzedać parę walutową EURUSD (zagrać na spadek) za pomocą funkcji my_price()* oraz my_transaction()*. Wolumen transakcji wynosi 0.02 , stop loss ustawiono na cenę o 0.001 wyższą od aktualnej, take profit ustawiono na cenę o 0.003 niższą od aktualnej.
symbol="EURUSD"
my_price(symbol)
order_id=my_transaction("sprzedaj",symbol,0.02,bid_v+0.001,bid_v-0.003)
W celu zamknięcia wcześniej otworzonej pozycji o wolumenie 0.02 EURUSD uruchamiamy funkcję zamknij()*.
zamknij(order_id,symbol,0.02)
Analogiczne postępujemy aby zakupić parę walutową.
symbol="EURUSD"
my_price(symbol)
order_id=my_transaction("kup",symbol,0.02,ask_v-0.001,ask_v+0.003)
zamknij(order_id,symbol,0.02)
* Kod źródłowy funkcji znaleźć w strefie PREMIUM.
© 2025 All Rights Reserved.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Kopiowanie wszystkich kodów tylko dla użytkowników PREMIUM.