private BitFlyer(string apikey, string apisecret) { ApiKey = apikey; ApiSecret = apisecret; m_api = new BitflyerClient(ApiKey, ApiSecret); m_instance = this; }
static void Main(string[] args) { // 通信用クライアント生成 client = new BitflyerClient( "xxxxxxx", // ※実際の API Key に差し替えること "xxxxxxx", // ※実際の API Secret に差し替えること ProductCode.FX_BTC_JPY // 今回は BTC-FX を選択 ); // 非同期なタスクを生成 Task.Run(async() => { try { await BotLogic(); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } }).Wait(); // タスクが終わるまで待つ }
/// <summary> /// Bitflyerの建玉の手じまいをする /// </summary> /// <param name="client"></param> /// <returns></returns> public static async Task Tejimai(BitflyerClient client) { await client.CancelAllOrders(); double buy = 0; double sell = 0; try { Console.WriteLine("leave all positions"); var positions = await client.GetMyPositions(); foreach (var p in positions) { if (p.Side == OrderSide.BUY) { sell += p.Size; } else if (p.Side == OrderSide.SELL) { buy += p.Size; } } if (sell >= 0.001) { //sell = ToRoundDown(sell, 3); await client.Sell(sell); } if (buy >= 0.001) { //buy = ToRoundDown(buy, 3); await client.Buy(buy); } } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message + "," + sell + "," + buy); } }
static void Main(string[] args) { // 通信用クライアント生成 (apiKey, apiSecret はご自身のもので差し替えてください) client = new BitflyerClient( "xxxxxxxxxxxxx", "xxxxxxxxxxxxx", ProductCode.FX_BTC_JPY, timeoutSec: 6 ); Task.Run(async() => { try { // 資産情報を取得・表示 // await ShowAssetInfo(); // 現在の板情報を取得・表示 //await ShowBoard(); // 自分の注文情報を取得・表示 // await ShowMyActiveOrders(); // 自分の注文を1個だけキャンセル await CancelOneOrder(); // 実際の注文 // await SendSomeOrders(); // 注文の取り消し //await client.CancelAllOrders(); } catch (Exception ex) { Console.WriteLine("AnyError: " + ex.Message); } }).Wait(); }
private async void Form1_Load(object sender, EventArgs e) { String key = bfTrader.Properties.Settings.Default.key; String secret = bfTrader.Properties.Settings.Default.secret; if (key != null && secret != null && 0 < key.Length && 0 < secret.Length) { // use stored value } else if (InputBox(ref key, ref secret) != DialogResult.OK) { bfTrader.Properties.Settings.Default.key = ""; bfTrader.Properties.Settings.Default.secret = ""; bfTrader.Properties.Settings.Default.Save(); listBox1.Items.Add("Failed to read API key."); Application.Exit(); } if (key != null && secret != null && 0 < key.Length && 0 < secret.Length) { bfTrader.Properties.Settings.Default.key = key; bfTrader.Properties.Settings.Default.secret = secret; bfTrader.Properties.Settings.Default.Save(); client = new BitflyerClient(key, secret, ProductCode.FX_BTC_JPY); await getOrderBook(); } else { bfTrader.Properties.Settings.Default.key = ""; bfTrader.Properties.Settings.Default.secret = ""; bfTrader.Properties.Settings.Default.Save(); listBox1.Items.Add("Failed to read API key."); Application.Exit(); } }
public Form1() { InitializeComponent(); client = new BitflyerClient("", "", ProductCode.FX_BTC_JPY); client = new BitflyerClient("", "", ProductCode.FX_BTC_JPY); }