private void btnAutoTransferStart_Click(object sender, EventArgs e) { if (b.AuthStatus != AuthStatusType.AS_OK) { Log("Not yet authorized." + Environment.NewLine, false); return; } try { interval = Convert.ToInt32(tbInterval.Text) * 60000; } catch (Exception ex) { Log("Invalid number-format in interval-input" + Environment.NewLine, false); return; } if (interval < 120000) { Log("Interval too short, needs to be at least 2 minutes" + Environment.NewLine, false); return; } readOnly = cbReadOnly.Checked; singleUser = cbSingleUser.Checked; if (singleUser) singleUserName = tbSingleUserName.Text; qtyLimit = cbMaxQuantity.Checked; if (qtyLimit) { try { maxQuantity = Convert.ToInt32(tbMaxQuantity.Text); } catch (Exception ex) { Log("Invalid number-format for max. quantity" + Environment.NewLine, false); return; } } DateTime d = dtpCustomStartDate.Value; DateTime ti = dtpCustomStartTime.Value; DateTime d0 = new DateTime(d.Year, d.Month, d.Day, ti.Hour, ti.Minute, ti.Second); if (cbCustomStartTime.Checked && d0.CompareTo(DateTime.Now) > 0) { Log("Can't select custom starting date/time in the future. Aborting.", false); return; } aB = new AutoTransfer(b, interval); aB.ReadOnly = readOnly; aB.SingleUser = singleUser; aB.SingleUserName = singleUserName; aB.QtyLimit = qtyLimit; aB.MaxQuantity = maxQuantity; aB.Logger = ATLog; aL = new AutoTransfer(l, interval); aL.ReadOnly = readOnly; aL.SingleUser = singleUser; aL.SingleUserName = singleUserName; aL.QtyLimit = qtyLimit; aL.MaxQuantity = maxQuantity; aL.Logger = ATLog; // TransferRule constructor arguments // - account performing transfers (BTCTLink object, in this code either 'b' or 'l') // - asset to be transferred in by users // - asset to be transferred out // - minimum number of input units (anything less is returned) // - fixed fee deducted from number of units // - true = fee is deducted from input units. False = fee deducted from output units // - multiplier between input and output // - true = input is multiplied to obtain output. False = input is divided by multiplier to obtain output (remainder is returned) // Make sure to add each rule to the correct AutoTransfer object. In this code, aB monitors the BTC-TC account, aL monitors LTC-Global. // DMS.PURCHASE -> DMS.MINING + DMS.SELLING /* TransferRule t1 = new TransferRule(b, "DMS.PURCHASE", "DMS.MINING", 1, 0, true, 1, true); TransferRule t2 = new TransferRule(b, "DMS.PURCHASE", "DMS.SELLING", 1, 0, true, 1, true); aB.AddRule(t1); aB.AddRule(t2); */ // ASICMINER-PT on LTC-Global /* TransferRule t1 = new TransferRule(l, "ASICMINER-PT", "TEST-ASICMINER", 1, 1, false, 100, true); aB.AddRule(t1); TransferRule t2 = new TransferRule(b, "TEST-ASICMINER", "ASICMINER-PT", 101, 1, true, 100, false); aL.AddRule(t2); */ // LTC-G & BTC-TC "HIGH / LOW" fund /* TransferRule t1 = new TransferRule(l, "BTC-HIGH", "LTC-HIGH", 2, 1, true, 1, true); TransferRule t2 = new TransferRule(l, "BTC-LOW", "LTC-LOW", 2, 1, true, 1, true); aB.AddRule(t1); aB.AddRule(t2); TransferRule t3 = new TransferRule(b, "LTC-HIGH", "BTC-HIGH", 2, 1, true, 1, true); TransferRule t4 = new TransferRule(b, "LTC-LOW", "BTC-LOW", 2, 1, true, 1, true); aL.AddRule(t3); aL.AddRule(t4); */ // For test-purposes TransferRule t1 = new TransferRule(b, "DMS.SELLING", "BTC-GROWTH", 1, 0, true, 1, true); TransferRule t2 = new TransferRule(b, "DMS.SELLING", "TAT.ASICMINER", 1, 0, true, 1, true); aB.AddRule(t1); aB.AddRule(t2); // Read in a file with BTC-TC <-> LTC-Global username pairs. // Each line has 1 pair of usernames, BTC-TC first, followed by whitespace, followed by LTC-Global. // Comment out this section if no cross-exchange transfers are done. try { AutoTransfer.ReadNameDB("namedb.txt"); } catch (Exception ex) { Log("Error: " + ex.Message + Environment.NewLine, false); return; } // Add/remove comments below depending on which account is being monitored. aB.StartTimer(cbCustomStartTime.Checked, d0, this); aL.StartTimer(cbCustomStartTime.Checked, d0, this); }
public void AddRule(TransferRule t) { _transferRules.Add(t); }