本文整理汇总了C#中SmartQuant.Instrument类的典型用法代码示例。如果您正苦于以下问题:C# Instrument类的具体用法?C# Instrument怎么用?C# Instrument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Instrument类属于SmartQuant命名空间,在下文中一共展示了Instrument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Subscribe
public override void Subscribe(Instrument instrument)
{
if (instrument.Parent != null)
{
this.strategyBySynthInstrument[instrument.Id] = this.strategyBySynthInstrument[instrument.Parent.Id];
this.strategyBySynthInstrument[instrument.Id].OnSubscribe(instrument);
return;
}
SellSideInstrumentStrategy sellSideInstrumentStrategy = (SellSideInstrumentStrategy)Activator.CreateInstance(base.GetType(), new object[]
{
this.framework,
string.Concat(new object[]
{
base.Name,
"(",
instrument,
")"
})
});
this.SetupStrategy(sellSideInstrumentStrategy);
sellSideInstrumentStrategy.Instrument = instrument;
this.strategyBySynthInstrument[instrument.Id] = sellSideInstrumentStrategy;
sellSideInstrumentStrategy.OnSubscribe(instrument);
sellSideInstrumentStrategy.dataProvider = base.DataProvider;
sellSideInstrumentStrategy.executionProvider = base.ExecutionProvider;
sellSideInstrumentStrategy.raiseEvents = true;
base.AddStrategy(sellSideInstrumentStrategy, false);
sellSideInstrumentStrategy.OnStrategyStart();
}
示例2: GetData_Instrument
// 从分类好的目录中取中所有合约
private SortedDictionary<int, FileInfo> GetData_Instrument(Instrument inst)
{
SortedDictionary<int, FileInfo> resultList = new SortedDictionary<int, FileInfo>();
if (string.IsNullOrEmpty(DataPath_Instrument))
return resultList;
// 直接查找某一目录是否存在
string instrument = inst.Symbol;
int i = inst.Symbol.IndexOf('.');
if(i>=0)
{
instrument = instrument.Substring(0,i);
}
var di = new DirectoryInfo(DataPath_Instrument);
if (!di.Exists)
return resultList;
var list = di.GetDirectories(instrument, System.IO.SearchOption.AllDirectories);
foreach(var l in list)
{
UnionAndUpdate(resultList, GetFiles(l, inst.Symbol));
}
return resultList;
}
示例3: HistoricalDataRequest
public HistoricalDataRequest(Instrument instrument, DateTime dateTime1, DateTime dateTime2, byte dataType)
{
this.Instrument = instrument;
this.DateTime1 = dateTime1;
this.DateTime2 = dateTime2;
this.DataType = dataType;
}
示例4: BarFactoryItem
protected BarFactoryItem(Instrument instrument, BarType barType, long barSize)
{
this.factory = null;
this.instrument = instrument;
this.barType = barType;
this.barSize = barSize;
}
示例5: OnInit
protected override void OnInit()
{
this.instrument = (Instrument) this.args[0];
this.InitDataSeriesList();
this.InitDataSeriesViewer();
this.Text = string.Format("Data [{0}]", (object) this.instrument.Symbol);
}
示例6: Read
public override object Read(BinaryReader reader)
{
reader.ReadByte();
int id = reader.ReadInt32();
InstrumentType type = (InstrumentType)reader.ReadByte();
string symbol = reader.ReadString();
string description = reader.ReadString();
byte currencyId = reader.ReadByte();
string exchange = reader.ReadString();
Instrument instrument = new Instrument(id, type, symbol, description, currencyId, exchange);
instrument.tickSize = reader.ReadDouble();
instrument.maturity = new DateTime(reader.ReadInt64());
instrument.factor = reader.ReadDouble();
instrument.strike = reader.ReadDouble();
instrument.putcall = (PutCall)reader.ReadByte();
instrument.margin = reader.ReadDouble();
int num = reader.ReadInt32();
for (int i = 0; i < num; i++)
{
AltId altId = new AltId();
altId.providerId = reader.ReadByte();
altId.symbol = reader.ReadString();
altId.exchange = reader.ReadString();
instrument.altId.Add(altId);
}
return instrument;
}
示例7: Subscribe
public void Subscribe(IDataProvider provider, Instrument instrument)
{
if (provider.Status != ProviderStatus.Connected)
{
provider.Connect();
}
Dictionary<Instrument, int> dictionary = null;
if (!this.subscriptions.TryGetValue((int)provider.Id, out dictionary))
{
dictionary = new Dictionary<Instrument, int>();
this.subscriptions[(int)provider.Id] = dictionary;
}
int num = 0;
bool flag = false;
if (!dictionary.TryGetValue(instrument, out num))
{
flag = true;
num = 1;
}
else
{
if (num == 0)
{
flag = true;
}
num++;
}
dictionary[instrument] = num;
if (flag)
{
provider.Subscribe(instrument);
}
}
示例8: ImportTask
public ImportTask(Instrument instrument)
{
this.Instrument = instrument;
this.State = ImportTaskState.Pending;
this.Count = 0;
this.TotalNum = 0;
this.Message = string.Empty;
}
示例9: textBox_Instrument_Validating
private void textBox_Instrument_Validating(object sender, CancelEventArgs e)
{
Instrument = SmartQuant.Shared.Global.Framework.InstrumentManager.Get((sender as TextBox).Text);
errorProvider1.Clear();
if (Instrument == null)
{
errorProvider1.SetError(textBox_Instrument,"合约不存在");
}
}
示例10: Delete
public void Delete(Instrument instrument)
{
this.instruments.Remove(instrument);
if (this.server != null && instrument.isPersistent)
{
this.server.Delete(instrument);
}
this.framework.eventServer.OnInstrumentDeleted(instrument);
}
示例11: GetById
public Instrument GetById(int id)
{
Instrument instrument = this.instruments.GetById(id);
if (instrument == null)
{
instrument = new Instrument(id, InstrumentType.Synthetic, Guid.NewGuid().ToString(), "", 1);
this.instruments.Add(instrument);
}
return instrument;
}
示例12: InstrumentViewItem
public InstrumentViewItem(Instrument instrument)
: base(new string[5])
{
this.Instrument = instrument;
this.SubItems[0].Text = instrument.Symbol;
this.SubItems[1].Text = instrument.Type.ToString();
this.SubItems[2].Text = instrument.Exchange;
this.SubItems[3].Text = CurrencyId.GetName(instrument.CurrencyId);
this.SubItems[4].Text = instrument.Maturity == DateTime.MinValue ? string.Empty : instrument.Maturity.ToShortDateString();
}
示例13: Order
public Order(IExecutionProvider provider, Instrument instrument, OrderType type, OrderSide side, double qty, double price = 0.0, double stopPx = 0.0, TimeInForce timeInForce = TimeInForce.Day, string text = "")
: this()
{
this.provider = provider;
this.instrument = instrument;
this.type = type;
this.side = side;
this.qty = qty;
this.price = price;
this.stopPx = stopPx;
this.timeInForce = timeInForce;
this.text = text;
this.portfolio = null;
}
示例14: Add
public void Add(Instrument instrument, bool save = true)
{
if (this.Contains(instrument.symbol))
{
throw new ApplicationException("Instrument with the same symbol is already present in the framework : " + instrument.symbol);
}
instrument.Id = this.next_id;
this.next_id++;
this.instruments.Add(instrument);
if (save && this.server != null)
{
this.server.Save(instrument);
}
this.framework.eventServer.OnInstrumentAdded(instrument);
}
示例15: AddInstance
public void AddInstance(Instrument instrument, InstrumentStrategy strategy)
{
strategy.instruments.Add(instrument);
strategy.instrument = instrument;
strategy.raiseEvents = true;
strategy.dataProvider = this.dataProvider;
strategy.executionProvider = this.executionProvider;
this.Add(strategy);
if (base.Instruments.GetById(instrument.id) == null)
{
base.Instruments.Add(instrument);
}
strategy.status = StrategyStatus.Running;
strategy.OnStrategyStart();
}