private void TransakcjaStop(TradeRecord tradeRecordStop) { try { SyncAPIConnector connector = new SyncAPIConnector(serverData); Credentials credentials = new Credentials(userId, password, "", "pixelNet"); LoginResponse loginResponse = APICommandFactory.ExecuteLoginCommand(connector, credentials, true); TRADE_OPERATION_CODE toc; if (tradeRecordStop.Cmd == 1) { toc = TRADE_OPERATION_CODE.SELL; } else { toc = TRADE_OPERATION_CODE.BUY; } double price = tradeRecordStop.Close_price.GetValueOrDefault(); double sl = 0.0; double tp = 0.0; string symbol = tradeRecordStop.Symbol; double?volume = tradeRecordStop.Volume; long order = tradeRecordStop.Order.GetValueOrDefault(); long expiration = 0; TradeTransInfoRecord ttCloseInfoRecord = new TradeTransInfoRecord( toc, TRADE_TRANSACTION_TYPE.ORDER_CLOSE, price, sl, tp, symbol, volume, order, "", expiration); TradeTransactionResponse closeTradeTransactionResponse = APICommandFactory.ExecuteTradeTransactionCommand(connector, ttCloseInfoRecord, true); LogoutResponse logoutResponse = APICommandFactory.ExecuteLogoutCommand(connector); } catch (Exception e) { MessageBox.Show(e.Message); } }
private void ListaInstrumentow() { try { SyncAPIConnector connector = new SyncAPIConnector(serverData); Credentials credentials = new Credentials(userId, password, "", "pixelNet"); LoginResponse loginResponse = APICommandFactory.ExecuteLoginCommand(connector, credentials, true); AllSymbolsResponse allSymbolsResponse = APICommandFactory.ExecuteAllSymbolsCommand(connector, true); ListaInstrumentow fx = new ListaInstrumentow() { Symbol = "FX" }; ListaInstrumentow cmd = new ListaInstrumentow() { Symbol = "CMD" }; ListaInstrumentow crt = new ListaInstrumentow() { Symbol = "CRT" }; foreach (SymbolRecord symbolRecord in allSymbolsResponse.SymbolRecords) { if (symbolRecord.CategoryName == "FX") { fx.Pozycje.Add(symbolRecord); } if (symbolRecord.CategoryName == "CMD") { cmd.Pozycje.Add(symbolRecord); } if (symbolRecord.CategoryName == "CRT") { crt.Pozycje.Add(symbolRecord); } } treev.Items.Add(fx); treev.Items.Add(cmd); treev.Items.Add(crt); LogoutResponse logoutResponse = APICommandFactory.ExecuteLogoutCommand(connector); } catch (Exception e) { MessageBox.Show(e.Message); } }
public void DaneInstrumentu() { try { SyncAPIConnector connector = new SyncAPIConnector(serverData); Credentials credentials = new Credentials(userId, password, "", "pixelNet"); LoginResponse loginResponse = APICommandFactory.ExecuteLoginCommand(connector, credentials, true); SymbolResponse symbolResponse = APICommandFactory.ExecuteSymbolCommand(connector, this.Nazwa); this.info = symbolResponse.Symbol; ulamek = Convert.ToInt32(info.Precision); double d = Convert.ToDouble(info.Ask); string strl = d.ToString("0"); dziesiatki = strl.Length; podzielp = Convert.ToInt32(Math.Pow(10, strl.Length)); LogoutResponse logoutResponse = APICommandFactory.ExecuteLogoutCommand(connector); } catch (Exception e) { MessageBox.Show(e.Message); } }
private void TransakcjaStart(string Nazwa, double volume, TRADE_OPERATION_CODE toc) { try { SyncAPIConnector connector = new SyncAPIConnector(serverData); Credentials credentials = new Credentials(userId, password, "", "pixelNet"); LoginResponse loginResponse = APICommandFactory.ExecuteLoginCommand(connector, credentials, true); SymbolResponse symbolResponse = APICommandFactory.ExecuteSymbolCommand(connector, Nazwa); double price = symbolResponse.Symbol.Ask.GetValueOrDefault(); double sl = 0.0; double tp = 0.0; string symbol = symbolResponse.Symbol.Symbol; long order = 0; long expiration = 0; TradeTransInfoRecord ttOpenInfoRecord = new TradeTransInfoRecord( toc, TRADE_TRANSACTION_TYPE.ORDER_OPEN, price, sl, tp, symbol, volume, order, "", expiration); TradeTransactionResponse tradeTransactionResponse = APICommandFactory.ExecuteTradeTransactionCommand(connector, ttOpenInfoRecord); LogoutResponse logoutResponse = APICommandFactory.ExecuteLogoutCommand(connector); } catch (Exception e) { MessageBox.Show(e.Message); } }
private void ListaTransakcji() { try { SyncAPIConnector connector = new SyncAPIConnector(serverData); Credentials credentials = new Credentials(userId, password, "", "pixelNet"); LoginResponse loginResponse = APICommandFactory.ExecuteLoginCommand(connector, credentials, true); TradesResponse tradesResponse = APICommandFactory.ExecuteTradesCommand(connector, true); listaTran.Items.Clear(); foreach (xAPI.Records.TradeRecord rec in tradesResponse.TradeRecords) { string rodz = ""; if (rec.Cmd == 1) { rodz = "Sell"; } else { rodz = "Buy"; } listaTran.Items.Add(new PozTran() { Nazwa = rec.Symbol, CenaZak = (double)rec.Open_price, Zysk = (double)rec.Profit, Rodzaj = rodz });; //if (rec.Profit > 30) TransakcjaStop(rec); LogoutResponse logoutResponse = APICommandFactory.ExecuteLogoutCommand(connector); } tradesResponse = null; } catch { } }
public void Notowania(PERIOD_CODE pc, long Zakres) { tabelaWynikow = new double[10000]; try { SyncAPIConnector connector = new SyncAPIConnector(serverData); Credentials credentials = new Credentials(userId, password, "", "pixelNet"); LoginResponse loginResponse = APICommandFactory.ExecuteLoginCommand(connector, credentials, true); double ms = DateTime.Now.Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds; long? msd = Convert.ToInt64(ms); long? msd1 = msd - (Zakres * (60 * 1000));//17800 10000min ChartRangeInfoRecord zakres = new ChartRangeInfoRecord(Nazwa, pc, msd1, msd, 0); ChartRangeResponse chartRangeResponse = APICommandFactory.ExecuteChartRangeCommand(connector, zakres); int tabdl = 0; int dlresp = chartRangeResponse.RateInfos.Count - 10000; double podz = dziesiatki + ulamek; podz = Math.Pow(10, podz); foreach (xAPI.Records.RateInfoRecord nota in chartRangeResponse.RateInfos) { if (tabdl >= dlresp) { tabelaWynikow[tabdl - dlresp] = (double)nota.Open / podz; } tabdl++; } LogoutResponse logoutResponse = APICommandFactory.ExecuteLogoutCommand(connector); } catch (Exception e) { MessageBox.Show(e.Message); } }