Download:The first financial management course for programmers Python quantitative trading system combat
To build an automatic trading platform, novice can also improve financial income lecturer DeltaF, in the past five years, the average annual income of personal investment and financial management exceeded 25%. If you also want to boost your after-sleep income and make easy money, then this course is for you. The course is based on a complete and real quantitative trading business, combined with the financial management experience of the teacher and the use of programming techniques to assist investment skills, so that you can deal with a variety of complex investment situations.
Basic Knowledge of Python (getting started)
General environment parameters
In MongoDB, the OjbectId Json serialization fails to be deserialized. You can solve the problem in the following two ways
1, the simplest and crude method, a new business primary key such as key, in this case equal to the previous _id does not work
2. Use JsonConverter
public class ObjectIdConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return objectType == typeof(ObjectId);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType ! = JsonToken.String) { throw new Exception( String.Format(" Unexpected token parsing ObjectId. Expected String, got {0}." , reader.TokenType)); } var value = (string)reader.Value; return String.IsNullOrEmpty(value) ? ObjectId.Empty : new ObjectId(value); } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { if (value is ObjectId) { var objectId = (ObjectId)value; writer.WriteValue(objectId ! = ObjectId.Empty ? objectId.ToString() : String.Empty); } else { throw new Exception(" Expected ObjectId value.") ; }}}Copy the code
Add a line of code to the ObjectId field
[JsonConverter(typeof(ObjectIdConverter))] public string _id { get; set; } If Newtonsoft’s JsonConvert is used, additional parameters are required
JsonConvert.DeserializeObject(json,new ObjectIdConverter());
3. By Ignore, a very tricky way of writing
[JsonIgnore]
public override ObjectId _Id { get; set; }
[BsonIgnore] public string _IdStr { get { return Id.ToString(); } set { ObjectId id; ObjectId.TryParse(value, out id); Id = id; }}